Bugzilla – Attachment 184111 Details for
Bug 40395
Allow selecting multiple holds in patron detail page to perform actions on
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 40395: Preparation: Move holds table JS from request.tt to holds.js
Bug-40395-Preparation-Move-holds-table-JS-from-req.patch (text/plain), 14.56 KB, created by
Pedro Amorim
on 2025-07-15 15:01:39 UTC
(
hide
)
Description:
Bug 40395: Preparation: Move holds table JS from request.tt to holds.js
Filename:
MIME Type:
Creator:
Pedro Amorim
Created:
2025-07-15 15:01:39 UTC
Size:
14.56 KB
patch
obsolete
>From ba79ed803c3e7c7cf33a99d8b0a3760e45450d51 Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@openfifth.co.uk> >Date: Tue, 15 Jul 2025 12:41:32 +0000 >Subject: [PATCH] Bug 40395: Preparation: Move holds table JS from request.tt > to holds.js > >This is so that tables from patron-detail-tabs.inc can also make use of this JS >--- > .../prog/en/modules/reserve/request.tt | 73 ------ > koha-tmpl/intranet-tmpl/prog/js/holds.js | 221 ++++++++++++++++++ > 2 files changed, 221 insertions(+), 73 deletions(-) > >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 f4a01f47bc9..abf5ccefb28 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >@@ -1429,8 +1429,6 @@ > pickupNotInHoldGroup: _("Only pickup locations within the same hold group are allowed") > } > >- var MSG_CANCEL_SELECTED = _("Cancel selected (%s)"); >- var MSG_CANCEL_ALERT = _("This action will cancel <span class='badge bg-danger'>%s</span> hold(s)."); > $.fn.select2.defaults.set("width", "100%" ); > $.fn.select2.defaults.set("dropdownAutoWidth", true ); > >@@ -1749,21 +1747,6 @@ > $("#" + fieldID).val(""); > }); > >- // Confirm cancellation of hold >- let cancel_link; >- $(".cancel-hold").on("click",function(e) { >- e.preventDefault; >- cancel_link = $(this); >- $("#cancel_modal_form #inputs").empty(); >- let reserve_id = cancel_link.data('id'); >- let biblionumber = cancel_link.data('biblionumber'); >- $("#cancel_modal_form #inputs").append('<input type="hidden" name="reserve_id" value="' + reserve_id + '">'); >- $("#cancel_modal_form #inputs").append('<input type="hidden" name="biblionumber" value="' + biblionumber + '">'); >- $("#cancel_modal_form #inputs").append('<input type="hidden" name="op" value="cud-cancel">'); >- $('#cancelModal').modal('show'); >- return false; >- }); >- > [% UNLESS ( patron || patron.borrowernumber || borrowers || noitems || nobiblio ) %] > [% IF ( PatronAutoComplete ) %] > patron_autocomplete($(".search_patron_filter"), { 'link-to': 'reserve', 'url-params': '[% url_biblio_params | url %]' }); >@@ -1780,62 +1763,6 @@ > }); > [% END %] > >- if(!localStorage.selectedHolds || document.referrer.replace(/\?.*/, '') !== document.location.origin+document.location.pathname) { >- localStorage.selectedHolds = []; >- } >- >- $('.holds_table .select_hold').each(function() { >- if(localStorage.selectedHolds.includes($(this).data('id'))) { >- $(this).prop('checked', true); >- } >- }); >- >- $('.holds_table .select_hold_all').each(function() { >- var table = $(this).parents('.holds_table'); >- var count = $('.select_hold:not(:checked)', table).length; >- $('.select_hold_all', table).prop('checked', !count); >- }); >- >- $('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked').length)); >- >- $('.holds_table .select_hold_all').click(function() { >- var table = $(this).parents('.holds_table'); >- var count = $('.select_hold:checked', table).length; >- $('.select_hold', table).prop('checked', !count); >- $(this).prop('checked', !count); >- $('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked').length)); >- $('#cancel_hold_alert').html( MSG_CANCEL_ALERT.format($('.holds_table .select_hold:checked').length)); >- $('#cancel_hold_alert').show(); >- localStorage.selectedHolds = $('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id')); >- }); >- >- $('.holds_table .select_hold').click(function() { >- var table = $(this).parents('.holds_table'); >- var count = $('.select_hold:not(:checked)', table).length; >- $('.select_hold_all', table).prop('checked', !count); >- $('.cancel_selected_holds').html(MSG_CANCEL_SELECTED.format($('.holds_table .select_hold:checked').length)); >- $('#cancel_hold_alert').html( MSG_CANCEL_ALERT.format($('.holds_table .select_hold:checked').length)); >- $('#cancel_hold_alert').show(); >- localStorage.selectedHolds = $('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id')); >- }); >- >- $('.cancel_selected_holds').click(function(e) { >- e.preventDefault(); >- if($('.holds_table .select_hold:checked').length) { >- cancel_link = $(this); >- $("#cancel_modal_form #inputs").empty(); >- biblionumbers.forEach( function(biblionumber){ >- $("#cancel_modal_form #inputs").append('<input type="hidden" name="biblionumber" value="'+biblionumber+'">'); >- }); >- $("#cancel_modal_form #inputs").append('<input type="hidden" name="op" value="cud-cancel_bulk">'); >- let hold_ids= $('.holds_table .select_hold:checked').toArray().map(el => $(el).data('id')).join(','); >- $("#cancel_modal_form #inputs").append('<input type="hidden" name="ids" value="' + hold_ids + '">'); >- delete localStorage.selectedHolds; >- $('#cancelModal').modal('show'); >- } >- return false; >- }); >- > $(".hold-arrow").click(function(e) { > e.preventDefault(); > let arrowForm = $("#hold-actions-form").attr({ >diff --git a/koha-tmpl/intranet-tmpl/prog/js/holds.js b/koha-tmpl/intranet-tmpl/prog/js/holds.js >index 752e0f5b6ab..8e3acf7b1ac 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/holds.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/holds.js >@@ -686,6 +686,25 @@ $(document).ready(function () { > ]; > return toggle_suspend(this, inputs); > }); >+ >+ var MSG_SUSPEND_SELECTED = _("Suspend selected (%s)"); >+ var MSG_SUSPEND_SELECTED_HOLDS = _("Suspend selected holds"); >+ $(".suspend_selected_holds").html( >+ MSG_SUSPEND_SELECTED.format( >+ $(".holds_table .select_hold:checked").length >+ ) >+ ); >+ >+ $(".suspend_selected_holds").click(function (e) { >+ e.preventDefault(); >+ if (!$(".holds_table .select_hold:checked").length) { >+ return false; >+ } >+ $(".modal-title").html(MSG_SUSPEND_SELECTED_HOLDS); >+ $("#suspend-modal").modal("show"); >+ return false; >+ }); >+ > $(".unsuspend-hold").on("click", function (e) { > e.preventDefault(); > let inputs = [ >@@ -697,4 +716,206 @@ $(document).ready(function () { > ]; > return toggle_suspend(this, inputs); > }); >+ >+ var MSG_CANCEL_SELECTED = _("Cancel selected (%s)"); >+ var MSG_CANCEL_ALERT = _( >+ "This action will cancel <span class='badge bg-danger'>%s</span> hold(s)." >+ ); >+ >+ // Confirm cancellation of hold >+ let cancel_link; >+ $(document).on("click", ".cancel-hold", function (e) { >+ e.preventDefault; >+ cancel_link = $(this); >+ $("#cancel_modal_form #inputs").empty(); >+ let reserve_id = cancel_link.data("id"); >+ let biblionumber = cancel_link.data("biblionumber"); >+ if (!patron_page) { >+ $("#cancel_modal_form #inputs").append( >+ '<input type="hidden" name="reserve_id" value="' + >+ reserve_id + >+ '">' >+ ); >+ $("#cancel_modal_form #inputs").append( >+ '<input type="hidden" name="biblionumber" value="' + >+ biblionumber + >+ '">' >+ ); >+ $("#cancel_modal_form #inputs").append( >+ '<input type="hidden" name="op" value="cud-cancel">' >+ ); >+ } else { >+ _append_patron_page_cancel_hold_modal_data({ >+ hold: reserve_id, >+ biblionumber: biblionumber, >+ borrowernumber: cancel_link.data("borrowernumber"), >+ }); >+ } >+ $("#cancelModal").modal("show"); >+ return false; >+ }); >+ >+ if ( >+ !localStorage.selectedHolds || >+ document.referrer.replace(/\?.*/, "") !== >+ document.location.origin + document.location.pathname >+ ) { >+ localStorage.selectedHolds = []; >+ } >+ >+ $(".holds_table .select_hold").each(function () { >+ if (localStorage.selectedHolds.includes($(this).data("id"))) { >+ $(this).prop("checked", true); >+ } >+ }); >+ >+ if (!patron_page) { >+ $(".holds_table .select_hold_all").each(function () { >+ var table = $(this).parents(".holds_table"); >+ var count = $(".select_hold:not(:checked)", table).length; >+ $(".select_hold_all", table).prop("checked", !count); >+ }); >+ } >+ >+ function updateSelectedHoldsButtonCounters() { >+ $(".cancel_selected_holds").html( >+ MSG_CANCEL_SELECTED.format( >+ $(".holds_table .select_hold:checked").length >+ ) >+ ); >+ $(".suspend_selected_holds").html( >+ MSG_SUSPEND_SELECTED.format( >+ $(".holds_table .select_hold:checked").length >+ ) >+ ); >+ } >+ >+ updateSelectedHoldsButtonCounters(); >+ >+ $(".holds_table .select_hold_all").click(function () { >+ var table; >+ if (!patron_page) { >+ table = $(this).parents(".holds_table"); >+ } else { >+ table = $(".holds_table:not(.fixedHeader-floating)"); >+ } >+ var count = $(".select_hold:checked", table).length; >+ $(".select_hold", table).prop("checked", !count); >+ $(this).prop("checked", !count); >+ updateSelectedHoldsButtonCounters(); >+ $("#cancel_hold_alert").html( >+ MSG_CANCEL_ALERT.format( >+ $(".holds_table .select_hold:checked").length >+ ) >+ ); >+ $("#cancel_hold_alert").show(); >+ localStorage.selectedHolds = >+ "[" + >+ $(".holds_table .select_hold:checked") >+ .toArray() >+ .map(el => >+ JSON.stringify({ >+ hold: $(el).data("id"), >+ borrowernumber: $(el).data("borrowernumber"), >+ biblionumber: $(el).data("biblionumber"), >+ }) >+ ) >+ .join(",") + >+ "]"; >+ }); >+ >+ $(".holds_table").on("click", ".select_hold", function () { >+ var table = $(this).parents(".holds_table"); >+ var count = $(".select_hold:not(:checked)", table).length; >+ $(".select_hold_all", table).prop("checked", !count); >+ updateSelectedHoldsButtonCounters(); >+ $("#cancel_hold_alert").html( >+ MSG_CANCEL_ALERT.format( >+ $(".holds_table .select_hold:checked").length >+ ) >+ ); >+ $("#cancel_hold_alert").show(); >+ localStorage.selectedHolds = >+ "[" + >+ $(".holds_table .select_hold:checked") >+ .toArray() >+ .map(el => >+ JSON.stringify({ >+ hold: $(el).data("id"), >+ borrowernumber: $(el).data("borrowernumber"), >+ biblionumber: $(el).data("biblionumber"), >+ }) >+ ) >+ .join(",") + >+ "]"; >+ }); >+ >+ $(".cancel_selected_holds").click(function (e) { >+ e.preventDefault(); >+ if ($(".holds_table .select_hold:checked").length) { >+ $("#cancel_modal_form #inputs").empty(); >+ if (!patron_page) { >+ biblionumbers.forEach(function (biblionumber) { >+ $("#cancel_modal_form #inputs").append( >+ '<input type="hidden" name="biblionumber" value="' + >+ biblionumber + >+ '">' >+ ); >+ }); >+ $("#cancel_modal_form #inputs").append( >+ '<input type="hidden" name="op" value="cud-cancel_bulk">' >+ ); >+ let hold_ids = $(".holds_table .select_hold:checked") >+ .toArray() >+ .map(el => $(el).data("id")) >+ .join(","); >+ $("#cancel_modal_form #inputs").append( >+ '<input type="hidden" name="ids" value="' + hold_ids + '">' >+ ); >+ } else { >+ $("#cancel_modal_form #inputs").append( >+ '<input type="hidden" name="op" value="cud-cancelall">' >+ ); >+ let hold_data = >+ "[" + >+ $(".holds_table .select_hold:checked") >+ .toArray() >+ .map(el => >+ JSON.stringify({ >+ hold: $(el).data("id"), >+ borrowernumber: $(el).data("borrowernumber"), >+ biblionumber: $(el).data("biblionumber"), >+ }) >+ ) >+ .join(",") + >+ "]"; >+ JSON.parse(hold_data).forEach(function (hold) { >+ _append_patron_page_cancel_hold_modal_data(hold); >+ }); >+ } >+ >+ delete localStorage.selectedHolds; >+ $("#cancelModal").modal("show"); >+ } >+ return false; >+ }); >+ >+ function _append_patron_page_cancel_hold_modal_data(hold) { >+ $("#cancel_modal_form #inputs").append( >+ '<input type="hidden" name="rank-request" value="del">' >+ ); >+ $("#cancel_modal_form #inputs").append( >+ '<input type="hidden" name="biblionumber" value="' + >+ hold.biblionumber + >+ '">' >+ ); >+ $("#cancel_modal_form #inputs").append( >+ '<input type="hidden" name="borrowernumber" value="' + >+ hold.borrowernumber + >+ '">' >+ ); >+ $("#cancel_modal_form #inputs").append( >+ '<input type="hidden" name="reserve_id" value="' + hold.hold + '">' >+ ); >+ } > }); >-- >2.39.5
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 40395
:
184109
|
184110
|
184111
|
184112
|
184113
|
184114
|
184115
|
184116
|
184134
|
184135
|
184136
|
184137
|
184138
|
184139
|
184140
|
184141
|
184398
|
184399
|
184400
|
184401
|
184402
|
184403
|
184404
|
184405
|
184434
|
184435
|
184437
|
184470
|
184471
|
184472
|
184473
|
184474
|
184475
|
184476
|
184477
|
184478
|
184479