summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--modules/luci-base/htdocs/luci-static/resources/ui.js5
-rw-r--r--modules/luci-base/luasrc/dispatcher.lua24
-rw-r--r--modules/luci-compat/luasrc/view/cbi/footer.htm6
-rw-r--r--modules/luci-compat/luasrc/view/cbi/map.htm22
4 files changed, 30 insertions, 27 deletions
diff --git a/modules/luci-base/htdocs/luci-static/resources/ui.js b/modules/luci-base/htdocs/luci-static/resources/ui.js
index 4219932b9a..50410762fe 100644
--- a/modules/luci-base/htdocs/luci-static/resources/ui.js
+++ b/modules/luci-base/htdocs/luci-static/resources/ui.js
@@ -444,7 +444,8 @@ var UITextarea = UIElement.extend(/** @lends LuCI.ui.Textarea.prototype */ {
/** @override */
render: function() {
- var frameEl = E('div', { 'id': this.options.id }),
+ var style = !this.options.cols ? 'width:100%' : null,
+ frameEl = E('div', { 'id': this.options.id, 'style': style }),
value = (this.value != null) ? String(this.value) : '';
frameEl.appendChild(E('textarea', {
@@ -454,7 +455,7 @@ var UITextarea = UIElement.extend(/** @lends LuCI.ui.Textarea.prototype */ {
'readonly': this.options.readonly ? '' : null,
'disabled': this.options.disabled ? '' : null,
'placeholder': this.options.placeholder,
- 'style': !this.options.cols ? 'width:100%' : null,
+ 'style': style,
'cols': this.options.cols,
'rows': this.options.rows,
'wrap': this.options.wrap ? '' : null
diff --git a/modules/luci-base/luasrc/dispatcher.lua b/modules/luci-base/luasrc/dispatcher.lua
index d4ba0a95e4..d14a866737 100644
--- a/modules/luci-base/luasrc/dispatcher.lua
+++ b/modules/luci-base/luasrc/dispatcher.lua
@@ -1329,12 +1329,23 @@ function _cbi(self, ...)
local cbi = require "luci.cbi"
local tpl = require "luci.template"
local http = require "luci.http"
+ local util = require "luci.util"
local config = self.config or {}
local maps = cbi.load(self.model, ...)
local state = nil
+ local function has_uci_access(config, level)
+ local rv = util.ubus("session", "access", {
+ ubus_rpc_session = context.authsession,
+ scope = "uci", object = config,
+ ["function"] = level
+ })
+
+ return (type(rv) == "table" and rv.access == true) or false
+ end
+
local i, res
for i, res in ipairs(maps) do
if util.instanceof(res, cbi.SimpleForm) then
@@ -1388,6 +1399,7 @@ function _cbi(self, ...)
local applymap = false
local pageaction = true
local parsechain = { }
+ local writable = false
for i, res in ipairs(maps) do
if res.apply_needed and res.parsechain then
@@ -1413,12 +1425,19 @@ function _cbi(self, ...)
end
for i, res in ipairs(maps) do
+ local is_readable_map = has_uci_access(res.config, "read")
+ local is_writable_map = has_uci_access(res.config, "write")
+
+ writable = writable or is_writable_map
+
res:render({
firstmap = (i == 1),
redirect = redirect,
messages = messages,
pageaction = pageaction,
- parsechain = parsechain
+ parsechain = parsechain,
+ readable = is_readable_map,
+ writable = is_writable_map
})
end
@@ -1429,7 +1448,8 @@ function _cbi(self, ...)
redirect = redirect,
state = state,
autoapply = config.autoapply,
- trigger_apply = applymap
+ trigger_apply = applymap,
+ writable = writable
})
end
end
diff --git a/modules/luci-compat/luasrc/view/cbi/footer.htm b/modules/luci-compat/luasrc/view/cbi/footer.htm
index 176f10c5e1..abcc47b920 100644
--- a/modules/luci-compat/luasrc/view/cbi/footer.htm
+++ b/modules/luci-compat/luasrc/view/cbi/footer.htm
@@ -19,15 +19,15 @@
end
if display_apply then
- %><input class="btn cbi-button cbi-button-apply" type="button" value="<%:Save & Apply%>" onclick="cbi_submit(this, 'cbi.apply')"<%=ifattr(not has_writeable_map, "disabled")%> /> <%
+ %><input class="btn cbi-button cbi-button-apply" type="button" value="<%:Save & Apply%>" onclick="cbi_submit(this, 'cbi.apply')"<%=ifattr(not writable, "disabled")%> /> <%
end
if display_save then
- %><input class="btn cbi-button cbi-button-save" type="submit" value="<%:Save%>"<%=ifattr(not has_writeable_map, "disabled")%> /> <%
+ %><input class="btn cbi-button cbi-button-save" type="submit" value="<%:Save%>"<%=ifattr(not writable, "disabled")%> /> <%
end
if display_reset then
- %><input class="btn cbi-button cbi-button-reset" type="button" value="<%:Reset%>" onclick="location.href='<%=REQUEST_URI%>'"<%=ifattr(not has_writeable_map, "disabled")%> /> <%
+ %><input class="btn cbi-button cbi-button-reset" type="button" value="<%:Reset%>" onclick="location.href='<%=REQUEST_URI%>'"<%=ifattr(not writable, "disabled")%> /> <%
end
%></div><%
diff --git a/modules/luci-compat/luasrc/view/cbi/map.htm b/modules/luci-compat/luasrc/view/cbi/map.htm
index 530d1fec60..a96f722378 100644
--- a/modules/luci-compat/luasrc/view/cbi/map.htm
+++ b/modules/luci-compat/luasrc/view/cbi/map.htm
@@ -2,26 +2,8 @@
<div class="alert-message warning"><%=pcdata(msg)%></div>
<%- end end -%>
-<%
- local function has_access(config, level)
- local rv = luci.util.ubus("session", "access", {
- ubus_rpc_session = luci.dispatcher.context.authsession,
- scope = "uci",
- object = config,
- ["function"] = level
- })
-
- return (type(rv) == "table" and rv.access == true) or false
- end
-
- local is_readable = has_access(self.config, "read")
- local is_writable = has_access(self.config, "write")
-
- has_writeable_map = has_writeable_map or is_writable
-%>
-
-<% if is_readable then %>
-<div class="cbi-map" id="cbi-<%=self.config%>"<%=ifattr(not is_writable, "style", "opacity:.6; pointer-events:none")%>>
+<% if readable then %>
+<div class="cbi-map" id="cbi-<%=self.config%>"<%=ifattr(not writable, "style", "opacity:.6; pointer-events:none")%>>
<% if self.title and #self.title > 0 then %>
<h2 name="content"><%=self.title%></h2>
<% end %>