From 56bc8c53d1b61c9427f2a3067f234f66f7299ee9 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=utf8 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 Signed-off-by: Jonathan Druart (cherry picked from commit f35571410b191770337708f4e389b49bde15e04e) Signed-off-by: Fridolin Somers --- 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 4fd5fdc2bf..43b69c4e27 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/virtualshelves/shelves.tt @@ -475,6 +475,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.39.5