From 705e2d53efa38a8d0b4ec2ab12f4c768726119a8 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Fri, 4 Oct 2024 10:39:18 +0000 Subject: [PATCH] Bug 38071: Add behavior to work with filters Consider column filters values when deciding if the 'clear filter' should be enabled or not. --- koha-tmpl/intranet-tmpl/prog/js/datatables.js | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js index daab5c2c0ed..6a96ce163dd 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -70,8 +70,8 @@ var dataTablesDefaults = { } }; -function toggledClearFilter(searchText, tableId){ - if( searchText == "" ){ +function toggledClearFilter(searchText, tableId, searchFilters){ + if( searchText == "" && searchFilters === false ){ $("#" + tableId + "_wrapper").find(".dt_button_clear_filter").addClass("disabled"); } else { $("#" + tableId + "_wrapper").find(".dt_button_clear_filter").removeClass("disabled"); @@ -1007,7 +1007,10 @@ function _dt_add_delay(table_dt, table_node, delay_ms) { // enable or disable the "Clear filter" button based on // the presence of a search string this.on( 'search.dt', function ( e, settings ) { - toggledClearFilter(settings.oPreviousSearch.sSearch, tableId); + let searchFilters = settings.aoPreSearchCols.some(function (value) { + return value.sSearch != ""; + }); + toggledClearFilter(settings.oPreviousSearch.sSearch, tableId, searchFilters); }); } -- 2.43.0