Bugzilla – Attachment 151339 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), 5.98 KB, created by
Jonathan Druart
on 2023-05-17 13:55:19 UTC
(
hide
)
Description:
Bug 33568: Preserve item selection across pagination and filtering
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2023-05-17 13:55:19 UTC
Size:
5.98 KB
patch
obsolete
>From df4cd95f818d2410dafb3506beabddea6b5ced53 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 > >BTW Do we really need StaffDetailItemSelection? >--- > .../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 cad8dc8a43a..64de34c6df5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -1317,11 +1317,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='); >@@ -1334,11 +1333,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='); >@@ -1351,10 +1347,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 { >@@ -1363,10 +1359,6 @@ > } > > $(document).ready(function() { >- $('table.items_table').each(function() { >- var div = $(this).parent().attr("id"); >- itemSelectionBuildActionLinks(div); >- }); > > $(".SelectAll").on("click",function(e){ > e.preventDefault(); >@@ -2204,6 +2196,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" ]], >@@ -2218,7 +2213,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 '' > } >@@ -2676,11 +2675,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.25.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