From de91b2e5d9dbff8c43a5090828397583bd397dc1 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 --- .../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 09602bec19..d402cdba38 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 @@ -309,10 +309,10 @@ [% savedreport.type | html %] - + [% savedreport.groupname | html %] - + [% savedreport.subgroupname | html %] @@ -1973,9 +1973,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); @@ -2278,15 +2278,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