View | Details | Raw Unified | Return to bug 35287
Collapse All | Expand All

(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesFormAdd.vue (+12 lines)
Lines 109-114 Link Here
109
                        </li>
109
                        </li>
110
                    </ol>
110
                    </ol>
111
                </fieldset>
111
                </fieldset>
112
                <AdditionalFieldsEntry
113
                    tablename="erm_licenses"
114
                    :additional_field_values="license.extended_attributes"
115
                    @additional-fields-changed="additionalFieldsChanged"
116
                />
112
                <UserRoles
117
                <UserRoles
113
                    :user_type="$__('License user %s')"
118
                    :user_type="$__('License user %s')"
114
                    :user_roles="license.user_roles"
119
                    :user_roles="license.user_roles"
Lines 134-139 import { inject } from "vue" Link Here
134
import flatPickr from "vue-flatpickr-component"
139
import flatPickr from "vue-flatpickr-component"
135
import UserRoles from "./UserRoles.vue"
140
import UserRoles from "./UserRoles.vue"
136
import Documents from "./Documents.vue"
141
import Documents from "./Documents.vue"
142
import AdditionalFieldsEntry from "../AdditionalFieldsEntry.vue"
137
import FormSelectVendors from "../FormSelectVendors.vue"
143
import FormSelectVendors from "../FormSelectVendors.vue"
138
import { setMessage, setWarning } from "../../messages"
144
import { setMessage, setWarning } from "../../messages"
139
import { APIClient } from "../../fetch/api-client.js"
145
import { APIClient } from "../../fetch/api-client.js"
Lines 166-171 export default { Link Here
166
                ended_on: undefined,
172
                ended_on: undefined,
167
                user_roles: [],
173
                user_roles: [],
168
                documents: [],
174
                documents: [],
175
                extended_attributes: [],
169
            },
176
            },
170
            initialized: false,
177
            initialized: false,
171
        }
178
        }
Lines 228-233 export default { Link Here
228
235
229
            delete license.license_id
236
            delete license.license_id
230
            delete license.vendor
237
            delete license.vendor
238
            delete license._strings
231
239
232
            if (license.vendor_id == "") {
240
            if (license.vendor_id == "") {
233
                license.vendor_id = null
241
                license.vendor_id = null
Lines 260-271 export default { Link Here
260
                )
268
                )
261
            }
269
            }
262
        },
270
        },
271
        additionalFieldsChanged(additionalFieldValues) {
272
            this.license.extended_attributes = additionalFieldValues
273
        },
263
    },
274
    },
264
    components: {
275
    components: {
265
        flatPickr,
276
        flatPickr,
266
        UserRoles,
277
        UserRoles,
267
        Documents,
278
        Documents,
268
        FormSelectVendors,
279
        FormSelectVendors,
280
        AdditionalFieldsEntry,
269
    },
281
    },
270
    name: "LicensesFormAdd",
282
    name: "LicensesFormAdd",
271
}
283
}
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesList.vue (-2 / +49 lines)
Lines 12-17 Link Here
12
            <KohaTable
12
            <KohaTable
13
                ref="table"
13
                ref="table"
14
                v-bind="tableOptions"
14
                v-bind="tableOptions"
15
                :searchable_additional_fields="searchable_additional_fields"
16
                :searchable_av_options="searchable_av_options"
15
                @show="doShow"
17
                @show="doShow"
16
                @edit="doEdit"
18
                @edit="doEdit"
17
                @delete="doDelete"
19
                @delete="doDelete"
Lines 64-73 export default { Link Here
64
                    button_title: this.$__("New license"),
66
                    button_title: this.$__("New license"),
65
                },
67
                },
66
            ],
68
            ],
69
            searchable_additional_fields: [],
70
            searchable_av_options: [],
