From 8848ee26a6dae3885253299994a417f22816ecdd Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Tue, 8 Nov 2022 14:53:07 -0100 Subject: [PATCH] Bug 30719: (QA Follow-up): - Fix wrong link 'Create a new batch status message' in case there are no existing batch statuses - Detail of batch update - View status of any request within a batch - Fix typo to correctly display status code on batch statuses list page - Fixed an issue with illrequest api definition that prevented the listing of any ILL requests if any request had a status_alias - Updated "Add items to batch" css class to match new 22.11 style - Fixed conflict issue where it prevented the creation of a single request in a backend that is using JS field validation utilizing the #cardnumber selector - Added a check for metadata enrichment plugins and bail batches JS code if none are found, this prevents a console error - Remove ysearch from patron auto complete in batch creation and use patron_autocomplete instead - 'New batch' and 'list batches' buttons no longer show if no metadata plugin is installed Sponsored-by: UKHSA --- api/v1/swagger/definitions/illrequest.yaml | 2 +- .../prog/en/includes/ill-batch-modal.inc | 7 +-- .../prog/en/includes/ill-toolbar.inc | 2 +- .../en/modules/admin/ill_batch_statuses.tt | 4 +- .../intranet-tmpl/prog/js/ill-batch-modal.js | 43 +++++++++++-------- 5 files changed, 33 insertions(+), 25 deletions(-) diff --git a/api/v1/swagger/definitions/illrequest.yaml b/api/v1/swagger/definitions/illrequest.yaml index c37f7a30d3..78f9dc8385 100644 --- a/api/v1/swagger/definitions/illrequest.yaml +++ b/api/v1/swagger/definitions/illrequest.yaml @@ -128,7 +128,7 @@ properties: description: The request's current status status_alias: type: - - string + - object - "null" description: The ID of a user defined status for this request updated: diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-batch-modal.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/ill-batch-modal.inc index f0abfa8a64..b7587606e1 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-batch-modal.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/ill-batch-modal.inc @@ -18,8 +18,8 @@ value="" />
  • - - + +
  • @@ -65,7 +65,7 @@ @@ -74,6 +74,7 @@ + diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-toolbar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/ill-toolbar.inc index ffc6055071..cbb6bfd13e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/ill-toolbar.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/ill-toolbar.inc @@ -32,7 +32,7 @@ List requests [% END %] - [% IF have_batch.size > 0 %] + [% IF have_batch.size > 0 && metadata_enrichment_services %]
    - + [% ELSE %]
    - There are no batch statuses defined. Create new batch status + There are no batch statuses defined. Create new batch status
    [% END %] [% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/ill-batch-modal.js b/koha-tmpl/intranet-tmpl/prog/js/ill-batch-modal.js index 70f9e29c5a..469292d753 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/ill-batch-modal.js +++ b/koha-tmpl/intranet-tmpl/prog/js/ill-batch-modal.js @@ -1,4 +1,10 @@ (function () { + // Bail if there aren't any metadata enrichment plugins installed + if (typeof metadata_enrichment_services === 'undefined') { + console.log('No metadata enrichment plugins found.') + return; + } + window.addEventListener('load', onload); // Delay between API requests @@ -7,7 +13,7 @@ // Elements we work frequently with var textarea = document.getElementById("identifiers_input"); var nameInput = document.getElementById("name"); - var cardnumberInput = document.getElementById("cardnumber"); + var cardnumberInput = document.getElementById("batchcardnumber"); var branchcodeSelect = document.getElementById("branchcode"); var processButton = document.getElementById("process_button"); var createButton = document.getElementById("button_create_batch"); @@ -21,7 +27,6 @@ var createRequestsButton = document.getElementById('create-requests-button'); var statusesSelect = document.getElementById('statuscode'); - // We need a data structure keyed on identifier type, which tells us how to parse that // identifier type and what services can get its metadata. We receive an array of // available services @@ -299,6 +304,7 @@ tableContent.data = tableContent.data.map(function (row) { if (row.value === identifier) { row.requestId = data.illrequest_id; + row.requestStatus = data.status; } return row; }); @@ -893,6 +899,10 @@ return data.requestId || '-'; } + function createRequestStatus(x, y, data) { + return data.requestStatus || '-'; + } + function buildTable(identifiers) { table = KohaTable('identifier-table', { processing: true, @@ -918,9 +928,14 @@ }, { data: 'requestId', - width: '13%', + width: '6.5%', render: createRequestId }, + { + data: 'requestStatus', + width: '6.5%', + render: createRequestStatus + }, { width: '18%', render: createActions, @@ -1021,23 +1036,15 @@ } function patronAutocomplete() { - // Add autocomplete for patron selection - $('#batch-form #cardnumber').autocomplete({ - appendTo: '#batch-form', - source: "/cgi-bin/koha/circ/ysearch.pl", - minLength: 3, - select: function (event, ui) { - var field = ui.item.cardnumber; - $('#batch-form #cardnumber').val(field) + patron_autocomplete( + $('#batch-form #batchcardnumber'), + { + 'on-select-callback': function( event, ui ) { + $("#batch-form #batchcardnumber").val( ui.item.cardnumber ); return false; + } } - }) - .data("ui-autocomplete")._renderItem = function (ul, item) { - return $("
  • ") - .data("ui-autocomplete-item", item) - .append("" + item.surname + ", " + item.firstname + " (" + item.cardnumber + ") " + item.address + " " + item.city + " " + item.zipcode + " " + item.country + "") - .appendTo(ul); - }; + ); }; function createPatronLink() { -- 2.30.2