From 14f1cbb94223bf9cbd5bd21b406c4fcb58e7f10e Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Mon, 25 Aug 2025 20:51:54 +0000 Subject: [PATCH] Bug 31698: Move request.tt JS to hold.js --- .../prog/en/includes/holds_table.inc | 12 +- .../prog/en/modules/reserve/request.tt | 95 --------------- koha-tmpl/intranet-tmpl/prog/js/holds.js | 108 ++++++++++++++++++ 3 files changed, 119 insertions(+), 96 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc index 0e0ae915821..ba64eda6e73 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc @@ -46,7 +46,17 @@ [%- END -%] [% SET tr_class = hold.suspend ? 'suspend' : '' %] - +
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt index 833b41d164c..9d6db932955 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt @@ -1854,101 +1854,6 @@ } $(document).ready(function() { - $("#itemSearchForm").on("submit", function (event) { - event.preventDefault(); - $('#move_hold_item_confirm').prop('disabled' , true ); - - let externalID = $("#external_id").val(); - let apiUrl = `/api/v1/items?external_id=${encodeURIComponent(externalID)}`; - - $.ajax({ - url: apiUrl, - method: "GET", - dataType: "json", - success: function (data) { - // Filter for exact matches only - let exactMatches = data.filter(item => item.external_id === externalID); - if (exactMatches.length > 0) { - let resultHtml = ""; - $.each(exactMatches, function (index, item) { - resultHtml += ` -
- Biblionumber: ${item.biblio_id}
- Item: ${item.external_id}
- - - -
-
- `; - }); - $("#itemResultMessage").html(resultHtml); - } else { - $("#itemResultMessage").html(` -
No item found with barcode: ${externalID}.
- `); - } - }, - }); - }); - - $("#biblioSearchForm").on("submit", function (event) { - event.preventDefault(); - $('#move_hold_biblio_confirm').prop('disabled' , true ); - - let biblioID = parseInt( $("#biblio_id").val() ); - let apiUrl = `/api/v1/biblios?q={"biblio_id":"${encodeURIComponent(biblioID)}"}`; - $.ajax({ - url: apiUrl, - method: "GET", - dataType: "json", - headers: { - 'Accept': 'application/json' - }, - success: function (data) { - // Filter for exact matches only - let exactMatches = data.filter(item => item.biblio_id === biblioID); - - - if (exactMatches.length > 0) { - let resultHtml = ""; - $.each(exactMatches, function (index, item) { - resultHtml += ` -
- Biblionumber: ${item.biblio_id}
- - -
-
- `; - }); - $("#biblioResultMessage").html(resultHtml); - } else { - $("#biblioResultMessage").html(` -
No record found with biblionumber: ${biblioID}.
- `); - } - } - }); - }); - - $(document).on("change", 'input[name="new_itemnumber"]', function() { - $('input[name="new_itemnumber"]').not(this).prop("checked", false); - if ( $('input[name="new_itemnumber"]:checked').length ){ - $('#move_hold_item_confirm').prop( 'disabled' , false ); - } else { - $('#move_hold_item_confirm').prop( 'disabled' , true ); - } - }); - - $(document).on("change", 'input[name="new_biblionumber"]', function() { - $('input[name="new_biblionumber"]').not(this).prop("checked", false); - if ( $('input[name="new_biblionumber"]:checked').length ){ - $('#move_hold_biblio_confirm').prop('disabled' , false ); - } else { - $('#move_hold_biblio_confirm').prop('disabled' , true ); - } - }); $("#always_show_holds").change(function(){ if( $(this).prop('checked') ){ diff --git a/koha-tmpl/intranet-tmpl/prog/js/holds.js b/koha-tmpl/intranet-tmpl/prog/js/holds.js index 6f746a8e109..e5c08efa572 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/holds.js +++ b/koha-tmpl/intranet-tmpl/prog/js/holds.js @@ -715,6 +715,7 @@ $(document).ready(function () { }); var MSG_CANCEL_SELECTED = __("Cancel selected (%s)"); + var MSG_MOVE_SELECTED = __("Move selected (%s)"); var MSG_CANCEL_ALERT = __( "This action will cancel %s hold(s)." ); @@ -780,6 +781,11 @@ $(document).ready(function () { $(".holds_table .select_hold:checked").length ) ); + $(".move_selected_holds").html( + MSG_MOVE_SELECTED.format( + $(".holds_table .select_hold:checked").length + ) + ); $(".suspend_selected_holds").html( MSG_SUSPEND_SELECTED.format( $(".holds_table .select_hold:checked").length @@ -819,11 +825,13 @@ $(document).ready(function () { ) .join(",") + "]"; + $(".move_selected_holds").prop("disabled", count); }); $(".holds_table").on("click", ".select_hold", function () { var table = $(this).parents(".holds_table"); var count = $(".select_hold:not(:checked)", table).length; + var checked_count = $(".select_hold:checked", table).length; $(".select_hold_all", table).prop("checked", !count); updateSelectedHoldsButtonCounters(); $("#cancel_hold_alert").html( @@ -845,6 +853,7 @@ $(document).ready(function () { ) .join(",") + "]"; + $(".move_selected_holds").prop("disabled", !checked_count); }); $(".cancel_selected_holds").click(function (e) { @@ -897,6 +906,105 @@ $(document).ready(function () { return false; }); + $("#itemSearchForm").on("submit", function (event) { + event.preventDefault(); + $("#move_hold_item_confirm").prop("disabled", true); + + let externalID = $("#external_id").val(); + let apiUrl = `/api/v1/items?external_id=${encodeURIComponent(externalID)}`; + + $.ajax({ + url: apiUrl, + method: "GET", + dataType: "json", + success: function (data) { + // Filter for exact matches only + let exactMatches = data.filter( + item => item.external_id === externalID + ); + if (exactMatches.length > 0) { + let resultHtml = ""; + $.each(exactMatches, function (index, item) { + resultHtml += ` +
+ Biblionumber: ${item.biblio_id}
+ Item: ${item.external_id}
+ + + +
+
+ `; + }); + $("#itemResultMessage").html(resultHtml); + } else { + $("#itemResultMessage").html(` +
No item found with barcode: ${externalID}.
+ `); + } + }, + }); + }); + + $("#biblioSearchForm").on("submit", function (event) { + event.preventDefault(); + $("#move_hold_biblio_confirm").prop("disabled", true); + + let biblioID = parseInt($("#biblio_id").val()); + let apiUrl = `/api/v1/biblios?q={"biblio_id":"${encodeURIComponent(biblioID)}"}`; + $.ajax({ + url: apiUrl, + method: "GET", + dataType: "json", + headers: { + Accept: "application/json", + }, + success: function (data) { + // Filter for exact matches only + let exactMatches = data.filter( + item => item.biblio_id === biblioID + ); + + if (exactMatches.length > 0) { + let resultHtml = ""; + $.each(exactMatches, function (index, item) { + resultHtml += ` +
+ Biblionumber: ${item.biblio_id}
+ + +
+
+ `; + }); + $("#biblioResultMessage").html(resultHtml); + } else { + $("#biblioResultMessage").html(` +
No record found with biblionumber: ${biblioID}.
+ `); + } + }, + }); + }); + + $(document).on("change", 'input[name="new_itemnumber"]', function () { + $('input[name="new_itemnumber"]').not(this).prop("checked", false); + if ($('input[name="new_itemnumber"]:checked').length) { + $("#move_hold_item_confirm").prop("disabled", false); + } else { + $("#move_hold_item_confirm").prop("disabled", true); + } + }); + + $(document).on("change", 'input[name="new_biblionumber"]', function () { + $('input[name="new_biblionumber"]').not(this).prop("checked", false); + if ($('input[name="new_biblionumber"]:checked').length) { + $("#move_hold_biblio_confirm").prop("disabled", false); + } else { + $("#move_hold_biblio_confirm").prop("disabled", true); + } + }); + function _append_patron_page_cancel_hold_modal_data(hold) { $("#cancel_modal_form #inputs").append( '' -- 2.39.5