summaryrefslogtreecommitdiffhomepage
path: root/modules/luci-base/htdocs/luci-static
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2020-04-15 22:15:28 +0200
committerJo-Philipp Wich <jo@mein.io>2020-04-16 13:30:35 +0200
commitadeb0f3aa6bb9080066f79d0411e8e334b8b498f (patch)
tree42c4c749dfd6d9bf4fec19c5cc347e827dcfcfb0 /modules/luci-base/htdocs/luci-static
parentb739fc17eabe9905889017127ac1de8f4e194819 (diff)
luci-base: luci.js: disable page action buttons on readonly views
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
Diffstat (limited to 'modules/luci-base/htdocs/luci-static')
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/luci.js27
1 files changed, 23 insertions, 4 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/luci.js b/modules/luci-base/htdocs/luci-static/resources/luci.js
index 519bf8fd6..4af5f2944 100644
--- a/modules/luci-base/htdocs/luci-static/resources/luci.js
+++ b/modules/luci-base/htdocs/luci-static/resources/luci.js
@@ -2148,7 +2148,23 @@
* methods are overwritten with `null`.
*/
addFooter: function() {
- var footer = E([]);
+ var footer = E([]),
+ vp = document.getElementById('view'),
+ hasmap = false,
+ readonly = true;
+
+ vp.querySelectorAll('.cbi-map').forEach(function(map) {
+ var m = DOM.findClassInstance(map);
+ if (m) {
+ hasmap = true;
+
+ if (!m.readonly)
+ readonly = false;
+ }
+ });
+
+ if (!hasmap)
+ readonly = !L.hasViewPermission();
var saveApplyBtn = this.handleSaveApply ? new L.ui.ComboButton('0', {
0: [ _('Save & Apply') ],
@@ -2158,7 +2174,8 @@
0: 'btn cbi-button cbi-button-apply important',
1: 'btn cbi-button cbi-button-negative important'
},
- click: L.ui.createHandlerFn(this, 'handleSaveApply')
+ click: L.ui.createHandlerFn(this, 'handleSaveApply'),
+ disabled: readonly || null
}).render() : E([]);
if (this.handleSaveApply || this.handleSave || this.handleReset) {
@@ -2166,11 +2183,13 @@
saveApplyBtn, ' ',
this.handleSave ? E('button', {
'class': 'cbi-button cbi-button-save',
- 'click': L.ui.createHandlerFn(this, 'handleSave')
+ 'click': L.ui.createHandlerFn(this, 'handleSave'),
+ 'disabled': readonly || null
}, [ _('Save') ]) : '', ' ',
this.handleReset ? E('button', {
'class': 'cbi-button cbi-button-reset',
- 'click': L.ui.createHandlerFn(this, 'handleReset')
+ 'click': L.ui.createHandlerFn(this, 'handleReset'),
+ 'disabled': readonly || null
}, [ _('Reset') ]) : ''
]));
}