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
                    resource_type="license"
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 138-143 import { inject } from "vue" Link Here
138
import flatPickr from "vue-flatpickr-component"
143
import flatPickr from "vue-flatpickr-component"
139
import UserRoles from "./UserRoles.vue"
144
import UserRoles from "./UserRoles.vue"
140
import Documents from "./Documents.vue"
145
import Documents from "./Documents.vue"
146
import AdditionalFieldsEntry from "../AdditionalFieldsEntry.vue"
141
import FormSelectVendors from "../FormSelectVendors.vue"
147
import FormSelectVendors from "../FormSelectVendors.vue"
142
import { setMessage, setWarning } from "../../messages"
148
import { setMessage, setWarning } from "../../messages"
143
import { APIClient } from "../../fetch/api-client.js"
149
import { APIClient } from "../../fetch/api-client.js"
Lines 170-175 export default { Link Here
170
                ended_on: undefined,
176
                ended_on: undefined,
171
                user_roles: [],
177
                user_roles: [],
172
                documents: [],
178
                documents: [],
179
                extended_attributes: [],
173
            },
180
            },
174
            initialized: false,
181
            initialized: false,
175
        }
182
        }
Lines 232-237 export default { Link Here
232
239
233
            delete license.license_id
240
            delete license.license_id
234
            delete license.vendor
241
            delete license.vendor
242
            delete license._strings
235
243
236
            if (license.vendor_id == "") {
244
            if (license.vendor_id == "") {
237
                license.vendor_id = null
245
                license.vendor_id = null
Lines 264-275 export default { Link Here
264
                )
272
                )
265
            }
273
            }
266
        },
274
        },
275
        additionalFieldsChanged(additionalFieldValues) {
276
            this.license.extended_attributes = additionalFieldValues
277
        },
267
    },
278
    },
268
    components: {
279
    components: {
269
        flatPickr,
280
        flatPickr,
270
        UserRoles,
281
        UserRoles,
271
        Documents,
282
        Documents,
272
        FormSelectVendors,
283
        FormSelectVendors,
284
        AdditionalFieldsEntry,
273
    },
285
    },
274
    name: "LicensesFormAdd",
286
    name: "LicensesFormAdd",
275
}
287
}
(-)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("license").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_name)
133
                .map(field => field.authorised_value_category_name)
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 / +10 lines)
Lines 136-141 Link Here
136
                    </li>
136
                    </li>
137
                </ol>
137
                </ol>
138
            </fieldset>
138
            </fieldset>
139
            <AdditionalFieldsDisplay
140
                resource_type="license"
141
                :additional_field_values="
142
                    license._strings.additional_field_values
143
                "
144
            />
139
            <fieldset class="action">
145
            <fieldset class="action">
140
                <router-link
146
                <router-link
141
                    :to="{ name: 'LicensesList' }"
147
                    :to="{ name: 'LicensesList' }"
Lines 153-158 import { inject } from "vue" Link Here
153
import { APIClient } from "../../fetch/api-client.js"
159
import { APIClient } from "../../fetch/api-client.js"
154
import Toolbar from "../Toolbar.vue"
160
import Toolbar from "../Toolbar.vue"
155
import ToolbarButton from "../ToolbarButton.vue"
161
import ToolbarButton from "../ToolbarButton.vue"
162
import AdditionalFieldsDisplay from "../AdditionalFieldsDisplay.vue"
156
163
157
export default {
164
export default {
158
    setup() {
165
    setup() {
Lines 183-188 export default { Link Here
183
                type: "",
190
                type: "",
184
                status: "",
191
                status: "",
185
                user_roles: [],
192
                user_roles: [],
193
                extended_attributes: [],
194
                _strings: [],
186
                started_on: undefined,
195
                started_on: undefined,
187
                ended_on: undefined,
196
                ended_on: undefined,
188
            },
197
            },
Lines 233-239 export default { Link Here
233
            )
242
            )
234
        },
243
        },
235
    },
244
    },
236
    components: { Toolbar, ToolbarButton },
245
    components: { Toolbar, ToolbarButton, AdditionalFieldsDisplay },
237
    name: "LicensesShow",
246
    name: "LicensesShow",
238
}
247
}
239
</script>
248
</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