Bugzilla – Attachment 115327 Details for
Bug 27467
Provide a static URL for tables
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 27467: [SOLUTION 1] Use keepConditions
Bug-27467-SOLUTION-1-Use-keepConditions.patch (text/plain), 6.70 KB, created by
Jonathan Druart
on 2021-01-19 14:12:08 UTC
(
hide
)
Description:
Bug 27467: [SOLUTION 1] Use keepConditions
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-01-19 14:12:08 UTC
Size:
6.70 KB
patch
obsolete
>From bb306a73428265ff8c7b4c780ec0d1c320bb04c7 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Mon, 18 Jan 2021 15:49:01 +0100 >Subject: [PATCH] Bug 27467: [SOLUTION 1] Use keepConditions > >This first solution use a non longer maintained plugin: > https://github.com/jhyland87/DataTables-Keep-Conditions/ > >I've tried to make it works with the column filters. But actually even >with the general search filter the table is not correctly filtered. > >I guess it's related to their issue 1 > https://github.com/jhyland87/DataTables-Keep-Conditions/issues/1 > >To test: >Go to the cities page >Use the general search filter >Copy the URL and open it in a separate tab >=> The filter is kept but the REST API query is not built using it >--- > .../plugins/dataTables.keepConditions.js | 30 +++++++++++++++---- > .../prog/en/includes/datatables.inc | 1 + > .../prog/en/modules/admin/cities.tt | 1 + > koha-tmpl/intranet-tmpl/prog/js/datatables.js | 21 +++++++++++++ > 4 files changed, 47 insertions(+), 6 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/lib/jquery/plugins/dataTables.keepConditions.js b/koha-tmpl/intranet-tmpl/lib/jquery/plugins/dataTables.keepConditions.js >index 6a6d4867cd..b15bfe5b1a 100644 >--- a/koha-tmpl/intranet-tmpl/lib/jquery/plugins/dataTables.keepConditions.js >+++ b/koha-tmpl/intranet-tmpl/lib/jquery/plugins/dataTables.keepConditions.js >@@ -852,28 +852,46 @@ var KeepConditions = (function () { > > // Check if condition is setup on table > isInit: function isInit() { >- return typeof _parent._dtSettings.oInit.searching === 'undefined' || _parent._dtSettings.oInit.searching !== false; >+ return true; // FIXME >+ //return typeof _parent._dtSettings.oInit.searching === 'undefined' || _parent._dtSettings.oInit.searching !== false; > }, > > // Function to check if a condition exists in the hash, and to process it > onLoad: function onLoad(hashComponent) { >- if (typeof hashComponent !== 'undefined' && _parent._dtApi.search() !== decodeURIComponent(hashComponent)) { >- _parent._dtApi.search(decodeURIComponent(hashComponent)); >+ if (typeof hashComponent !== 'undefined' ) { >+ var filters = JSON.parse(decodeURIComponent(hashComponent)); >+ var global_filter = filters['f']; >+ var column_filters = filters['cf']; >+ var table_dt = $(_parent._dtApi.table); >+ _parent._dtApi.search(global_filter); >+ $.each(column_filters, function(i, v){ >+ if ( v != "" ) { >+ $(table_dt).find('thead tr:eq(1) th:eq('+i+') input').val(v); >+ //_parent._dtApi.column(i).search(v).draw(); >+ _parent._dtApi.column(i).search(v); >+ } >+ }); >+ > _parent._shouldDraw = true; > } > }, > > // Check if a value for this condition is currently set for the table (and not at default) > isset: function isset() { >- return _parent._dtApi.search().length !== 0; >+ return true; // FIXME >+ //return _parent._dtApi.search().length !== 0; > }, > > // Return the new value to be stored in the hash for this conditions component > newHashVal: function newHashVal() { >- return encodeURIComponent(_parent._dtApi.search()); >+ var global_filter = _parent._dtApi.search(); >+ var column_filters = []; >+ _parent._dtApi.columns().search().each(function(v,i){ >+ column_filters.push(this[i]); >+ }); >+ return encodeURIComponent(JSON.stringify({'f': global_filter, 'cf': column_filters })); > } > }, >- > /** > * Condition: Length > * >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc >index a545868ce7..33802683fa 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/datatables.inc >@@ -2,4 +2,5 @@ > [% USE Asset %] > [% INCLUDE 'format_price.inc' %] > [% Asset.js("lib/datatables/datatables.min.js") | $raw %] >+[% Asset.js("lib/jquery/plugins/dataTables.keepConditions.js") | $raw %] > [% Asset.js("js/datatables.js") | $raw %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/cities.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/cities.tt >index 24a2d26d30..a291a72f9a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/cities.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/cities.tt >@@ -188,6 +188,7 @@ > "ajax": { > "url": cities_table_url > }, >+ keepConditions: true, > "order": [[ 1, "asc" ]], > "columnDefs": [ { > "targets": [0,1,2,3,4], >diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >index 6baa84b8bb..9e6e6ea436 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >@@ -734,6 +734,27 @@ jQuery.fn.dataTable.ext.errMode = function(settings, note, message) { > buttons: export_buttons > } > ); >+ settings["buttons"].push( >+ { >+ extend: 'copyConditions', >+ autoClose: true, >+ fade: 100, >+ className: "copyConditions_controls", >+ titleAttr: __("Copy conditions"), >+ text: '<i class="fa fa-lg fa-copy"></i> <span class="dt-button-text">' + __("Copy conditions") + '</span>', >+ } >+ ); >+ >+ settings["buttons"].push( >+ { >+ extend: 'copyConditions', >+ autoClose: true, >+ fade: 100, >+ className: "copyConditions_controls", >+ titleAttr: __("Copy conditions"), >+ text: '<i class="fa fa-lg fa-copy"></i> <span class="dt-button-text">' + __("Copy conditions") + '</span>', >+ } >+ ); > > $(".dt_button_clear_filter, .columns_controls, .export_controls").tooltip(); > >-- >2.20.1
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 27467
:
115325
|
115326
|
115327
|
115328
|
115329
|
115330
|
115331
|
117962