67
            tableOptions: {
71
            tableOptions: {
68
                columns: this.getTableColumns(),
72
                columns: this.getTableColumns(),
69
                url: "/api/v1/erm/licenses",
73
                url: "/api/v1/erm/licenses",
70
                options: { embed: "vendor" },
74
                options: { embed: "vendor,extended_attributes,+strings" },
71
                table_settings: this.license_table_settings,
75
                table_settings: this.license_table_settings,
72
                add_filters: true,
76
                add_filters: true,
73
                filters_options: {
77
                filters_options: {
Lines 89-95 export default { Link Here
89
    },
93
    },
90
    beforeRouteEnter(to, from, next) {
94
    beforeRouteEnter(to, from, next) {
91
        next(vm => {
95
        next(vm => {
92
            vm.getLicenseCount().then(() => (vm.initialized = true))
96
            vm.getLicenseCount().then(() =>
97
                vm
98
                    .getSearchableAdditionalFields()
99
                    .then(() =>
100
                        vm
101
                            .getSearchableAVOptions()
102
                            .then(() => (vm.initialized = true))
103
                    )
104
            )
93
        })
105
        })
94
    },
106
    },
95
    methods: {
107
    methods: {
Lines 102-107 export default { Link Here
102
                error => {}
114
                error => {}
103
            )
115
            )
104
        },
116
        },
117
        async getSearchableAdditionalFields() {
118
            const client = APIClient.additional_fields
119
            await client.additional_fields.getAll("erm_licenses").then(
120
                searchable_additional_fields => {
121
                    this.searchable_additional_fields =
122
                        searchable_additional_fields.filter(
123
                            field => field.searchable
124
                        )
125
                },
126
                error => {}
127
            )
128
        },
129
        async getSearchableAVOptions() {
130
            const client_av = APIClient.authorised_values
131
            let av_cat_array = this.searchable_additional_fields
132
                .filter(field => field.authorised_value_category)
133
                .map(field => field.authorised_value_category)
134
135
            await client_av.values
136
                .getCategoriesWithValues([
137
                    ...new Set(av_cat_array.map(av_cat => '"' + av_cat + '"')),
138
                ]) // unique
139
                .then(av_categories => {
140
                    av_cat_array.forEach(av_cat => {
141
                        let av_match = av_categories.find(
142
                            element => element.category_name == av_cat
143
                        )
144
                        this.searchable_av_options[av_cat] =
145
                            av_match.authorised_values.map(av => ({
146
                                value: av.value,
147
                                label: av.description,
148
                            }))
149
                    })
150
                })
151
        },
105
        doShow: function ({ license_id }, dt, event) {
152
        doShow: function ({ license_id }, dt, event) {
106
            event.preventDefault()
153
            event.preventDefault()
107
            this.$router.push({ name: "LicensesShow", params: { license_id } })
154
            this.$router.push({ name: "LicensesShow", params: { license_id } })
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/LicensesShow.vue (-1 / +12 lines)
Lines 132-137 Link Here
132
                    </li>
132
                    </li>
133
                </ol>
133
                </ol>
134
            </fieldset>
134
            </fieldset>
135
            <AdditionalFieldsDisplay
136
                tablename="erm_licenses"
137
                :additional_field_values="
138
                    license._strings.additional_field_values
139
                "
140
            />
135
            <fieldset class="action">
141
            <fieldset class="action">
136
                <router-link
142
                <router-link
137
                    :to="{ name: 'LicensesList' }"
143
                    :to="{ name: 'LicensesList' }"
Lines 147-152 Link Here
147
<script>
153
<script>
148
import { inject } from "vue"
154
import { inject } from "vue"
149
import { APIClient } from "../../fetch/api-client.js"
155
import { APIClient } from "../../fetch/api-client.js"
156
import AdditionalFieldsDisplay from "../AdditionalFieldsDisplay.vue"
150
157
151
export default {
158
export default {
152
    setup() {
159
    setup() {
Lines 177-182 export default { Link Here
177
                type: "",
184
                type: "",
178
                status: "",
185
                status: "",
179
                user_roles: [],
186
                user_roles: [],
187
                extended_attributes: [],
188
                _strings: [],
180
                started_on: undefined,
189
                started_on: undefined,
181
                ended_on: undefined,
190
                ended_on: undefined,
182
            },
191
            },
Lines 227-233 export default { Link Here
227
            )
236
            )
228
        },
237
        },
229
    },
238
    },
230
    components: {},
239
    components: {
240
        AdditionalFieldsDisplay,
241
    },
231
    name: "LicensesShow",
242
    name: "LicensesShow",
232
}
243
}
233
</script>
244
</script>
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/fetch/erm-api-client.js (-2 / +1 lines)
Lines 66-72 export class ERMAPIClient extends HttpClient { Link Here
66
                    endpoint: "licenses/" + id,
66
                    endpoint: "licenses/" + id,
67
                    headers: {
67
                    headers: {
68
                        "x-koha-embed":
68
                        "x-koha-embed":
69
                            "user_roles,user_roles.patron,vendor,documents",
69
                            "user_roles,user_roles.patron,vendor,documents,extended_attributes,+strings",
70
                    },
70
                    },
71
                }),
71
                }),
72
            getAll: (query, params) =>
72
            getAll: (query, params) =>
73
- 

Return to bug 35287