From c53364b5fafaf1577b110230643d4fb8bfb1db61 Mon Sep 17 00:00:00 2001 From: Lucas Gass Date: Thu, 1 Sep 2022 16:55:14 +0000 Subject: [PATCH] Bug 31455: Make batchMod sort by order scanned MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit To test: 1. In batch item deletion and batch item modification add some barcodes. 2. Notice they are being sorted by item number, not in the order scanned. 3. Appply patch and restart services. 4. Try scanning items again in both batch item deletion and batch item modification. 5. The found barcodes should now sort by order scanned. Signed-off-by: Owen Leonard Signed-off-by: Joonas Kylmälä --- Koha/UI/Table/Builder/Items.pm | 5 ++++- koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc | 3 ++- koha-tmpl/intranet-tmpl/prog/js/pages/batchMod.js | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/Koha/UI/Table/Builder/Items.pm b/Koha/UI/Table/Builder/Items.pm index b573f2a3b3..34b3cfcffd 100644 --- a/Koha/UI/Table/Builder/Items.pm +++ b/Koha/UI/Table/Builder/Items.pm @@ -19,6 +19,7 @@ use Modern::Perl; use List::MoreUtils qw( uniq ); use C4::Biblio qw( GetMarcStructure GetMarcFromKohaField IsMarcStructureInternal ); use Koha::Items; +use List::MoreUtils qw(first_index); =head1 NAME @@ -71,14 +72,16 @@ Use it with: sub build_table { my ( $self, $params ) = @_; - + my @itemnumbers = @{ $self->{itemnumbers} }; my $items = Koha::Items->search( { itemnumber => $self->{itemnumbers} } ); my @items; while ( my $item = $items->next ) { my $item_info = $item->columns_to_str; + my $index = first_index { $_ eq $item->itemnumber } @itemnumbers; $item_info = { %$item_info, + index => $index, biblio => $item->biblio, safe_to_delete => $item->safe_to_delete, holds => $item->biblio->holds->count, diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc index 6ec8a50c8f..237500bf7a 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc @@ -243,6 +243,7 @@ + [% IF checkboxes_edit OR checkboxes_delete %] [% END %] @@ -264,6 +265,7 @@ [% SET can_be_edited = ! ( Koha.Preference('IndependentBranches') && ! logged_in_user.is_superlibrarian && item.homebranch != Branches.GetLoggedInBranchname() ) %] + [% IF checkboxes_edit %] [% UNLESS can_be_edited%] @@ -333,7 +335,6 @@ [% END %] [% END %] - [% END # /FOREACH items %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/pages/batchMod.js b/koha-tmpl/intranet-tmpl/prog/js/pages/batchMod.js index 987bd3537b..4d178d29d5 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/pages/batchMod.js +++ b/koha-tmpl/intranet-tmpl/prog/js/pages/batchMod.js @@ -121,7 +121,8 @@ $(document).ready(function () { $("#itemst").dataTable($.extend(true, {}, dataTablesDefaults, { "sDom": 't', "aoColumnDefs": [ - { "aTargets": [0], "bSortable": false, "bSearchable": false }, + { "aTargets": [0, 1], "bSortable": false, "bSearchable": false }, + { "aTargets": [0], "bVisible": false }, { "sType": "anti-the", "aTargets": ["anti-the"] } ], "bPaginate": false, -- 2.30.2
[% item.index + 1 | html %]Cannot edit[% item.$attribute | html %]