luci-base: do not add validation for named section if readonly is set

Signed-off-by: Florian Eckert <fe@dev.tdt.de>
This commit is contained in:
Florian Eckert 2021-07-01 15:54:21 +02:00
parent 3358516e1f
commit 1a2b7fef6c

View file

@ -2212,14 +2212,15 @@ var CBITypedSection = CBIAbstractSection.extend(/** @lends LuCI.form.TypedSectio
return this.handleAdd(ev, nameEl.value); return this.handleAdd(ev, nameEl.value);
}), }),
'disabled': true 'disabled': this.map.readonly || true
}, [ btn_title || _('Add') ]) }, [ btn_title || _('Add') ])
]); ]);
if (this.map.readonly !== true) {
ui.addValidator(nameEl, 'uciname', true, function(v) { ui.addValidator(nameEl, 'uciname', true, function(v) {
var button = document.querySelector('.cbi-section-create > .cbi-button-add'); var button = document.querySelector('.cbi-section-create > .cbi-button-add');
if (v !== '') { if (v !== '') {
button.disabled = false; button.disabled = null;
return true; return true;
} }
else { else {
@ -2228,6 +2229,7 @@ var CBITypedSection = CBIAbstractSection.extend(/** @lends LuCI.form.TypedSectio
} }
}, 'blur', 'keyup'); }, 'blur', 'keyup');
} }
}
return createEl; return createEl;
}, },