summaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorChristian Schoenebeck <christian.schoenebeck@gmail.com>2015-11-01 15:34:17 +0100
committerChristian Schoenebeck <christian.schoenebeck@gmail.com>2015-11-01 15:34:17 +0100
commitc7a2fe3b01cbe25f5ad2d196cedef7c6c7ab53dc (patch)
tree7a62108fef3632a77668eae880b3b0a5bf0dc1fa /modules
parent16336ce0ca870013c43af04813621cbab5535b9e (diff)
parent162548a8795252d6383407744cb1311727684522 (diff)
Merge pull request #529 from chris5560/master
cbi: Implement "readonly" property for "Value"
Diffstat (limited to 'modules')
-rw-r--r--modules/luci-base/luasrc/cbi.lua5
-rw-r--r--modules/luci-base/luasrc/view/cbi/value.htm2
2 files changed, 6 insertions, 1 deletions
diff --git a/modules/luci-base/luasrc/cbi.lua b/modules/luci-base/luasrc/cbi.lua
index 1aa00eed9e..b5b2c8d8f2 100644
--- a/modules/luci-base/luasrc/cbi.lua
+++ b/modules/luci-base/luasrc/cbi.lua
@@ -1471,6 +1471,7 @@ function Value.__init__(self, ...)
self.template = "cbi/value"
self.keylist = {}
self.vallist = {}
+ self.readonly = nil
end
function Value.reset_values(self)
@@ -1484,6 +1485,10 @@ function Value.value(self, key, val)
table.insert(self.vallist, tostring(val))
end
+function Value.parse(self, section, novld)
+ if self.readonly then return end
+ AbstractValue.parse(self, section, novld)
+end
-- DummyValue - This does nothing except being there
DummyValue = class(AbstractValue)
diff --git a/modules/luci-base/luasrc/view/cbi/value.htm b/modules/luci-base/luasrc/view/cbi/value.htm
index d1a7bea5c6..6e05206aa1 100644
--- a/modules/luci-base/luasrc/view/cbi/value.htm
+++ b/modules/luci-base/luasrc/view/cbi/value.htm
@@ -1,7 +1,7 @@
<%+cbi/valueheader%>
<input type="<%=self.password and 'password" class="cbi-input-password' or 'text" class="cbi-input-text' %>" onchange="cbi_d_update(this.id)"<%=
attr("name", cbid) .. attr("id", cbid) .. attr("value", self:cfgvalue(section) or self.default) ..
- ifattr(self.size, "size") .. ifattr(self.placeholder, "placeholder")
+ ifattr(self.size, "size") .. ifattr(self.placeholder, "placeholder") .. ifattr(self.readonly, "readonly")
%> />
<% if self.password then %><img src="<%=resource%>/cbi/reload.gif" style="vertical-align:middle" title="<%:Reveal/hide password%>" onclick="var e = document.getElementById('<%=cbid%>'); e.type = (e.type=='password') ? 'text' : 'password';" /><% end %>
<% if #self.keylist > 0 or self.datatype then -%>