From 4310e587b810c08e78770e5cac0885d7a25df54e Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 17 Oct 2024 15:55:05 +0200 Subject: [PATCH] Bug 33484: External filter into state - catalogue concerns Use a checkbox to store the state. It does not make the code better but make possible to keep and restore and state of the filter. Not sure it's working correct on the cataloguing/concerns.pl page but the behaviour was already not good before. At least I think it fixes the filter/include icon in some situation. On main I managed to get the "include resolved" link with the "filter" icon and the resolved concerns were already displayed... Signed-off-by: Pedro Amorim Signed-off-by: Jonathan Druart Signed-off-by: Martin Renvoize Signed-off-by: Katrin Fischer --- .../prog/en/modules/catalogue/detail.tt | 13 +++++--- .../prog/en/modules/cataloguing/concerns.tt | 32 +++++++++++-------- 2 files changed, 27 insertions(+), 18 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt index 7a00e941dc..13fb0b04e6 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt @@ -781,6 +781,7 @@
Hide resolved | Show all +
@@ -1228,10 +1229,9 @@ $("#bibliodetails a:first").tab("show"); var table_settings = [% TablesSettings.GetTableSettings( 'catalogue', 'concerns', 'table_concerns', 'json' ) | $raw %]; - var filtered = false; let additional_filters = { resolved_date: function(){ - if ( filtered ) { + if ( $("#hide_resolved_concerns").is(":checked") ) { return { "=": null }; } else { return; @@ -1240,6 +1240,9 @@ source: 'catalog', biblio_id: [% biblionumber | uri %] }; + let external_filter_nodes = { + hide_resolved_concerns: "#hide_resolved_concerns", + }; var tickets_url = '/api/v1/tickets'; var tickets = $("#table_concerns").kohaTable({ @@ -1350,15 +1353,15 @@ "orderable": false }, ] - }, table_settings, 0, additional_filters); + }, table_settings, 0, additional_filters, undefined, external_filter_nodes); $('#hideResolved').on("click", function() { - filtered = true; + $("#hide_resolved_concerns").prop("checked", true); tickets.DataTable().draw(); }); $('#showAll').on("click", function() { - filtered = false; + $("#hide_resolved_concerns").prop("checked", false); tickets.DataTable().draw(); }); }); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt index b1878fb0b9..a7452655fe 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt @@ -38,9 +38,11 @@
- Include resolved + Include resolved + [% FOR st IN status %] | Filter [% st.lib | html %] + [% END %]
@@ -81,10 +83,9 @@ var table_settings = [% TablesSettings.GetTableSettings('cataloguing', 'concerns', 'table_concerns', 'json') | $raw %]; - var filter_resolved = true; let additional_filters = { resolved_date: function(){ - if ( filter_resolved ) { + if ( $("#hide_resolved_concerns").is(":checked") ) { return { "=": null }; } else { return; @@ -92,6 +93,9 @@ }, source: 'catalog' }; + let external_filter_nodes = { + hide_resolved_concerns: "#hide_resolved_concerns", + }; var tickets_url = '/api/v1/tickets'; var tickets = $("#table_concerns").kohaTable({ @@ -204,25 +208,27 @@ $(row).addClass(data.status.toLowerCase()); } }, - }, table_settings, 1, additional_filters); + }, table_settings, 1, additional_filters, undefined, external_filter_nodes); var txtActivefilter = _("Include resolved"); var txtInactivefilter = _("Filter resolved"); - $('#resolved_filter').on("click", function() { - if ($(this).hasClass('filtered')){ - filter_resolved = false; - $(this).html(' '+txtActivefilter); + function adjust_filter_label(){ + if ($("#hide_resolved_concerns").is(":checked")){ + $("#resolved_filter").html(' '+txtActivefilter); } else { - filter_resolved = true; - $(this).html(' '+txtInactivefilter); + $("#resolved_filter").html(' '+txtInactivefilter); } + } + $('#resolved_filter').on("click", function() { + $("#hide_resolved_concerns").prop("checked", !$("#hide_resolved_concerns").is(":checked")); + adjust_filter_label() tickets.DataTable().draw(); - $(this).toggleClass('filtered'); }); + adjust_filter_label(); [% FOR st IN status %] $('#[% st.authorised_value | html %]_filter').on("click", function() { - if ($(this).hasClass('filtered')){ + if ($("#hide_[% st.authorised_value | html %]").is(":checked")){ additional_filters.status.find((o, i) => { if (o["!="] === '[% st.authorised_value | html %]') { additional_filters.status.splice(i, 1); @@ -240,8 +246,8 @@ additional_filters.status.push({ '!=': "[% st.authorised_value | html %]" }); $(this).html(' '+_("Include ")+"[% st.lib | html %]"); } + $("#hide_[% st.authorised_value | html %]").prop("checked", !$("#hide_[% st.authorised_value | html %]").is(":checked")); tickets.DataTable().draw(); - $(this).toggleClass('filtered'); }); [% END %] }); -- 2.39.5