luci-base: load luci preferences early

Follow-up to 315dbfc749

In order to look at any saved uci value, the luci config
must be loaded before we render the page, so we can determine
stored preferences, for things like table filter, without
encumbering all consumers of configurable elements to load
the luci uci configuration.

All (Table) elements extend CBIAbstractElement, so load
there.

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
This commit is contained in:
Paul Donald
2026-02-03 20:30:37 +01:00
parent a91593d03b
commit 01c53bec37
2 changed files with 3 additions and 2 deletions

View File

@@ -378,6 +378,7 @@ const CBIAbstractElement = baseclass.extend(/** @lends LuCI.form.AbstractElement
const CBIMap = CBIAbstractElement.extend(/** @lends LuCI.form.Map.prototype */ {
__init__(config, ...args) {
this.super('__init__', args);
uci.load('luci');
this.config = config;
this.parsechain = [ config ];
@@ -2740,7 +2741,7 @@ const CBITableSection = CBITypedSection.extend(/** @lends LuCI.form.TableSection
const max_cols = this.max_cols ?? this.children.length;
const has_more = max_cols < this.children.length;
const anon_class = (!this.anonymous || this.sectiontitle) ? 'named' : 'anonymous';
const tableFilter = this.map.data.get('luci', 'main', 'tablefilters') || false;
const tableFilter = uci.get('luci', 'main', 'tablefilters') || false;
const trEls = E([]);
for (let i = 0, opt; i < max_cols && (opt = this.children[i]) != null; i++) {

View File

@@ -19,7 +19,7 @@
"file": [ "list" ],
"uci": [ "changes", "get" ]
},
"uci": [ "system" ]
"uci": [ "system", "luci" ]
},
"write": {
"cgi-io": [ "upload" ],