luci-app-lldpd: improvements for IO select

ES6 and implement optional property

Signed-off-by: Paul Donald <newtwen+github@gmail.com>
This commit is contained in:
Paul Donald
2025-10-18 02:57:32 +02:00
parent 764a94b59c
commit 33d6492459
2 changed files with 14 additions and 11 deletions

View File

@@ -183,19 +183,19 @@ const CBIMultiIOSelect = form.MultiValue.extend({
__name__: 'CBI.MultiIOSelect',
renderWidget(section_id, option_index, cfgvalue) {
const value = (cfgvalue != null) ? cfgvalue : this.default ? this.default : '',
choices = this.transformChoices() ? this.transformChoices() : '';
const value = (cfgvalue != null) ? cfgvalue : this.default ? this.default : '';
const choices = this.transformChoices() ? this.transformChoices() : '';
const widget = new ui.Dropdown(L.toArray(value), choices, {
id: this.cbid(section_id),
sort: this.keylist,
multiple: true,
optional: true,
display_items: 5,
dropdown_items: -1,
create: true,
disabled: (this.readonly != null) ? this.readonly : this.map.readonly,
validate: L.bind(this.validate, this, section_id),
id: this.cbid(section_id),
sort: this.keylist,
multiple: this.multiple ?? true,
optional: this.optional ?? true,
display_items: this.display_items ?? 5,
dropdown_items: this.dropdown_items ?? -1,
create: this.create ?? true,
disabled: (this.readonly != null) ? this.readonly : this.map.readonly,
validate: L.bind(this.validate, this, section_id),
});
return widget.render();

View File

@@ -440,6 +440,7 @@ return L.view.extend({
'blacklist IPv6 addresses, use <code>!*:*</code>.') + '<br />' +
usage);
o.placeholder = 'Addresses and interfaces';
o.optional = true;
o.depends({lldp_mgmt_addr_advertisements: '1'});
o.cfgvalue = function(section_id) {
const opt = uci.get(this.config, section_id, this.option);
@@ -541,6 +542,7 @@ return L.view.extend({
'Absent any value, all interfaces are considered. ' +
'LLDPd takes the first MAC address from all the considered ' +
'interfaces to compute the chassis ID.'));
o.optional = true;
o.value('*');
o.value('!*');
@@ -850,6 +852,7 @@ return L.view.extend({
ss.addbtntitle = _('Add Custom TLV', 'lldpd Custom TLV');
oo = ss.option(lldpd.CBIMultiIOSelect, 'ports',
_('Network Interface(s)'));
oo.optional = true;
net_devices.forEach(nd => {
oo.value(nd.getName());
oo.value('!'+nd.getName());