Bugzilla – Attachment 142977 Details for
Bug 32016
Fix 'clear filter' button behavior on datatable saving their state
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32016: Fix clear filter button behavior
Bug-32016-Fix-clear-filter-button-behavior.patch (text/plain), 3.33 KB, created by
Katrin Fischer
on 2022-11-02 13:42:05 UTC
(
hide
)
Description:
Bug 32016: Fix clear filter button behavior
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2022-11-02 13:42:05 UTC
Size:
3.33 KB
patch
obsolete
>From 0d5a1c8264ebd84041cd0eb87322c80d2404ff07 Mon Sep 17 00:00:00 2001 >From: Thibaud Guillot <thibaud.guillot@biblibre.com> >Date: Thu, 27 Oct 2022 14:15:19 +0200 >Subject: [PATCH] Bug 32016: Fix clear filter button behavior > >For example, if you filter by global search input a datatable which saves its previous state when you want to return to this datatable, the backup is recovered in a cookie but the "clear filter" button is disabled because for it the input is empty, the verification of the recovery of the cookie not being made. > >When loading I therefore added the verification of the cookie and if the search value is not empty then the button can be activated. > >Test plan: > >1) Be sure to have some orders and baskets which can be received >2) Go to 'cgi-bin/koha/acqui/booksellers.pl' and click on 'Receive >shipments' >3) Enter something in global search >4) Go to receive and cancel or save to be back on datatable >5) See that you cannot remove your previous input by the 'clear filter' >button >6) Apply this patch >7) Repeat steps 3) and 4) >8) See that now you can remove your search > >Signed-off-by: David Nind <david@davidnind.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > koha-tmpl/intranet-tmpl/prog/js/datatables.js | 17 ++++++++++++----- > 1 file changed, 12 insertions(+), 5 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >index 82f2c91e79..1955ff8a63 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >@@ -53,19 +53,25 @@ var dataTablesDefaults = { > "fixedHeader": true, > initComplete: function( settings) { > var tableId = settings.nTable.id >+ var state = $("#" + tableId ).DataTable().state(); >+ state && toggledClearFilter(state.search.search, tableId); > // When the DataTables search function is triggered, > // enable or disable the "Clear filter" button based on > // the presence of a search string > $("#" + tableId ).on( 'search.dt', function ( e, settings ) { >- if( settings.oPreviousSearch.sSearch == "" ){ >- $("#" + tableId + "_wrapper").find(".dt_button_clear_filter").addClass("disabled"); >- } else { >- $("#" + tableId + "_wrapper").find(".dt_button_clear_filter").removeClass("disabled"); >- } >+ toggledClearFilter(settings.oPreviousSearch.sSearch, tableId); > }); > } > }; > >+function toggledClearFilter(searchText, tableId){ >+ if( searchText == "" ){ >+ $("#" + tableId + "_wrapper").find(".dt_button_clear_filter").addClass("disabled"); >+ } else { >+ $("#" + tableId + "_wrapper").find(".dt_button_clear_filter").removeClass("disabled"); >+ } >+} >+ > > // Return an array of string containing the values of a particular column > $.fn.dataTableExt.oApi.fnGetColumnData = function ( oSettings, iColumn, bUnique, bFiltered, bIgnoreEmpty ) { >@@ -846,6 +852,7 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { > > if ( add_filters ) { > var table_dt = table.DataTable(); >+ // table_dt.on('search', console.log); > $(this).find('thead tr:eq(1) th').each( function (i) { > var is_searchable = table_dt.settings()[0].aoColumns[i].bSearchable; > if ( is_searchable ) { >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 32016
:
142713
|
142797
| 142977 |
143347