Bug 22276 - Add client storage of user-selected DataTables configuration
Summary: Add client storage of user-selected DataTables configuration
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: Main
Hardware: All All
: P5 - low enhancement (vote)
Assignee: Owen Leonard
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 33484 35569 33426
  Show dependency treegraph
 
Reported: 2019-02-05 17:27 UTC by Owen Leonard
Modified: 2024-01-06 10:21 UTC (History)
10 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This allows Koha to remember the changes a user has made to the columns settings on a page so they are kept when reloading the page.
Version(s) released in:
22.11.00


Attachments
Bug 22276: Add client storage of user-selected DataTables configuration (5.14 KB, patch)
2022-01-28 13:45 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 22276: Add client storage of user-selected DataTables configuration (5.29 KB, patch)
2022-02-14 13:27 UTC, Solene D
Details | Diff | Splinter Review
Bug 22276: Add client storage of user-selected DataTables configuration (5.34 KB, patch)
2022-04-24 12:46 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 22276: (QA follow-up) Add missing USE (805 bytes, patch)
2022-04-24 12:46 UTC, Katrin Fischer
Details | Diff | Splinter Review
Bug 22276: Add client storage of user-selected DataTables configuration (5.34 KB, patch)
2022-07-27 11:57 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 22276: (QA follow-up) Add missing USE (805 bytes, patch)
2022-07-27 11:57 UTC, Owen Leonard
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Owen Leonard 2019-02-05 17:27:15 UTC
DataTables has a "stateSave" option which uses's the browser's local storage to "remember" how someone last changed the configuration of a DataTable: columns settings, filters, etc. This option doesn't work by default because we always load the configuration stored in Columns Settings. I propose to add a function which will check for the existence of a locally-store table configuration before defaults are loaded.
Comment 1 Owen Leonard 2022-01-28 13:45:26 UTC
Created attachment 129938 [details] [review]
Bug 22276: Add client storage of user-selected DataTables configuration

This patch enables use of DataTables' built-in session storage of table
configurations. DataTables by default uses the browser's localstorage
feature to store the state of each DataTable, including which columns
have been hidden by the user.

Our table settings system has always overridden this saved state. This
patch adds a check for a saved configuration state and if present loads
the saved state instead of the default state.

The system is enabled in this patch on the libraries administration
page. To test, apply the patch and open go to Administration ->
Libraries.

- Use the "Columns" button to change the visibility setting of multiple
  columns.
- Navigate away from the page and then back to test that the visibility
  settings have been kept.
- Go to Administration -> Table settings -> Administration and change
  the visibility settings for the "libraries" table in a way that it
  differs from the visibility settings you set manually.
- Return to the libraries administration page and confirm that your
  manual settings are still being loaded instead of the defaults from
  table settings.
Comment 2 Solene D 2022-02-14 13:27:20 UTC
Created attachment 130548 [details] [review]
Bug 22276: Add client storage of user-selected DataTables configuration

This patch enables use of DataTables' built-in session storage of table
configurations. DataTables by default uses the browser's localstorage
feature to store the state of each DataTable, including which columns
have been hidden by the user.

Our table settings system has always overridden this saved state. This
patch adds a check for a saved configuration state and if present loads
the saved state instead of the default state.

The system is enabled in this patch on the libraries administration
page. To test, apply the patch and open go to Administration ->
Libraries.

- Use the "Columns" button to change the visibility setting of multiple
  columns.
- Navigate away from the page and then back to test that the visibility
  settings have been kept.
- Go to Administration -> Table settings -> Administration and change
  the visibility settings for the "libraries" table in a way that it
  differs from the visibility settings you set manually.
- Return to the libraries administration page and confirm that your
  manual settings are still being loaded instead of the defaults from
  table settings.

