summaryrefslogtreecommitdiffhomepage
path: root/libs/cbi
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-08-16 20:18:14 +0000
committerSteven Barth <steven@midlink.org>2008-08-16 20:18:14 +0000
commitd7b95a555baac0a815bfb8975648f7435c4a0754 (patch)
tree589eaddf1ed9b7647c7bf29dac9c5e9c104d33ef /libs/cbi
parent5237b79adfeaa49b23f6e95379d4e0861c153217 (diff)
Added process control page
Minor improvements
Diffstat (limited to 'libs/cbi')
-rw-r--r--libs/cbi/luasrc/cbi.lua43
-rw-r--r--libs/cbi/luasrc/view/cbi/button.htm17
-rw-r--r--libs/cbi/luasrc/view/cbi/cell_valuefooter.htm6
-rw-r--r--libs/cbi/luasrc/view/cbi/full_valuefooter.htm8
4 files changed, 62 insertions, 12 deletions
diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua
index 7e2f53c80..bf4bfb80c 100644
--- a/libs/cbi/luasrc/cbi.lua
+++ b/libs/cbi/luasrc/cbi.lua
@@ -287,7 +287,7 @@ function SimpleForm.parse(self, ...)
or valid and 1
or -1
- self.dorender = self:handle(state, self.data) ~= false
+ self.dorender = not self.handle or self:handle(state, self.data) ~= false
end
function SimpleForm.render(self, ...)
@@ -487,7 +487,11 @@ function Table.__init__(self, form, data, ...)
self.data = data
function datasource.get(self, section, option)
- return data[section][option]
+ return data[section] and data[section][option]
+ end
+
+ function datasource.del(...)
+ return true
end
AbstractSection.__init__(self, datasource, "table", ...)
@@ -496,10 +500,18 @@ function Table.__init__(self, form, data, ...)
self.anonymous = true
end
+function Table.parse(self)
+ for i, k in ipairs(self:cfgsections()) do
+ if luci.http.formvalue("cbi.submit") then
+ Node.parse(self, k)
+ end
+ end
+end
+
function Table.cfgsections(self)
local sections = {}
- for i, v in pairs(self.data) do
+ for i, v in luci.util.kspairs(self.data) do
table.insert(sections, i)
end
@@ -685,6 +697,7 @@ function AbstractValue.__init__(self, map, option, ...)
self.config = map.config
self.tag_invalid = {}
self.tag_missing = {}
+ self.tag_error = {}
self.deps = {}
self.track_missing = false
@@ -700,6 +713,11 @@ function AbstractValue.depends(self, field, value)
table.insert(self.deps, {field=field, value=value})
end
+-- Generates the unique CBID
+function AbstractValue.cbid(self, section)
+ return "cbid."..self.map.config.."."..section.."."..self.option
+end
+
-- Return whether this object should be created
function AbstractValue.formcreated(self, section)
local key = "cbi.opt."..self.config.."."..section
@@ -708,8 +726,7 @@ end
-- Returns the formvalue for this object
function AbstractValue.formvalue(self, section)
- local key = "cbid."..self.map.config.."."..section.."."..self.option
- return luci.http.formvalue(key)
+ return luci.http.formvalue(self:cbid(section))
end
function AbstractValue.additional(self, value)
@@ -746,9 +763,7 @@ function AbstractValue.render(self, s, scope)
if not self.optional or self:cfgvalue(s) or self:formcreated(s) then
scope = scope or {}
scope.section = s
- scope.cbid = "cbid." .. self.config ..
- "." .. s ..
- "." .. self.option
+ scope.cbid = self:cbid(s)
scope.ifattr = function(cond,key,val)
if cond then
@@ -965,3 +980,15 @@ function TextValue.__init__(self, ...)
AbstractValue.__init__(self, ...)
self.template = "cbi/tvalue"
end
+
+--[[
+Button
+]]--
+Button = class(AbstractValue)
+
+function Button.__init__(self, ...)
+ AbstractValue.__init__(self, ...)
+ self.template = "cbi/button"
+ self.inputstyle = nil
+ self.rmempty = true
+end \ No newline at end of file
diff --git a/libs/cbi/luasrc/view/cbi/button.htm b/libs/cbi/luasrc/view/cbi/button.htm
new file mode 100644
index 000000000..2d740f45c
--- /dev/null
+++ b/libs/cbi/luasrc/view/cbi/button.htm
@@ -0,0 +1,17 @@
+<%#
+LuCI - Lua Configuration Interface
+Copyright 2008 Steven Barth <steven@midlink.org>
+Copyright 2008 Jo-Philipp Wich <xm@leipzig.freifunk.net>
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+$Id$
+
+-%>
+<%+cbi/valueheader%>
+ <input<% if self.inputstyle then %> class="cbi-input-<%=self.inputstyle%>"<% end %> type="submit"<%= attr("name", cbid) .. attr("id", cbid) .. attr("value", self.title) %> />
+<%+cbi/valuefooter%>
diff --git a/libs/cbi/luasrc/view/cbi/cell_valuefooter.htm b/libs/cbi/luasrc/view/cbi/cell_valuefooter.htm
index fbe266ebe..941214246 100644
--- a/libs/cbi/luasrc/view/cbi/cell_valuefooter.htm
+++ b/libs/cbi/luasrc/view/cbi/cell_valuefooter.htm
@@ -13,8 +13,12 @@ $Id$
-%>
- <% if self.tag_invalid[section] then -%>
+ <% if self.tag_error[section] then -%>
+ <div class="cbi-error"><%=self.tag_error[section]%></div>
+ <%- elseif self.tag_invalid[section] then -%>
<div class="cbi-error"><%:cbi_invalid%></div>
+ <%- elseif self.tag_missing[section] then -%>
+ <div class="cbi-error"><%:cbi_missing%></div>
<%- end %>
</td>
diff --git a/libs/cbi/luasrc/view/cbi/full_valuefooter.htm b/libs/cbi/luasrc/view/cbi/full_valuefooter.htm
index a5a6046a5..5a52898d1 100644
--- a/libs/cbi/luasrc/view/cbi/full_valuefooter.htm
+++ b/libs/cbi/luasrc/view/cbi/full_valuefooter.htm
@@ -21,12 +21,14 @@ $Id$
</div>
<%- end -%>
- <% if self.tag_invalid[section] then -%>
+ <% if self.tag_error[section] then -%>
+ <div class="cbi-error"><%=self.tag_error[section]%></div>
+ <%- elseif self.tag_invalid[section] then -%>
<div class="cbi-error"><%:cbi_invalid%></div>
- <%- end %>
- <% if self.tag_missing[section] then -%>
+ <%- elseif self.tag_missing[section] then -%>
<div class="cbi-error"><%:cbi_missing%></div>
<%- end %>
+
</div>
<% if #self.deps > 0 then -%>