Skip to content

Commit 3aa2841

Browse files
committed
Sortable Table UI: Fallback default sort settings to global client config, if user pref is not set.
1 parent 21b9357 commit 3aa2841

3 files changed

Lines changed: 8 additions & 2 deletions

File tree

docs/config.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -623,6 +623,11 @@ This path string points to the logo used in the UI header/sidebar and in emails
623623

624624
This array allows you to globally hide specific sidebar sections for all users, regardless of their preferences.
625625

626+
### client.tables
627+
<!-- Title: Default Table Sort -->
628+
629+
This object allows you to set default sort preferences for all the sortable tables in the UI.
630+
626631
### client.items_per_page
627632
<!-- Title: List Items Per Page -->
628633

htdocs/js/pages/Base.class.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3679,8 +3679,8 @@ Page.Base = class Base extends Page {
36793679
var html = '';
36803680
if (!this.tables) this.tables = {};
36813681

3682-
opts.sort_by = app.getPref(`tables.${opts.id}.sort_by`) || opts.sort_by;
3683-
opts.sort_dir = app.getPref(`tables.${opts.id}.sort_dir`) || opts.sort_dir;
3682+
opts.sort_by = app.getPref(`tables.${opts.id}.sort_by`) || get_path(config, `tables.${opts.id}.sort_by`) || opts.sort_by;
3683+
opts.sort_dir = app.getPref(`tables.${opts.id}.sort_dir`) || get_path(config, `tables.${opts.id}.sort_dir`) || opts.sort_dir;
36843684

36853685
// retrieve previous settings if applicable
36863686
if (this.tables[ opts.id ]) {

sample_conf/config.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,7 @@
272272
"company": "PixlCore LLC",
273273
"logo_url": "/images/logotype.png",
274274
"hide_sidebar_sections": [],
275+
"tables": {},
275276

276277
"items_per_page": 50,
277278
"alt_items_per_page": 25,

0 commit comments

Comments
 (0)