From f23b5b78f45cdd10d0927c7a04228ac84889a261 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Thu, 28 Dec 2023 10:04:36 +0000 Subject: [PATCH] Bug 35628: Add status filters to top bar This patch adds status filters to the top toolbar alongside the existing filter on resolved. --- .../prog/en/modules/cataloguing/concerns.tt | 41 ++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) 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 1b649fe5da6..0a9acde6e47 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/concerns.tt @@ -1,6 +1,8 @@ [% USE raw %] [% USE Asset %] +[% USE AuthorisedValues %] [% PROCESS 'i18n.inc' %] +[% SET status = AuthorisedValues.GetAuthValueDropbox('TICKET_STATUS') %] [% SET footerjs = 1 %] [% USE TablesSettings %] [% INCLUDE 'doc-head-open.inc' %] @@ -41,6 +43,9 @@
Include resolved + [% FOR st IN status %] + | Filter [% st.lib | html %] + [% END %]
@@ -88,7 +93,8 @@ } else { return; } - } + }, + source: 'catalog' }; var tickets_url = '/api/v1/tickets'; @@ -193,19 +199,44 @@ }, }, table_settings, 1, additional_filters); - var txtActivefilter = _("Filter resolved"); - var txtInactivefilter = _("Include resolved"); + var txtActivefilter = _("Include resolved"); + var txtInactivefilter = _("Filter resolved"); $('#resolved_filter').on("click", function() { if ($(this).hasClass('filtered')){ filter_resolved = false; - $(this).html(' '+txtActivefilter); + $(this).html(' '+txtActivefilter); } else { filter_resolved = true; - $(this).html(' '+txtInactivefilter); + $(this).html(' '+txtInactivefilter); + } + tickets.DataTable().draw(); + $(this).toggleClass('filtered'); + }); + + [% FOR st IN status %] + $('#[% st.authorised_value | html %]_filter').on("click", function() { + if ($(this).hasClass('filtered')){ + additional_filters.status.find((o, i) => { + if (o["!="] === '[% st.authorised_value | html %]') { + additional_filters.status.splice(i, 1); + return true; // stop searching + } + }); + if ( additional_filters.status.length === 1 ){ + delete additional_filters.status; + } + $(this).html(' '+_("Filter ")+"[% st.lib | html %]"); + } else { + if (!additional_filters.hasOwnProperty("status")) { + additional_filters.status = [ '-and' ]; + } + additional_filters.status.push({ '!=': "[% st.authorised_value | html %]" }); + $(this).html(' '+_("Include ")+"[% st.lib | html %]"); } tickets.DataTable().draw(); $(this).toggleClass('filtered'); }); + [% END %] }); [% Asset.js("js/modals/display_ticket.js") | $raw %] -- 2.43.0