Bugzilla – Attachment 164337 Details for
Bug 33568
Use the REST API to display items on the staff biblio detail view
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33568: Preserve item selection across pagination and filtering
Bug-33568-Preserve-item-selection-across-paginatio.patch (text/plain), 6.30 KB, created by
Jonathan Druart
on 2024-04-03 07:39:30 UTC
(
hide
)
Description:
Bug 33568: Preserve item selection across pagination and filtering
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-04-03 07:39:30 UTC
Size:
6.30 KB
patch
obsolete
>From e585aa70454dc1c9bf5392b727cd81d9c97efedf Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 17 May 2023 15:51:49 +0200 >Subject: [PATCH] Bug 33568: Preserve item selection across pagination and > filtering >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >BTW Do we really need StaffDetailItemSelection? > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> > >Signed-off-by: Laurence Rault <laurence.rault@biblibre.com> >Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov> >Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io> >--- > .../prog/en/modules/catalogue/detail.tt | 60 ++++++++++++------- > 1 file changed, 38 insertions(+), 22 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >index bc7c74d6b68..6c5350f7a48 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -1332,11 +1332,10 @@ > } > > [% IF StaffDetailItemSelection %] >- function itemSelectionBuildDeleteLink(div) { >- var itemnumbers = new Array(); >- $("input[name='itemnumber'][type='checkbox']:checked", div).each(function() { >- itemnumbers.push($(this).val()); >- }); >+ >+ let items_selection = {}; >+ function itemSelectionBuildDeleteLink(tab_id) { >+ var itemnumbers = items_selection[tab_id]; > if (itemnumbers.length > 0) { > var url = '/cgi-bin/koha/tools/batchMod.pl?op=show&del=1'; > url += '&itemnumber=' + itemnumbers.join('&itemnumber='); >@@ -1349,11 +1348,8 @@ > return true > } > >- function itemSelectionBuildModifyLink(div) { >- var itemnumbers = new Array(); >- $("input[name='itemnumber'][type='checkbox']:checked", div).each(function() { >- itemnumbers.push($(this).val()); >- }); >+ function itemSelectionBuildModifyLink(tab_id) { >+ var itemnumbers = items_selection[tab_id]; > if (itemnumbers.length > 0) { > var url = '/cgi-bin/koha/tools/batchMod.pl?op=show'; > url += '&itemnumber=' + itemnumbers.join('&itemnumber='); >@@ -1366,10 +1362,10 @@ > return true; > } > >- function itemSelectionBuildActionLinks(tab) { >- var div = $("#" + tab); >- var delete_link_ok = itemSelectionBuildDeleteLink(div); >- var modify_link_ok = itemSelectionBuildModifyLink(div); >+ function itemSelectionBuildActionLinks(tab_id) { >+ var delete_link_ok = itemSelectionBuildDeleteLink(tab_id); >+ var modify_link_ok = itemSelectionBuildModifyLink(tab_id); >+ var div = $("#" + tab_id); > if (modify_link_ok || delete_link_ok) { > $('.itemselection_actions', div).show(); > } else { >@@ -1378,10 +1374,6 @@ > } > > $(document).ready(function() { >- $('table.items_table').each(function() { >- var div = $(this).parent().attr("id"); >- itemSelectionBuildActionLinks(div); >- }); > > $(".SelectAll").on("click",function(e){ > e.preventDefault(); >@@ -2220,6 +2212,9 @@ > [% IF hidden_count %] > default_filters.lost_status = "0"; > [% END %] >+ if ( !items_selection.hasOwnProperty(tab_id) ){ >+ items_selection[tab_id] = []; >+ } > var items_table = $("#" + tab_id + '_table').kohaTable({ > ajax: { url: item_table_url }, > order: [[ 0, "asc" ]], >@@ -2234,7 +2229,11 @@ > orderable: false, > render: function (data, type, row, meta) { > if ( can_edit_items_from[row.holding_library_id] ){ >- return '<input type="checkbox" value="%s" name="itemnumber" />'.format(row.item_id); >+ if ( items_selection[tab_id].includes(row.item_id) ) { >+ return '<input type="checkbox" value="%s" name="itemnumber" checked />'.format(row.item_id); >+ } else { >+ return '<input type="checkbox" value="%s" name="itemnumber" />'.format(row.item_id); >+ } > } else { > return '' > } >@@ -2686,11 +2685,28 @@ > }); > itemSelectionBuildActionLinks(tab_id); > }, >+ [% IF StaffDetailItemSelection %] > drawCallback: function(settings){ >- $(this).find("td:first input[name='itemnumber'][type='checkbox']").on("change", function(){ >- itemSelectionBuildActionLinks(tab_id); >- }); >+ var api = new $.fn.dataTable.Api(settings) >+ $.each( >+ $(this).find("tbody tr td:first-child"), >+ function (index, e) { >+ let tr = $(this).parent() >+ let row = api.row(tr).data() >+ if (!row) return // Happen if the table is empty >+ $(this).find("input[name='itemnumber'][type='checkbox']").on("change", function(){ >+ let itemnumber = parseInt($(this).val()); >+ if( $(this).prop("checked") ){ >+ items_selection[tab_id].push(itemnumber); >+ } else { >+ items_selection[tab_id] = items_selection[tab_id].filter( id => id != itemnumber ); >+ } >+ itemSelectionBuildActionLinks(tab_id); >+ }); >+ } >+ ); > }, >+ [% END %] > ...dt_options, > }, > items_table_settings[tab_id], >-- >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 33568
:
151339
|
153791
|
164308
|
164309
|
164310
|
164311
|
164312
|
164313
|
164314
|
164315
|
164316
|
164317
|
164318
|
164319
|
164320
|
164321
|
164322
|
164323
|
164324
|
164325
|
164326
|
164327
|
164328
|
164329
|
164330
|
164331
|
164332
|
164333
|
164334
|
164335
|
164336
|
164337
|
164338
|
164339
|
164340
|
164341
|
164342
|
164343
|
164344
|
164345
|
164346
|
164347
|
164348
|
164349
|
164350
|
164351
|
164352
|
164353
|
164354
|
164355
|
164356
|
164358
|
164359
|
164360
|
164361
|
164362
|
164363
|
164364
|
164365
|
164366
|
164367
|
164368
|
164369
|
164370
|
164371
|
164372
|
164373
|
164374
|
164472
|
164480
|
164482
|
164483
|
164485
|
164528