Bugzilla – Attachment 178166 Details for
Bug 36135
Add tool to batch modify holds
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 36135: Save state of selected checkboxes and fix modifying suspend
0014-Bug-36135-Save-state-of-selected-checkboxes-and-fix-.patch (text/plain), 19.40 KB, created by
Emmi Takkinen
on 2025-02-18 06:36:32 UTC
(
hide
)
Description:
Bug 36135: Save state of selected checkboxes and fix modifying suspend
Filename:
MIME Type:
Creator:
Emmi Takkinen
Created:
2025-02-18 06:36:32 UTC
Size:
19.40 KB
patch
obsolete
>From 5ba60088817b071e1fb392b260d6123acd9d3e8b Mon Sep 17 00:00:00 2001 >From: Emmi Takkinen <emmi.takkinen@koha-suomi.fi> >Date: Fri, 14 Feb 2025 13:15:37 +0200 >Subject: [PATCH 14/14] Bug 36135: Save state of selected checkboxes and fix > modifying suspend > >--- > .../en/modules/tools/batch_modify_holds.tt | 317 +++++++++++------- > 1 file changed, 190 insertions(+), 127 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_modify_holds.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_modify_holds.tt >index c92914f9cb..ce5900c01f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_modify_holds.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/batch_modify_holds.tt >@@ -118,7 +118,11 @@ > <div id="searchheader" class="searchheader"> > <a id="select_all" href="#" class="btn btn-link"><i class="fa fa-check"></i> Select all visible rows</a> > | <a id="clear_all" href="#" class="btn btn-link"><i class="fa fa-times"></i> Clear selections</a> >- </div> >+ <div id="table_search_selections" class="btn-group" style="display:none;"> >+ <span></span> >+ <a href="#" id="clear-row-selection"><i class="fa fa-times"></i> Clear</a> >+ </div> >+ </div> <!-- /#searchheader --> > <h3>Holds found for: <span class="searchpattern"></span></h3> > <table id="holds_to_modify"></table> > </div> <!-- /#modify_holds_results --> >@@ -188,21 +192,53 @@ > let hold_ids = [% IF updated_holds %] [% updated_holds | $raw %] [% ELSE %] [] [% END %]; > > $(document).ready(function() { >+ //Empty local storage from previous selections >+ localStorage.removeItem("holds_modify_selections"); >+ >+ $("#holds_to_modify").on("change", "input[type='checkbox']", function(){ >+ var holds_modify_selections = JSON.parse(localStorage.getItem("holds_modify_selections")) || []; >+ var hold_id = $(this).val(); >+ if ($(this).prop("checked")) { >+ holds_modify_selections.push($(this).val()); >+ localStorage.setItem("holds_modify_selections", JSON.stringify(holds_modify_selections)); >+ showHoldSelections(holds_modify_selections.length); >+ } else { >+ var filtered = holds_modify_selections.filter(function( value ){ >+ return value !== hold_id; >+ }); >+ if( filtered.length > 0 ){ >+ localStorage.setItem("holds_modify_selections", JSON.stringify( filtered )); >+ holds_modify_selections = filtered; >+ showHoldSelections( filtered.length ); >+ } else { >+ holds_modify_selections = []; >+ localStorage.removeItem("holds_modify_selections"); >+ showHoldSelections( 0 ); >+ } >+ } >+ }); > >- $("#select_all").click(function(e){ >+ $("#select_all").on("click", function(e){ > e.preventDefault(); > $("#holds_to_modify input[type='checkbox']").each(function(){ >- $(this).prop("checked", true); >+ $(this).prop("checked", true).change(); > }); > }); > >- $("#clear_all").click(function(e){ >+ $("#clear_all").on("click", function(e){ > e.preventDefault(); > $("#holds_to_modify input[type='checkbox']").each(function(){ >- $(this).prop("checked", false); >+ $(this).prop("checked", false).change(); > }); > }); > >+ $("#clear-row-selection").on("click", function (e) { >+ e.preventDefault(); >+ $("input[type='checkbox']").prop("checked", false).change(); >+ localStorage.removeItem("holds_modify_selections"); >+ $("#table_search_selections").hide(); >+ }); >+ > $('#modify_holds_form').submit(function() { > var modify_holds_form = $(this); > search_holds(modify_holds_form); >@@ -217,6 +253,30 @@ > $('#edit_search').hide(); > }); > >+ function prepSelections(){ >+ let holds_modify_selections = JSON.parse( localStorage.getItem("holds_modify_selections") ) || []; >+ if( holds_modify_selections.length > 0 ){ >+ showHoldSelections( holds_modify_selections.length ); >+ $("#holds_to_modify input[type='checkbox']").each(function(){ >+ var hold_id = $(this).val(); >+ if( holds_modify_selections.indexOf( hold_id ) >= 0 ){ >+ $(this).prop("checked", true ); >+ } >+ }); >+ } >+ } >+ >+ function showHoldSelections( number ){ >+ if (number === 0) { >+ $("#table_search_selections").hide(); >+ } else { >+ $("#table_search_selections") >+ .show() >+ .find("span") >+ .text(__("Holds selected: %s").format(number)); >+ } >+ } >+ > function search_holds(modify_holds_form){ > var table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds', 'holds_to_modify', 'json' ) | $raw %]; > var searchpattern = ""; >@@ -308,7 +368,7 @@ > "name": "checkbox", > "orderable": false, > "render": function(data, type, row, meta) { >- return '<input type="checkbox" name="hold_id" value="'+ encodeURIComponent(data) +'"/>' >+ return '<input class="selection" type="checkbox" name="hold_id" value="'+ encodeURIComponent(data) +'"/>' > } > }, > { >@@ -372,7 +432,7 @@ > } else if( data == "W" ) { > status = _("Waiting"); > } >- return status; >+ return "<span data-found-status='" + escape_str( data ) + "'>" + status + "</span>"; > } > }, > { >@@ -411,7 +471,10 @@ > return escape_str( data ); > } > } >- ] >+ ], >+ "drawCallback": function( settings ) { >+ prepSelections(); >+ }, > }, table_settings, 0, filters); > > $(".searchpattern").text(searchpattern); >@@ -439,7 +502,7 @@ > if( new_pickup_loc || new_suspend_status ){ > var found = false; > holds_checked.each(function(){ >- if($(this).parents("tr").children(".found_status").html() !== "No status"){ >+ if($(this).parents("tr").children(".found_status").children("span").data("found-status")){ > e.preventDefault(); > found = true; > } >@@ -468,131 +531,131 @@ > > //Modified holds table > var table_settings = [% TablesSettings.GetTableSettings( 'circ', 'holds', 'modified_holds', 'json' ) | $raw %]; >- var filters = { >- "me.hold_id": function(){ >- return {"-in": hold_ids}; >- } >+ var filters = { >+ "me.hold_id": function(){ >+ return {"-in": hold_ids}; > } >+ } > >- var holds_modified_table = $("#modified_holds").kohaTable({ >- "ajax": { >- "url": "/api/v1/holds" >+ var holds_modified_table = $("#modified_holds").kohaTable({ >+ "ajax": { >+ "url": "/api/v1/holds" >+ }, >+ "embed": [ >+ "biblio", >+ "item", >+ "pickup_library", >+ "patron" >+ ], >+ "destroy": true, >+ "autoWidth": false, >+ "processing": true, >+ "columns": [ >+ { >+ "data": "expiration_date", >+ "name": "expiration_date", >+ "type": "date", >+ "title": _("Expiration date"), >+ "orderable": true, >+ "render": function( data, type, row, meta ) { >+ return $date(data); >+ } > }, >- "embed": [ >- "biblio", >- "item", >- "pickup_library", >- "patron" >- ], >- "destroy": true, >- "autoWidth": false, >- "processing": true, >- "columns": [ >- { >- "data": "expiration_date", >- "name": "expiration_date", >- "type": "date", >- "title": _("Expiration date"), >- "orderable": true, >- "render": function( data, type, row, meta ) { >- return $date(data); >- } >- }, >- { >- "data": "biblio.title", >- "name": "title", >- "title": _("Title"), >- "orderable": true, >- "render": function( data, type, row, meta ) { >- return '<a href="/cgi-bin/koha/catalogue/detail.pl?' + >- 'biblionumber=' + encodeURIComponent( row.biblio_id ) + '">' + escape_str( data ) + '</a>'; >- } >- }, >- { >- "data": "item.external_id", >- "name": "barcode", >- "title": _("Barcode"), >- "defaultContent": _(""), >- "orderable": true, >- "render": function( data, type, row, meta ) { >- if( row.item ){ >- let item_id = encodeURIComponent( row.item_id ); >- let biblio_id = encodeURIComponent( row.biblio_id ); >- return '<a href="/cgi-bin/koha/catalogue/moredetail.pl?' + >- 'itemnumber='+ item_id +'&biblionumber='+ biblio_id +'&' + >- 'bi='+ biblio_id +'#item'+ item_id +'">' + escape_str( data ) + '</a>' >- } >- } >- }, >- { >- "data": "patron_id", >- "name": "patron", >- "title": _("Patron"), >- "orderable": true, >- "render": function( data, type, row, meta ) { >- let patron_to_html = $patron_to_html(row.patron, { url: true, display_cardnumber: true, hide_patron_name }); >- return patron_to_html; >- } >- }, >- { >- "data": "status", >- "name": "status", >- "className": "found_status", >- "title": _("Status"), >- "orderable": true, >- "render": function( data, type, row, meta ) { >- let status = _("No status"); >- if ( data == "T" ) { >- status = _("In transit"); >- } else if( data == "P" ) { >- status = _("In processing"); >- } else if( data == "W" ) { >- status = _("Waiting"); >- } >- return status; >- } >- }, >- { >- "data": "pickup_library_id", >- "name": "pickup_library", >- "title": _("Hold pickup library"), >- "orderable": true, >- "render": function( data, type, row, meta ) { >- return escape_str( row.pickup_library.name ); >- } >- }, >- { >- "data": "suspended", >- "name": "suspended", >- "title": _("Suspended"), >- "orderable": true, >- "render": function( data, type, row, meta ) { >- return data == 0 ? _("No") : _("Yes"); >- } >- }, >- { >- "data": "suspended_until", >- "name": "suspended_until", >- "title": _("Suspended until"), >- "orderable": true, >- "render": function( data, type, row, meta ) { >- return $date( data ); >+ { >+ "data": "biblio.title", >+ "name": "title", >+ "title": _("Title"), >+ "orderable": true, >+ "render": function( data, type, row, meta ) { >+ return '<a href="/cgi-bin/koha/catalogue/detail.pl?' + >+ 'biblionumber=' + encodeURIComponent( row.biblio_id ) + '">' + escape_str( data ) + '</a>'; >+ } >+ }, >+ { >+ "data": "item.external_id", >+ "name": "barcode", >+ "title": _("Barcode"), >+ "defaultContent": _(""), >+ "orderable": true, >+ "render": function( data, type, row, meta ) { >+ if( row.item ){ >+ let item_id = encodeURIComponent( row.item_id ); >+ let biblio_id = encodeURIComponent( row.biblio_id ); >+ return '<a href="/cgi-bin/koha/catalogue/moredetail.pl?' + >+ 'itemnumber='+ item_id +'&biblionumber='+ biblio_id +'&' + >+ 'bi='+ biblio_id +'#item'+ item_id +'">' + escape_str( data ) + '</a>' > } >- }, >- { >- "data": "notes", >- "name": "notes", >- "title": _("Notes"), >- "orderable": true, >- "render": function( data, type, row, meta ) { >- return escape_str( data ); >+ } >+ }, >+ { >+ "data": "patron_id", >+ "name": "patron", >+ "title": _("Patron"), >+ "orderable": true, >+ "render": function( data, type, row, meta ) { >+ let patron_to_html = $patron_to_html(row.patron, { url: true, display_cardnumber: true, hide_patron_name }); >+ return patron_to_html; >+ } >+ }, >+ { >+ "data": "status", >+ "name": "status", >+ "className": "found_status", >+ "title": _("Status"), >+ "orderable": true, >+ "render": function( data, type, row, meta ) { >+ let status = _("No status"); >+ if ( data == "T" ) { >+ status = _("In transit"); >+ } else if( data == "P" ) { >+ status = _("In processing"); >+ } else if( data == "W" ) { >+ status = _("Waiting"); > } >+ return status; > } >- ] >- }, table_settings, 0, filters); >+ }, >+ { >+ "data": "pickup_library_id", >+ "name": "pickup_library", >+ "title": _("Hold pickup library"), >+ "orderable": true, >+ "render": function( data, type, row, meta ) { >+ return escape_str( row.pickup_library.name ); >+ } >+ }, >+ { >+ "data": "suspended", >+ "name": "suspended", >+ "title": _("Suspended"), >+ "orderable": true, >+ "render": function( data, type, row, meta ) { >+ return data == 0 ? _("No") : _("Yes"); >+ } >+ }, >+ { >+ "data": "suspended_until", >+ "name": "suspended_until", >+ "title": _("Suspended until"), >+ "orderable": true, >+ "render": function( data, type, row, meta ) { >+ return $date( data ); >+ } >+ }, >+ { >+ "data": "notes", >+ "name": "notes", >+ "title": _("Notes"), >+ "orderable": true, >+ "render": function( data, type, row, meta ) { >+ return escape_str( data ); >+ } >+ } >+ ] >+ }, table_settings, 0, filters); > >- var modified_message = '<div class="alert alert-info">'+hold_ids.length+' hold(s) have been modified!</div>'; >- $("#modified_holds_results-wrapper").prepend(modified_message); >+ var modified_message = '<div class="alert alert-info">'+hold_ids.length+' hold(s) have been modified!</div>'; >+ $("#modified_holds_results-wrapper").prepend(modified_message); > > }); > </script> >-- >2.34.1 >
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 36135
:
163021
|
163022
|
163023
|
163024
|
163529
|
163530
|
163540
|
163541
|
163542
|
163543
|
163544
|
163796
|
164037
|
164051
|
164057
|
164058
|
164059
|
164060
|
164061
|
164062
|
164063
|
177518
|
177519
|
177959
|
177960
|
177961
|
177962
|
177963
|
177964
|
177965
|
177966
|
177967
|
177968
|
177969
|
177975
|
177976
|
177981
|
177982
|
178154
|
178155
|
178156
|
178157
|
178158
|
178159
|
178160
|
178161
|
178162
|
178163
|
178164
|
178165
|
178166
|
178167