From: Steven Barth Date: Wed, 14 May 2008 12:10:44 +0000 (+0000) Subject: * core: Added template for a table view of typed sections X-Git-Tag: 0.8.0~1038 X-Git-Url: https://git.archive.openwrt.org/?p=project%2Fluci.git;a=commitdiff_plain;h=3f4f75b1079eb1ea29b6c2fde9a3dd25c52f2fe4 * core: Added template for a table view of typed sections --- diff --git a/applications/luci-fw/src/model/cbi/admin_network/portfw.lua b/applications/luci-fw/src/model/cbi/admin_network/portfw.lua index 96822b53a..5ee22336e 100644 --- a/applications/luci-fw/src/model/cbi/admin_network/portfw.lua +++ b/applications/luci-fw/src/model/cbi/admin_network/portfw.lua @@ -4,10 +4,11 @@ m = Map("luci_fw", "Portweiterleitung", [[Portweiterleitungen ermöglichen es in Netzwerkdienste von einem anderen externen Netzwerk aus erreichbar zu machen.]]) s = m:section(TypedSection, "portfw") +s.template = "cbi/tblsection" s.addremove = true s.anonymous = true -iface = s:option(ListValue, "iface", "Externes Interface") +iface = s:option(ListValue, "iface", "Schnittstelle", "Externe Schnittstelle") iface:value("") for k,v in pairs(ffluci.sys.net.devices()) do iface:value(v) diff --git a/core/src/cbi.lua b/core/src/cbi.lua index 3384e5c38..8a623b62c 100644 --- a/core/src/cbi.lua +++ b/core/src/cbi.lua @@ -87,8 +87,11 @@ function Node.parse(self, ...) end -- Render this node -function Node.render(self) - ffluci.template.render(self.template, {self=self}) +function Node.render(self, scope) + scope = scope or {} + scope.self = self + + ffluci.template.render(self.template, scope) end -- Render the children @@ -453,13 +456,6 @@ function TypedSection.parse(self) end end --- Render the children -function TypedSection.render_children(self, section) - for k, node in ipairs(self.children) do - node:render(section) - end -end - -- Verifies scope of sections function TypedSection.checkscope(self, section) -- Check if we are not excluded @@ -554,9 +550,11 @@ function AbstractValue.parse(self, section) end -- Render if this value exists or if it is mandatory -function AbstractValue.render(self, s) +function AbstractValue.render(self, s, scope) if not self.optional or self:cfgvalue(s) or self:formcreated(s) then - ffluci.template.render(self.template, {self=self, section=s}) + scope = scope or {} + scope.section = s + Node.render(self, scope) end end diff --git a/core/src/view/cbi/nsection.htm b/core/src/view/cbi/nsection.htm index bbc87f185..fff597ad0 100644 --- a/core/src/view/cbi/nsection.htm +++ b/core/src/view/cbi/nsection.htm @@ -6,7 +6,10 @@ section = self.section %> <% if self.addremove then %>
<% end %> +
<%+cbi/ucisection%> +
+
<% elseif self.addremove then %>
diff --git a/core/src/view/cbi/tblsection.htm b/core/src/view/cbi/tblsection.htm new file mode 100644 index 000000000..df16efbed --- /dev/null +++ b/core/src/view/cbi/tblsection.htm @@ -0,0 +1,39 @@ +
+

<%=self.title%>

+
<%=self.description%>
+
+
+<% for i, k in pairs(self.children) do %> +
<%=k.title%>
+<% end %> +
+
+<% for i, k in pairs(self.children) do %> +
<%=k.description%>
+<% end %> +
+<% for i, k in ipairs(self:cfgsections()) do%> + <% if not self.anonymous then %>

<%=k%>

<% end %> +<% +section = k +scope = {valueheader = "cbi/tiny_valueheader", valuefooter = "cbi/tiny_valuefooter"} +%> +
+<%+cbi/ucisection%> + <% if self.addremove then %>
+ +
<% end %> +
+<% end %> +<% if self.addremove then %> +
+ <% if self.anonymous then %> + + <% else %> + + + <% end %><% if self.err_invalid then %>
<%:cbi_invalid Fehler: Ungültige Eingabe%>
<% end %> +
+
+<% end %> +
diff --git a/core/src/view/cbi/tsection.htm b/core/src/view/cbi/tsection.htm index 666c14b2e..37b18b5d4 100644 --- a/core/src/view/cbi/tsection.htm +++ b/core/src/view/cbi/tsection.htm @@ -7,7 +7,10 @@
<% end %> <% if not self.anonymous then %>

