From ccd07ee03e84a26a59fa256a37dff36394c1a4fb Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Fri, 4 Oct 2024 12:33:27 +0000 Subject: [PATCH] Bug 38071: Make it so that 'clear filter' also clears the filter values 1 - Browse to details record for a biblio with items 2 - Click 'Show filters' 3 - Select/type in some filters 4 - Note 'Clear filters' is grayed out 5 - Try to click it, no response 6 - Apply patches. Repeat (make sure to use the search text input as well as the column filters. 7 - Repeat the same test plan but for the patrons table 8 - Verify all is working as intended --- koha-tmpl/intranet-tmpl/prog/js/datatables.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js index 6a96ce163dd..778fb3de13f 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -721,6 +721,10 @@ function _dt_buttons(params){ enabled: false, text: ' ' + __("Clear filter") + '', action: function ( e, dt, node, config ) { + $(".dt_filter_col input, .dt_filter_col select").val(""); + dt.columns().every( function () { + this.search( "" ); + } ); dt.search( "" ).draw("page"); node.addClass("disabled"); } @@ -822,7 +826,7 @@ function _dt_add_filters(table_node, table_dt, filters_options = {}) { $(table_node).find('thead tr:eq(1) th').each( function (i) { var is_searchable = table_dt.settings()[0].aoColumns[i].bSearchable; - $(this).removeClass('sorting').removeClass("sorting_asc").removeClass("sorting_desc"); + $(this).removeClass('sorting').removeClass("sorting_asc").removeClass("sorting_desc").addClass("dt_filter_col"); $(this).data('th-id', i); if ( is_searchable ) { let input_type = 'input'; -- 2.43.0