Bugzilla – Attachment 115330 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 3] Use stateSave
Bug-27467-SOLUTION-3-Use-stateSave.patch (text/plain), 2.30 KB, created by
Jonathan Druart
on 2021-01-19 14:13:04 UTC
(
hide
)
Description:
Bug 27467: [SOLUTION 3] Use stateSave
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-01-19 14:13:04 UTC
Size:
2.30 KB
patch
obsolete
>From a922f8acf1dcb32291ab62c85b7bcebdd8d64c90 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 19 Jan 2021 14:16:13 +0100 >Subject: [PATCH] Bug 27467: [SOLUTION 3] Use stateSave > >Based on > https://stackoverflow.com/questions/55446923/datatables-1-10-using-savestate-to-remember-filtering-and-order-but-need-to-upd/60708638#60708638 >(I removed the atob and btoa call) > >This solution is finally working but it's not the ideal one IMO. >Using stateSave will modify the URL when the user modifies the table's >settings. >We would prefer to not modify it but have a "Copy link" buttons on top >of the table instead. >--- > koha-tmpl/intranet-tmpl/prog/js/datatables.js | 27 +++++++++++++++++++ > 1 file changed, 27 insertions(+) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >index 6baa84b8bb..826f14d659 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >@@ -63,6 +63,33 @@ var dataTablesDefaults = { > $("#" + tableId + "_wrapper").find(".dt_button_clear_filter").removeClass("disabled"); > } > }); >+ }, >+ stateSave: true, >+ stateSaveCallback: function (settings, data) { >+ const state = JSON.stringify(data); >+ //get query part of the url >+ let searchParams = new URLSearchParams(window.location.search); >+ //add encoded state into query part >+ searchParams.set($(this).attr('id') + '_state', state); >+ //form url with new query parameter >+ const newRelativePathQuery = window.location.pathname + '?' + searchParams.toString() + window.location.hash; >+ //push new url into history object, this will change the current url without need of reload >+ history.pushState(null, '', newRelativePathQuery); >+ }, >+ stateLoadCallback: function (settings) { >+ const url = new URL(window.location.href); >+ let state = url.searchParams.get($(this).attr('id') + '_state'); >+ >+ //check the current url to see if we've got a state to restore >+ if (!state) { >+ return null; >+ } >+ >+ //if we got the state, add current timestamp >+ state = JSON.parse(state); >+ state['time'] = Date.now(); >+ >+ return state; > } > }; > >-- >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