Signed-off-by: Solène Desvaux <solene.desvaux@biblibre.com>
Comment 3 Solene D 2022-02-14 13:28:12 UTC
I have executed the test, it is working for me
Comment 4 Jonathan Druart 2022-03-22 10:59:37 UTC
We need to choose bug 16881 or this one. See discussion from bug 16881 comment 6.
Comment 5 Kyle M Hall 2022-03-31 16:05:38 UTC
(In reply to Jonathan Druart from comment #4)
> We need to choose bug 16881 or this one. See discussion from bug 16881
> comment 6.

Not able to test as branches.pl is borked in master atm. This patch limits the stored settings to a given browser while 16881 appears to store it across browsers. I like the simplicity of this implementation. I feel like we could extend this one to storing the data in a table and restoring to localStorage as a follow-up bug. That would give us the best of both!
Comment 6 Katrin Fischer 2022-04-24 12:46:06 UTC
Created attachment 133717 [details] [review]
Bug 22276: Add client storage of user-selected DataTables configuration

This patch enables use of DataTables' built-in session storage of table
configurations. DataTables by default uses the browser's localstorage
feature to store the state of each DataTable, including which columns
have been hidden by the user.

Our table settings system has always overridden this saved state. This
patch adds a check for a saved configuration state and if present loads
the saved state instead of the default state.

The system is enabled in this patch on the libraries administration
page. To test, apply the patch and open go to Administration ->
Libraries.

- Use the "Columns" button to change the visibility setting of multiple
  columns.
- Navigate away from the page and then back to test that the visibility
  settings have been kept.
- Go to Administration -> Table settings -> Administration and change
  the visibility settings for the "libraries" table in a way that it
  differs from the visibility settings you set manually.
- Return to the libraries administration page and confirm that your
  manual settings are still being loaded instead of the defaults from
  table settings.

Signed-off-by: Solène Desvaux <solene.desvaux@biblibre.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 7 Katrin Fischer 2022-04-24 12:46:11 UTC
Created attachment 133718 [details] [review]
Bug 22276: (QA follow-up) Add missing USE

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 8 Katrin Fischer 2022-04-24 12:59:48 UTC
I've added a follow-up to fix a complaint by the QA script. 

I think I agree with Kyle here - I like that this seems to work really nicely and is not a big change.

I'd still like even more permanent storage, but this here would already be very useful and doesn't seem not too risky at this point in the release cycle. 

If we can extend it even further as a next step, that would be great too.
Comment 9 Fridolin Somers 2022-05-04 21:09:31 UTC
Hi, nice indeed.

But how will it behave with a change of "Cannot be toggled" columns ?
What if a new column is added by upgrade ?

Cycle is near the end, I prefer not to push this in 22.05.
But I will follow this with interest ;)
Comment 10 Katrin Fischer 2022-07-21 08:01:16 UTC
It would be great if we could pick this up again. We often get asked about why the settings are not remembered.
Comment 11 Tomás Cohen Arazi 2022-07-25 14:31:17 UTC
Please rebase.
Comment 12 Owen Leonard 2022-07-27 11:57:43 UTC
Created attachment 138172 [details] [review]
Bug 22276: Add client storage of user-selected DataTables configuration

This patch enables use of DataTables' built-in session storage of table
configurations. DataTables by default uses the browser's localstorage
feature to store the state of each DataTable, including which columns
have been hidden by the user.

Our table settings system has always overridden this saved state. This
patch adds a check for a saved configuration state and if present loads
the saved state instead of the default state.

The system is enabled in this patch on the libraries administration
page. To test, apply the patch and open go to Administration ->
Libraries.

- Use the "Columns" button to change the visibility setting of multiple
  columns.
- Navigate away from the page and then back to test that the visibility
  settings have been kept.
- Go to Administration -> Table settings -> Administration and change
  the visibility settings for the "libraries" table in a way that it
  differs from the visibility settings you set manually.
- Return to the libraries administration page and confirm that your
  manual settings are still being loaded instead of the defaults from
  table settings.

Signed-off-by: Solène Desvaux <solene.desvaux@biblibre.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 13 Owen Leonard 2022-07-27 11:57:47 UTC
Created attachment 138173 [details] [review]
Bug 22276: (QA follow-up) Add missing USE

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 14 Tomás Cohen Arazi 2022-07-27 13:07:59 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 15 Lucas Gass 2022-09-02 20:15:14 UTC
Enhancement will not be backported to the 22.05.x series
Comment 16 Jonathan Druart 2023-04-06 06:49:42 UTC
Why do we have this in branches.tt only? We don't want to have one follow-up bug per table, we need to apply it from datatabase.js (or .inc or wherever, but in a single place).
Comment 17 Katrin Fischer 2023-04-08 15:38:02 UTC
(In reply to Jonathan Druart from comment #16)
> Why do we have this in branches.tt only? We don't want to have one follow-up
> bug per table, we need to apply it from datatabase.js (or .inc or wherever,
> but in a single place).

If this is possible, I think we should do it. It would be so nice to have this globally.
Comment 18 Martin Renvoize 2023-04-11 14:21:09 UTC
(In reply to Katrin Fischer from comment #17)
> (In reply to Jonathan Druart from comment #16)
> > Why do we have this in branches.tt only? We don't want to have one follow-up
> > bug per table, we need to apply it from datatabase.js (or .inc or wherever,
> > but in a single place).
> 
> If this is possible, I think we should do it. It would be so nice to have
> this globally.

See bug 33484