From 0771f3571647bddff999b8df84dcf4d7478fe41c Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 11 Jul 2024 09:50:43 +0200 Subject: [PATCH] Bug 37309: Improve Delete and Modify items links on the biblio detail page The way the "Delete selected items" and "Modify selected items" links are build on the bibliographic detail page is not nice. We could do better, for instance using a proper form element instead of building an URL. Test plan: Go to the detail page of a bibliographic record which has several items. In the items table check some checkboxes and play with "select all", "clear all" and the action buttons. Notice that everything works as before. Minor UI regression that must be fixed: there are CSS rules that cause problem. When the action links are displayed or hidden the table is moving up and down. I think the problematic rules are: .btn { padding: 6px 12px; font-size: 12px; } It makes the UI better if I remove them but still get the bumping issue. Signed-off-by: Owen Leonard --- .../tables/items/catalogue_detail.inc | 54 ++++++++++--------- 1 file changed, 29 insertions(+), 25 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc index f7ca251121..2171da8e3a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers/tables/items/catalogue_detail.inc @@ -57,10 +57,23 @@ | Actions: [% IF CAN_user_tools_items_batchdel %] - Delete selected items +
+ [% INCLUDE 'csrf-token.inc' %] + + + + + +
[% END %] [% IF CAN_user_tools_items_batchmod %] - Modify selected items +
+ [% INCLUDE 'csrf-token.inc' %] + + + + +
[% END %] [% IF CAN_user_editcatalogue_manage_item_groups && biblio.item_groups.count %] Add/move to item group @@ -81,32 +94,23 @@ [% IF StaffDetailItemSelection %] let items_selection = {}; - function itemSelectionBuildDeleteLink(tab_id) { + + function _itemSelectionBuildLink(tab_id, form) { + 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='); - url += '&biblionumber=[% biblionumber | uri %]'; - url += '&src=CATALOGUING'; - $('a.itemselection_action_delete').attr('href', url); - } else { - return false; - } - return true - } + $(form).find("input[name='itemnumber']").remove(); + + $(itemnumbers).each(function() { + $(form).append("".format(this)); + }); + return !!itemnumbers.length + } + function itemSelectionBuildDeleteLink(tab_id) { + return _itemSelectionBuildLink(tab_id, $('#itemselection_action_delete_form')); + } 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='); - url += '&biblionumber=[% biblionumber | uri %]'; - url += '&src=CATALOGUING'; - $('a.itemselection_action_modify').attr('href', url); - } else { - return false; - } - return true; + return _itemSelectionBuildLink(tab_id, $('#itemselection_action_modify_form')); } function itemSelectionBuildActionLinks(tab_id) { -- 2.39.2