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 <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
(cherry picked from commit de91b2e5d9)
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
(cherry picked from commit de13938d0a)
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Julian Maurice 2024-01-30 15:13:47 +01:00 committed by Lucas Gass
parent 77b5822ed3
commit 71acdea01a
1 changed files with 8 additions and 10 deletions

View File

@ -303,10 +303,10 @@
<td class="report_type">
[% savedreport.type | html %]
</td>
<td class="report_group">
<td data-search="[% savedreport.report_group | html %]" class="report_group">
[% savedreport.groupname | html %]
</td>
<td>
<td data-search="[% savedreport.report_subgroup | html %]">
[% savedreport.subgroupname | html %]
</td>
<td class="report_notes">
@ -1923,9 +1923,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);
@ -2236,15 +2236,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(