From bfa3b2f3ff0802732de11d45ad2cd166e5eb4314 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Wed, 15 Jan 2025 15:10:42 +0000 Subject: [PATCH] Bug 38010: (QA follow-up) Fix new vendor form Signed-off-by: Michaela Sieber Signed-off-by: Jonathan Druart --- .../vue/components/Vendors/VendorDetails.vue | 6 ++++- .../vue/components/Vendors/VendorFormAdd.vue | 27 ++++++++++++++----- .../components/Vendors/VendorInterfaces.vue | 8 +++--- .../Vendors/VendorOrderingInformation.vue | 6 +++-- 4 files changed, 34 insertions(+), 13 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorDetails.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorDetails.vue index 6d6f8df17db..70409fb389a 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorDetails.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorDetails.vue @@ -195,11 +195,15 @@ export default { if (!this.vendor.aliases) { this.vendor.aliases = []; } + if (!this.newAlias) return; this.vendor.aliases.push({ alias: this.newAlias }); this.newAlias = ""; }, removeAlias(e) { - this.vendor.aliases.splice(this.vendor.aliases.indexOf(e.alias), 1); + const aliasIndex = this.vendor.aliases + .map(e => e.alias) + .indexOf(e.alias); + this.vendor.aliases.splice(aliasIndex, 1); }, }, components: { 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 2405a70ebde..7f31ea051d7 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 @@ -114,13 +114,17 @@ export default { delete vendor.physical; delete vendor.subscriptions_count; - vendor.contacts = vendor.contacts.map( - ({ id, booksellerid, ...requiredProperties }) => - requiredProperties + vendor.contacts = this.checkContactOrInterface( + vendor.contacts.map( + ({ id, booksellerid, ...requiredProperties }) => + requiredProperties + ) ); - vendor.interfaces = vendor.interfaces.map( - ({ interface_id, vendor_id, ...requiredProperties }) => - requiredProperties + vendor.interfaces = this.checkContactOrInterface( + vendor.interfaces.map( + ({ interface_id, vendor_id, ...requiredProperties }) => + requiredProperties + ) ); const client = APIClient.acquisition; @@ -142,6 +146,17 @@ export default { ); } }, + checkContactOrInterface(array) { + return array.reduce((acc, curr) => { + const atLeastOneFieldFilled = Object.keys(curr).some( + key => curr[key] + ); + if (atLeastOneFieldFilled) { + acc.push(curr); + } + return acc; + }, []); + }, }, components: { ButtonSubmit, diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorInterfaces.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorInterfaces.vue index b094ec87e04..e2a1ed1281d 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorInterfaces.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorInterfaces.vue @@ -58,10 +58,6 @@ > {{ $__("Interface details") }} - - {{ $__("Remove this interface") }}
  1. @@ -131,6 +127,10 @@ />
+ + {{ $__("Delete interface") }} diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorOrderingInformation.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorOrderingInformation.vue index d24b353e6a4..abec175f5e0 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorOrderingInformation.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorOrderingInformation.vue @@ -186,7 +186,8 @@