From 3e4a3a60225d942b887e575751281dfe61bcf4f3 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Tue, 22 Apr 2025 11:58:08 +0100 Subject: [PATCH] Bug 38010: (QA follow-up) Fix issues in Show component This patch addresses the following: - website links were buttons so we now can pass a css class to the toolbar buttons again - contact options have been formatted to have the correct margin - the dropdown-item class has been added to the dropdown button list - entries in the dropdown were opening in a new tab, they are now a callback to avoid this Signed-off-by: Michaela Sieber Signed-off-by: Jonathan Druart --- .../js/vue/components/DropdownButtons.vue | 1 + .../prog/js/vue/components/ToolbarButton.vue | 51 +++++++++++-------- .../vue/components/Vendors/VendorContacts.vue | 16 +++--- .../vue/components/Vendors/VendorDetails.vue | 2 +- .../components/Vendors/VendorInterfaces.vue | 2 +- .../js/vue/components/Vendors/VendorShow.vue | 14 ++++- 6 files changed, 54 insertions(+), 32 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/DropdownButtons.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/DropdownButtons.vue index 7f10b634b88..ac04e60984a 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/DropdownButtons.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/DropdownButtons.vue @@ -12,6 +12,7 @@ :to="item.to" :title="$__(item.title)" :callback="item.callback" + :cssClass="'dropdown-item'" /> diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ToolbarButton.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ToolbarButton.vue index b13d3dbcf5f..554b6fa944b 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ToolbarButton.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/ToolbarButton.vue @@ -1,16 +1,13 @@ @@ -32,24 +29,20 @@ export default { type: [String, Function], required: false, }, + cssClass: { + type: String, + default: "btn btn-default", + required: false, + }, }, methods: { - redirect() { - if (typeof this.to === "string") - window.location.href = this.formatUrl(this.to); - if (typeof this.to === "object") { - let url = this.to.path; - if (this.to.hasOwnProperty("query")) { - url += - "?" + - Object.keys(this.to.query) - .map( - queryParam => - `${queryParam}=${this.to.query[queryParam]}` - ) - .join("&"); - } - window.open(this.formatUrl(url, this.to.internal), "_blank"); + redirect(url) { + const redirectParams = url ? url : this.to; + if (typeof redirectParams === "string") + window.location.href = this.formatUrl(redirectParams); + if (typeof redirectParams === "object") { + const url = this.handleQuery(redirectParams); + window.open(this.formatUrl(url), "_blank"); } }, formatUrl(url) { @@ -58,6 +51,20 @@ export default { return `//${window.location.host}/${url}`; return `//${url}`; }, + handleQuery(query) { + let url = this.to.path; + if (this.to.hasOwnProperty("query")) { + url += + "?" + + Object.keys(this.to.query) + .map( + queryParam => + `${queryParam}=${this.to.query[queryParam]}` + ) + .join("&"); + } + return url; + }, }, name: "ToolbarButton", }; diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorContacts.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorContacts.vue index 8ca36a4356c..e1afb903068 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorContacts.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/VendorContacts.vue @@ -46,19 +46,19 @@ {{ $__("Acquisitions options") }}:
  1. - {{ $__("Primary acquisitions contact") }}
  2. - {{ $__("Receives orders") }}
  3. - {{ $__("Receives claims for late orders") }} @@ -69,13 +69,13 @@ {{ $__("Serials options") }}:
    1. - {{ $__("Primary serials contact") }}
    2. - {{ $__("Receives claims for late issues") }} @@ -281,4 +281,8 @@ export default { }; - + 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 cd77214a9e1..c6f8ce0023a 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 @@ -49,7 +49,7 @@ :to="{ path: vendor.url, }" - class="" + :cssClass="''" :title="vendor.url" callback="redirect" /> 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 92c02d4d840..40f3ff86606 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 @@ -17,7 +17,7 @@ :to="{ path: vi.uri, }" - class="" + :cssClass="''" :title="vi.uri" callback="redirect" /> 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 e0114e8b137..77fdcbb3853 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 @@ -10,7 +10,12 @@ query: { booksellerid: vendor.id, op: 'add_form' }, }, title: 'Basket', - callback: 'redirect', + callback: toolbarComponent => { + const url = toolbarComponent.handleQuery( + toolbarComponent.to + ); + toolbarComponent.redirect(url); + }, }, { to: { @@ -18,7 +23,12 @@ query: { booksellerid: vendor.id, op: 'add_form' }, }, title: 'Contract', - callback: 'redirect', + callback: toolbarComponent => { + const url = toolbarComponent.handleQuery( + toolbarComponent.to + ); + toolbarComponent.redirect(url); + }, }, { to: { name: 'VendorFormAdd' }, -- 2.34.1