luci-app-lldpd: improvements for IO select
authorPaul Donald <[email protected]>
Sat, 18 Oct 2025 00:57:32 +0000 (02:57 +0200)
committerPaul Donald <[email protected]>
Tue, 25 Nov 2025 22:20:40 +0000 (23:20 +0100)
ES6 and implement optional property

Signed-off-by: Paul Donald <[email protected]>
applications/luci-app-lldpd/htdocs/luci-static/resources/lldpd.js
applications/luci-app-lldpd/htdocs/luci-static/resources/view/lldpd/config.js

index 8695fc8c5537e097df12dd7ef59ad8a1a79b29f3..e9c638b1531f4727df8ff682af49d5630f8e292b 100644 (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();
index 60afb119802a8e0589acaf1cfbe27d7058ce8e65..c96e38a82c18d6ac878218d8b978e87212c7276d 100644 (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());