From 3432b3bd5e9b5a5384bc3243e3d4b1629bd76496 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Tue, 23 Feb 2021 17:25:47 +0000 Subject: [PATCH] Bug 27766: Hide expired news items by default This patch modifies the news page in the staff interface so that expired news items are hidden by default. A checkbox in the sidebar can be checked to show the hidden rows. To test you should have multiple news items, some expired and some unexpired. - Apply the patch and go to Tools -> News - The table of news items as it initially appears should not include any expired news items. - In the sidebar, check the "Show expired" checkbox. - The expired news items should now appear. Signed-off-by: Barbara Johnson Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart --- .../prog/en/modules/tools/koha-news.tt | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt index 238ab054c0..d609997a40 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/koha-news.tt @@ -239,6 +239,11 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %] [% PROCESS options_for_libraries libraries => Branches.all( selected => branchcode, unfiltered => 1, ) %] +
  • + +
  • @@ -291,6 +296,20 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %] } } + /* Custom table search configuration: If a table row + has an "expired" class, hide it UNLESS the + show_expired checkbox is checked */ + $.fn.dataTable.ext.search.push( + function( settings, searchData, index, rowData, counter ) { + var row = $(settings.aoData[index].nTr); + if( row.hasClass("expired") && !$("#show_expired").prop("checked") ){ + return false; + } else { + return true; + } + } + ); + $(document).ready(function() { var newst = $("#newst").DataTable($.extend(true, {}, dataTablesDefaults, { "order": [[ 4, "desc" ]], @@ -315,6 +334,11 @@ Edit news item[% ELSE %]Add news item[% END %][% ELSE %]News[% END %] } }); + $("#show_expired").on("change", function(){ + /* redraw the DataTable according to the custom search function */ + newst.draw(); + }); + newst.on( 'search.dt', function () { var term = newst.search(); $("#news_keyword").val( term ); -- 2.39.5