From de13938d0af05445d32a8989d2eb7efe939b4658 Mon Sep 17 00:00:00 2001 From: Julian Maurice Date: Tue, 30 Jan 2024 15:13:47 +0100 Subject: [PATCH] Bug 35943: Fix group/subgroup filtering of saved reports Use code instead of name for filtering and escape regexp special characters. This patch also disables datatables' smart filtering as it is not recommended to use with regexp filtering https://datatables.net/reference/api/search() Test plan: 1. Create a report in a group named "Foo + Bar" and in a subgroup named "Baz + Quux" 2. Create other reports in group "Foo + Bar" but in other subgroups, as well as in other groups. This is useful to see the effect of filtering 3. Go to the saved reports page and verify that navigating between tabs have the desired result. Same for the subgroup select Signed-off-by: David Nind Signed-off-by: Kyle M Hall Signed-off-by: Katrin Fischer (cherry picked from commit de91b2e5d9dbff8c43a5090828397583bd397dc1) Signed-off-by: Fridolin Somers --- .../en/modules/reports/guided_reports_start.tt | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt index 1b639d26c6..8fd7b8bd33 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/guided_reports_start.tt @@ -320,10 +320,10 @@ [% savedreport.type | html %] - + [% savedreport.groupname | html %] - + [% savedreport.subgroupname | html %] @@ -1968,9 +1968,9 @@ $("#subgroup_filter").change(function() { var selected = $(this).find('option:selected'); var sg_id = $(selected).val(); - var sg_name = $(selected).text(); if (sg_id.length > 0) { - rtable.fnFilter('^' + sg_name + '$', 5, true, true, true, false); + const input = '^' + $.fn.dataTable.util.escapeRegex(sg_id) + '$'; + rtable.fnFilter(input, 5, true, false, true, false); rtable.fnSetColumnVis(5, false); } else { rtable.fnFilter('', 5); @@ -2281,15 +2281,13 @@ rtable.fnSetColumnVis(5, true); var g_id = tab.find("a").data("tabname"); - var g_name = tab.find("a").text().trim(); - - if ( g_name == _("All") ) { - g_id = ""; - g_name = ""; + if (g_id === 'reports') { + g_id = ''; } if (g_id && g_id.length > 0) { - rtable.fnFilter('^' + g_name + '$', 4, true, true, true, false); + const input = '^' + $.fn.dataTable.util.escapeRegex(g_id) + '$'; + rtable.fnFilter(input, 4, true, false, true, false); rtable.fnSetColumnVis(4, false); for(var i in group_subgroups[g_id]) { $("#subgroup_filter").append( -- 2.39.5