Bugzilla – Attachment 173465 Details for
Bug 33484
Ability to remember user's selected table configuration and search filters for tables
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33484: Adjust columns_settings.inc
Bug-33484-Adjust-columnssettingsinc.patch (text/plain), 7.11 KB, created by
Jonathan Druart
on 2024-10-28 09:45:39 UTC
(
hide
)
Description:
Bug 33484: Adjust columns_settings.inc
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-10-28 09:45:39 UTC
Size:
7.11 KB
patch
obsolete
>From 12a05cdf0aefa111baaeb146c0d273ca46f1d415 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 8 Oct 2024 12:45:43 +0200 >Subject: [PATCH] Bug 33484: Adjust columns_settings.inc > >Signed-off-by: Pedro Amorim <pedro.amorim@ptfs-europe.com> >Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> >--- > .../prog/en/includes/columns_settings.inc | 49 ++++++++++++++++++- > koha-tmpl/intranet-tmpl/prog/js/datatables.js | 44 +++++++++-------- > 2 files changed, 70 insertions(+), 23 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc >index c082277b9aa..0ed07f38671 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc >@@ -26,11 +26,29 @@ function KohaTable(id_selector, dt_parameters, table_settings, add_filters) { > dt_parameters.stateSaveCallback = function( settings, data ) { > localStorage.setItem( table_key, JSON.stringify(data) ) > } >+ >+ function set_default(table_settings, settings){ >+ let columns = new Array(table_settings.columns.length).fill({visible: true}); >+ let hidden_ids, included_ids; >+ [hidden_ids, included_ids] = _dt_visibility(table_settings, settings, $("#"+settings.nTable.id)); >+ hidden_ids.forEach((id, i) => { columns[id] = { visible: false } } ); >+ // State is not loaded if time is not passed >+ return { columns, time: new Date() }; >+ } > dt_parameters.stateLoadCallback = function(settings) { >- if (!default_save_state) return {}; >+ >+ // Load state from URL >+ const url = new URL(window.location.href); >+ let state_from_url = url.searchParams.get( settings.nTable.id + '_state'); >+ if ( state_from_url ) { >+ settings.loaded_from_state = true; >+ return JSON.parse(atob(state_from_url)); >+ } >+ >+ if (!default_save_state) return set_default(table_settings, settings); > > let state = localStorage.getItem(table_key); >- if (!state) return {}; >+ if (!state) return set_default(table_settings, settings); > > state = JSON.parse(state); > >@@ -38,6 +56,7 @@ function KohaTable(id_selector, dt_parameters, table_settings, add_filters) { > delete state.search; > state.columns.forEach(c => delete c.search ); > } >+ settings.loaded_from_state = true; > return state; > } > >@@ -193,6 +212,30 @@ function KohaTable(id_selector, dt_parameters, table_settings, add_filters) { > } > ); > >+ if ( table_settings ) { >+ dt_parameters["buttons"].push( >+ { >+ 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>', >+ action: function (e, dt, node, config) { >+ let state = JSON.stringify(dt.state()); >+ delete state.time; >+ let searchParams = new URLSearchParams(window.location.search); >+ let table_id = dt.table().node().id; >+ searchParams.set(table_id + '_state', btoa(state)); >+ let url = window.location.origin + window.location.pathname + '?' + searchParams.toString() + window.location.hash; >+ if( navigator.clipboard && navigator.clipboard.writeText){ >+ navigator.clipboard.writeText( url ); >+ // TODO Add tooltip "State copied to the clipboard" >+ } >+ }, >+ } >+ ); >+ } >+ > if ( table_settings && CAN_user_parameters_manage_column_config ) { > dt_parameters[ "buttons" ].push( > { >@@ -233,6 +276,8 @@ function KohaTable(id_selector, dt_parameters, table_settings, add_filters) { > }); > } > >+ new_parameters["loaded_from_state"] = false; >+ > if ( table_settings ) { > if ( table_settings.hasOwnProperty('default_display_length') && table_settings['default_display_length'] != null ) { > // pageLength needs to be a number, not a string, or it can cause issues with DataTable's next button. >diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >index 5b7de460846..31e61f3463c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >@@ -758,27 +758,29 @@ function _dt_buttons(params){ > } > ); > >- buttons.push( >- { >- 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>', >- action: function (e, dt, node, config) { >- let state = JSON.stringify(dt.state()); >- delete state.time; >- let searchParams = new URLSearchParams(window.location.search); >- let table_id = dt.table().node().id; >- searchParams.set(table_id + '_state', btoa(state)); >- let url = window.location.origin + window.location.pathname + '?' + searchParams.toString() + window.location.hash; >- if( navigator.clipboard && navigator.clipboard.writeText){ >- navigator.clipboard.writeText( url ); >- // TODO Add tooltip "State copied to the clipboard" >- } >- }, >- } >- ); >+ if ( table_settings ) { >+ buttons.push( >+ { >+ 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>', >+ action: function (e, dt, node, config) { >+ let state = JSON.stringify(dt.state()); >+ delete state.time; >+ let searchParams = new URLSearchParams(window.location.search); >+ let table_id = dt.table().node().id; >+ searchParams.set(table_id + '_state', btoa(state)); >+ let url = window.location.origin + window.location.pathname + '?' + searchParams.toString() + window.location.hash; >+ if( navigator.clipboard && navigator.clipboard.writeText){ >+ navigator.clipboard.writeText( url ); >+ // TODO Add tooltip "State copied to the clipboard" >+ } >+ }, >+ } >+ ); >+ } > > if ( table_settings && CAN_user_parameters_manage_column_config ) { > buttons.push( >-- >2.34.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 33484
:
149444
|
149445
|
149447
|
149448
|
149449
|
149925
|
149926
|
149927
|
149928
|
149929
|
149930
|
149974
|
149975
|
149976
|
149977
|
149978
|
149979
|
173443
|
173444
|
173445
|
173446
|
173447
|
173448
|
173449
|
173450
|
173451
|
173452
|
173453
|
173454
|
173455
|
173456
|
173457
|
173458
|
173459
|
173460
|
173461
|
173462
|
173463
|
173464
| 173465 |
173466
|
173467
|
173468
|
173469
|
173470
|
173471
|
173472
|
173473
|
173474
|
173475
|
173476
|
173477
|
173478
|
173479
|
173480
|
173481
|
173482
|
173483
|
173484
|
173485
|
173486
|
173546
|
173606
|
173607
|
173985
|
174219