diff options
author | Florian Eckert <fe@dev.tdt.de> | 2021-07-01 15:54:21 +0200 |
---|---|---|
committer | Florian Eckert <fe@dev.tdt.de> | 2021-07-01 15:54:51 +0200 |
commit | 1a2b7fef6cc181f7f0ff0e1133ad4d8ab03e279c (patch) | |
tree | a8991913fdb93515ded1df430e567de07c578323 /modules | |
parent | 3358516e1f8263b41fc5e132510fbf72b1108f61 (diff) |
luci-base: do not add validation for named section if readonly is set
Signed-off-by: Florian Eckert <fe@dev.tdt.de>
Diffstat (limited to 'modules')
-rw-r--r-- | modules/luci-base/htdocs/luci-static/resources/form.js | 26 |
1 files changed, 14 insertions, 12 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/form.js b/modules/luci-base/htdocs/luci-static/resources/form.js index e9c8d2eb00..fbdd73e55e 100644 --- a/modules/luci-base/htdocs/luci-static/resources/form.js +++ b/modules/luci-base/htdocs/luci-static/resources/form.js @@ -2212,21 +2212,23 @@ var CBITypedSection = CBIAbstractSection.extend(/** @lends LuCI.form.TypedSectio return this.handleAdd(ev, nameEl.value); }), - 'disabled': true + 'disabled': this.map.readonly || true }, [ btn_title || _('Add') ]) ]); - ui.addValidator(nameEl, 'uciname', true, function(v) { - var button = document.querySelector('.cbi-section-create > .cbi-button-add'); - if (v !== '') { - button.disabled = false; - return true; - } - else { - button.disabled = true; - return _('Expecting: %s').format(_('non-empty value')); - } - }, 'blur', 'keyup'); + if (this.map.readonly !== true) { + ui.addValidator(nameEl, 'uciname', true, function(v) { + var button = document.querySelector('.cbi-section-create > .cbi-button-add'); + if (v !== '') { + button.disabled = null; + return true; + } + else { + button.disabled = true; + return _('Expecting: %s').format(_('non-empty value')); + } + }, 'blur', 'keyup'); + } } return createEl; |