From 0602e62d5919e833434d3e0edfc962e1bcd56af5 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Tue, 6 Apr 2021 17:35:33 +0200 Subject: [PATCH] Bug 28069: (bug 27715 follow-up) Fix sort for lists MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sort functionality has been broken by bug 27715. We need to specify the table.column in the datatable init Note that "count" needs to be handled separately (which is a bit dirty but cannot find something better) Test plan: Create some lists, add contents, change owner and dates Sort using the different attributes and confirm that it's now working Signed-off-by: Séverine QUEUNE Signed-off-by: Kyle M Hall --- C4/Utils/DataTables.pm | 7 ++++++- .../prog/en/modules/virtualshelves/shelves.tt | 18 ++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/C4/Utils/DataTables.pm b/C4/Utils/DataTables.pm index 6e1af15611..ac2faad7cd 100644 --- a/C4/Utils/DataTables.pm +++ b/C4/Utils/DataTables.pm @@ -104,10 +104,15 @@ sub dt_build_orderby { return unless @orderbys; + my @sanitized_orderbys; + + # Trick for virtualshelves, should not be extended + push @sanitized_orderbys, 'count asc' if grep {$_ eq 'count asc'} @orderbys; + push @sanitized_orderbys, 'count desc' if grep {$_ eq 'count desc'} @orderbys; + # Must be "branches.branchname asc", "borrowers.firstname desc", etc. @orderbys = grep { /^\w+\.\w+ (asc|desc)$/ } @orderbys; - my @sanitized_orderbys; for my $orderby (@orderbys) { my ($identifier, $direction) = split / /, $orderby, 2; my ($table, $column) = split /\./, $identifier, 2; diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt index db6f2da101..5a006342c4 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt @@ -523,6 +523,24 @@ },{ 'name': 'template_path', 'value': 'virtualshelves/tables/shelves_results.tt', + },{ + 'name': 'shelfname_sorton', + 'value': 'vs.shelfname', + },{ + 'name': 'is_shared_sorton', + 'value': 'vs.category', + },{ + 'name': 'owner_sorton', + 'value': 'vs.owner', + },{ + 'name': 'sortby_sorton', + 'value': 'vs.sortfield', + },{ + 'name': 'created_on_sorton', + 'value': 'vs.created_on', + },{ + 'name': 'modification_time_sorton', + 'value': 'vs.lastmodified', }); $.ajax({ 'dataType': 'json', -- 2.24.3 (Apple Git-128)