From 84f3948c2a12b6c8aaeeb512571cc960d38b5d71 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. Signed-off-by: Esther Melander Signed-off-by: Ray Delahunty Signed-off-by: Marcel de Rooy Signed-off-by: Katrin Fischer --- .../prog/en/modules/cataloguing/concerns.tt | 38 +++++++++++++++++-- 1 file changed, 34 insertions(+), 4 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 49f01ef6db..9a89714f75 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' %] @@ -42,6 +44,9 @@
Include resolved + [% FOR st IN status %] + | Filter [% st.lib | html %] + [% END %]
@@ -195,19 +200,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.39.5