From 1492acbe31be61e788c1b033cdc72e4bdb654d04 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Tue, 29 Oct 2024 17:12:24 +0000 Subject: [PATCH] Bug 38262: Update UI --- .../en/modules/admin/additional-fields.tt | 3 +- .../prog/js/fetch/acquisition-api-client.js | 2 +- .../vue/components/Vendors/VendorFormAdd.vue | 14 ++- .../js/vue/components/Vendors/VendorList.vue | 86 ++++++++++++++++++- .../js/vue/components/Vendors/VendorShow.vue | 9 ++ 5 files changed, 109 insertions(+), 5 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt index e8c76a2f3b2..529221ac3d9 100755 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/additional-fields.tt @@ -30,7 +30,7 @@ [% marcfield_tables = ['subscription', 'aqorders'] %] -[% searchable_tables = ['subscription', 'aqbasket', 'aqinvoices', 'erm_licenses', 'erm_agreements', 'erm_packages'] %] +[% searchable_tables = ['subscription', 'aqbasket', 'aqinvoices', 'erm_licenses', 'erm_agreements', 'erm_packages', 'aqbooksellers'] %] [% show_marcfield = marcfield_tables.grep('^' _ tablename _ '$').size ? 1 : 0 %] [% show_searchable = searchable_tables.grep('^' _ tablename _ '$').size ? 1 : 0 %] @@ -130,6 +130,7 @@ [% IF CAN_user_acquisition_order_manage %] [% WRAPPER table_option value="aqbasket" %]Order baskets[% END %] [% WRAPPER table_option value="aqorders" %]Order lines[% END %] + [% WRAPPER table_option value="aqbooksellers:vendor" %]Vendors[% END %] [% END %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/acquisition-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/acquisition-api-client.js index 7c33723e04c..f0f1a482df4 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/fetch/acquisition-api-client.js +++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/acquisition-api-client.js @@ -21,7 +21,7 @@ export class AcquisitionAPIClient { endpoint: "vendors/" + id, headers: { "x-koha-embed": - "aliases,subscriptions+count,interfaces,contacts,contracts,baskets+count,invoices+count", + "aliases,subscriptions+count,interfaces,contacts,contracts,baskets+count,invoices+count,extended_attributes,+strings", }, }), getAll: (query, params) => diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorFormAdd.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorFormAdd.vue index 7deb47883ea..a67be6e09c5 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorFormAdd.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorFormAdd.vue @@ -15,6 +15,11 @@ :verifyDiscountValue="verifyDiscountValue" :discountValid="discountValid" /> +
{{ $__("Cancel") }}
- + @@ -37,6 +42,7 @@ import VendorDetails from "./VendorDetails.vue"; import VendorContacts from "./VendorContacts.vue"; import VendorOrderingInformation from "./VendorOrderingInformation.vue"; import VendorInterfaces from "./VendorInterfaces.vue"; +import AdditionalFieldsEntry from "../AdditionalFieldsEntry.vue"; export default { data() { @@ -69,6 +75,7 @@ export default { aliases: [], contacts: [], interfaces: [], + extended_attributes: [], }, initialized: false, discountValid: true, @@ -136,6 +143,7 @@ export default { delete vendor.subscriptions; delete vendor.contracts; delete vendor.invoices_count; + delete vendor._strings; if (!this.discountValid) errors.push(this.$__("Invalid discount value")); @@ -200,6 +208,9 @@ export default { this.vendor.discount ); }, + additionalFieldsChanged(additionalFieldValues) { + this.vendor.extended_attributes = additionalFieldValues; + }, }, components: { ButtonSubmit, @@ -207,6 +218,7 @@ export default { VendorContacts, VendorOrderingInformation, VendorInterfaces, + AdditionalFieldsEntry, }, name: "VendorFormAdd", }; diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorList.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorList.vue index aec7abad968..7931da68fdb 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorList.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorList.vue @@ -17,6 +17,8 @@ @delete="doDelete" @select="doSelect" @receive="doReceive" + :searchable_additional_fields="searchable_additional_fields" + :searchable_av_options="searchable_av_options" >
@@ -65,10 +67,12 @@ export default { vendor_count: 0, initialized: false, searchTerm: null, + searchable_av_options: [], + searchable_additional_fields: [], tableOptions: { columns: this.getTableColumns(), options: { - embed: "aliases,baskets+count,subscriptions+count,invoices+count", + embed: "aliases,baskets+count,subscriptions+count,invoices+count,extended_attributes,+strings", }, url: () => this.tableURL(), table_settings: this.vendorTableSettings, @@ -117,7 +121,15 @@ export default { }, beforeRouteEnter(to, from, next) { next(vm => { - vm.getVendorCount().then(() => (vm.initialized = true)); + vm.getVendorCount().then(() => + vm + .getSearchableAdditionalFields() + .then(() => + vm + .getSearchableAVOptions() + .then(() => (vm.initialized = true)) + ) + ); if (to.query.supplier) { vm.searchTerm = to.query.supplier; } @@ -275,6 +287,76 @@ export default { }, ]; }, + async getSearchableAdditionalFields() { + const client = APIClient.additional_fields; + await client.additional_fields.getAll("vendor").then( + searchable_additional_fields => { + this.searchable_additional_fields = + searchable_additional_fields.filter( + field => field.searchable + ); + }, + error => {} + ); + }, + async getSearchableAVOptions() { + const client_av = APIClient.authorised_values; + let av_cat_array = this.searchable_additional_fields + .filter(field => field.authorised_value_category_name) + .map(field => field.authorised_value_category_name); + + await client_av.values + .getCategoriesWithValues([ + ...new Set(av_cat_array.map(av_cat => '"' + av_cat + '"')), + ]) // unique + .then(av_categories => { + av_cat_array.forEach(av_cat => { + let av_match = av_categories.find( + element => element.category_name == av_cat + ); + this.searchable_av_options[av_cat] = + av_match.authorised_values.map(av => ({ + value: av.value, + label: av.description, + })); + }); + }); + }, + async getSearchableAdditionalFields() { + const client = APIClient.additional_fields; + await client.additional_fields.getAll("vendor").then( + searchable_additional_fields => { + this.searchable_additional_fields = + searchable_additional_fields.filter( + field => field.searchable + ); + }, + error => {} + ); + }, + async getSearchableAVOptions() { + const client_av = APIClient.authorised_values; + let av_cat_array = this.searchable_additional_fields + .filter(field => field.authorised_value_category_name) + .map(field => field.authorised_value_category_name); + + await client_av.values + .getCategoriesWithValues([ + ...new Set(av_cat_array.map(av_cat => '"' + av_cat + '"')), + ]) // unique + .then(av_categories => { + av_cat_array.forEach(av_cat => { + let av_match = av_categories.find( + element => element.category_name == av_cat + ); + this.searchable_av_options[av_cat] = + av_match.authorised_values.map(av => ({ + value: av.value, + label: av.description, + })); + }); + }); + }, }, components: { flatPickr, Toolbar, ToolbarButton, KohaTable }, name: "VendorList", diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorShow.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorShow.vue index 456250ad2eb..6e6e22b5ecd 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorShow.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorShow.vue @@ -86,6 +86,13 @@
+