From 4aa6188e897f78b10c075d1242ac3501581617fc Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Tue, 11 Apr 2023 14:58:59 +0100 Subject: [PATCH] Bug 33484: Make saveState column handling global This patch updates the handling for saveState added in bug 22276 to work globally for all KohaTables that pass a table_settings hash. --- .../prog/en/includes/columns_settings.inc | 21 ++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) 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 db3987bbdd..7ff0f80d43 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/columns_settings.inc @@ -11,7 +11,26 @@ function KohaTable(id_selector, dt_parameters, table_settings, add_filters) { var selector = '#' + id_selector; if ( table_settings ) { - var columns_settings = table_settings['columns']; + + var table_key = + 'DataTables_' + + table_settings ['module'] +'_' + + table_settings ['page'] +'_' + + table_settings ['table']; + + // enable stateSave + dt_parameters['stateSave'] = true; + dt_parameters['stateSaveCallback'] = function( settings, data ) { + localStorage.setItem( table_key, JSON.stringify(data) ) + } + dt_parameters['stateLoadCallback'] = function(settings) { + return JSON.parse( localStorage.getItem(table_key) ) + } + + // merge stateSave for column settings + var local_settings = localStorage.getItem(table_key); + var system_settings = table_settings['columns']; + var columns_settings = get_columns_saved_state(local_settings, system_settings); $(columns_settings).each( function() { var named_id = $( 'thead th[data-colname="' + this.columnname + '"]', selector ).index( selector + ' th' ); -- 2.40.0