<%=k%>

<% end %> <% section = k %> +
<%+cbi/ucisection%> +
+
<% end %> <% if self.addremove then %>
diff --git a/core/src/view/cbi/ucisection.htm b/core/src/view/cbi/ucisection.htm index a1fb39cf4..0abc37e7c 100644 --- a/core/src/view/cbi/ucisection.htm +++ b/core/src/view/cbi/ucisection.htm @@ -1,5 +1,4 @@ -
-<% self:render_children(section) %> +<% self:render_children(section, scope or {}) %> <% if #self.optionals[section] > 0 or self.dynamic then %>
<% if self.dynamic then %> @@ -18,6 +17,4 @@ <% end %>
- <% end %> -
-
\ No newline at end of file + <% end %> \ No newline at end of file diff --git a/core/src/view/cbi/valuefooter.htm b/core/src/view/cbi/valuefooter.htm index 99de567e0..bc9d1b127 100644 --- a/core/src/view/cbi/valuefooter.htm +++ b/core/src/view/cbi/valuefooter.htm @@ -1,7 +1,5 @@ -<% -if self.tiny then - include("cbi/tiny_valuefooter") +<% if valuefooter then + include(valuefooter) else include("cbi/full_valuefooter") -end -%> \ No newline at end of file +end %> \ No newline at end of file diff --git a/core/src/view/cbi/valueheader.htm b/core/src/view/cbi/valueheader.htm index 3b7dd5b82..8d9802f57 100644 --- a/core/src/view/cbi/valueheader.htm +++ b/core/src/view/cbi/valueheader.htm @@ -1,7 +1,5 @@ -<% -if self.tiny then - include("cbi/tiny_valueheader") +<% if valueheader then + include(valueheader) else include("cbi/full_valueheader") -end -%> \ No newline at end of file +end %> \ No newline at end of file diff --git a/core/src/view/header.htm b/core/src/view/header.htm index bc65e3e89..9bb8b8be9 100644 --- a/core/src/view/header.htm +++ b/core/src/view/header.htm @@ -12,6 +12,7 @@ require("ffluci.http").prepare_content("text/html") + FFLuCI diff --git a/modules/admin-core/src/model/cbi/admin_network/routes.lua b/modules/admin-core/src/model/cbi/admin_network/routes.lua index 49e432180..ed3838ca5 100644 --- a/modules/admin-core/src/model/cbi/admin_network/routes.lua +++ b/modules/admin-core/src/model/cbi/admin_network/routes.lua @@ -6,6 +6,7 @@ oder ein bestimmtes Netzwerk erreicht werden kann.]]) s = m:section(TypedSection, "route") s.addremove = true s.anonymous = true +s.template = "cbi/tblsection" iface = s:option(ListValue, "interface", "Schnittstelle") for k, v in pairs(ffluci.model.uci.sections("network")) do diff --git a/themes/fledermaus/root/www/ffluci/media/cascade.css b/themes/fledermaus/root/www/ffluci/media/cascade.css index 9dc24c3dd..5920254c7 100644 --- a/themes/fledermaus/root/www/ffluci/media/cascade.css +++ b/themes/fledermaus/root/www/ffluci/media/cascade.css @@ -143,6 +143,18 @@ h3 { margin-top: 0%; } +.table { + display: table; +} + +.table-row { + display: table-row; +} + +.table-cell { + display: table-cell; +} + .left { float: left; text-align: left; @@ -165,18 +177,6 @@ h3 { display: inline; } -.table { - display: table; -} - -.table-cell { - display: table-cell; -} - -.table-row { - display: table-row; -} - .code { background: #f7f7f7; border: 1px solid #d7d7d7; @@ -256,6 +256,22 @@ table th, table, td { border: 1px solid #d7d7d7; } +.cbi-section-row { + display: table-row; +} + +.cbi-section-row-head { + display: table-cell; + font-weight: bold; + padding: 0.25em; +} + +.cbi-section-row-descr { + display: table-cell; + padding: 0.25em; + font-size: 0.8em; +} + .cbi-section-node h3 { margin-bottom: 0.5em; } @@ -269,6 +285,7 @@ table th, table, td { .cbi-optionals { margin-top: 1em; + display: table-cell; } .cbi-optionals option {