From 30615536082bfccc40cce6158b3a01c33551cec1 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Thu, 4 Sep 2025 12:51:09 +0200 Subject: [PATCH] Bug 39930: Prevent DT's state to be lost overnight The default value for stateDuration is 7200 (2h). Which means DataTables will ignore the saved state if reused after this delay. Additionally is causes problem on some tables where the default state is not restored and all columns are displayed. From https://datatables.net/reference/option/stateDuration ``` Please note that the value is given in seconds. The value 0 is a special value as it indicates that the state can be stored and retrieved indefinitely with no time limit. ``` We are going to set it to 0 so that the state is only lost/reset after a logout Test plan: Ideally you can should edit this file and set saveState to 60 (seconds), so it's easy to test. Do not apply this patch and confirm that the state is not restored after either 60s or 2h (if you modified the file or not). It is a problem on the checkout list table as extra columns (like "Today's checkouts") are displayed. With this patch applied the state should be restored correctly. If you logout the state will be lost however. Ideally we might want to store user's preferences on the server. --- koha-tmpl/intranet-tmpl/prog/js/datatables.js | 1 + 1 file changed, 1 insertion(+) diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js index 28d1cf5eee8..dfa8e93af03 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js +++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js @@ -1270,6 +1270,7 @@ function _dt_save_restore_state(table_settings, external_filter_nodes = {}) { return { stateSave: true, + stateDuration: 0, stateSaveCallback, stateLoadCallback, stateSaveParams, -- 2.34.1