From 813e82ec50aa236b766c1a9ca434f145059c2dd6 Mon Sep 17 00:00:00 2001 From: Jake Deery Date: Thu, 5 Mar 2026 16:29:18 +0000 Subject: [PATCH] Bug 14962: (QA follow-up) Fix edit display hanging when barcode has multiple matches This patch fixes a bug where lower-order barcodes could not be added if there were multiple starts_with matches. This will mean librarians can add e.g. an item barcode of 3, when there is an item with barcode of 33 as well. This patch also reduces the number of API calls when a display is viewed, by using the embeded biblio, rather than a separate call. Sponsored-by: ByWater Solutions --- .../prog/js/fetch/item-api-client.js | 1 + .../vue/components/Display/DisplaysResource.vue | 15 ++++----------- 2 files changed, 5 insertions(+), 11 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/fetch/item-api-client.js b/koha-tmpl/intranet-tmpl/prog/js/fetch/item-api-client.js index 12f6f757ac1..fe5ef6e4cd7 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/fetch/item-api-client.js +++ b/koha-tmpl/intranet-tmpl/prog/js/fetch/item-api-client.js @@ -28,6 +28,7 @@ export class ItemAPIClient { "items?" + new URLSearchParams({ _match: "starts_with", + _order_by: "me.barcode", external_id: external_id, }), headers: { diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Display/DisplaysResource.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Display/DisplaysResource.vue index a8025ee6cfe..2e5b35c24d0 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Display/DisplaysResource.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Display/DisplaysResource.vue @@ -389,7 +389,7 @@ export default { await itemsApiClient .getByExternalId(external_id) .then(data => { - if (data.length == 1) item = data[0]; + if (data.length > 0) item = data[0]; }) .catch(error => { console.error(error); @@ -519,18 +519,11 @@ export default { componentData.resource.value.display_items[idx].barcode = _("Loading"); - getBiblioFromId(display_item.biblionumber) - .then(biblio => { - componentData.resource.value.display_items[ - idx - ].title = biblio.title; - }) - .catch(error => { - console.error(error); - }); - getItemFromId(display_item.itemnumber) .then(item => { + componentData.resource.value.display_items[ + idx + ].title = item.biblio?.title || _("Unknown biblio"); componentData.resource.value.display_items[ idx ].barcode = item.external_id; -- 2.50.1 (Apple Git-155)