* core: Added template for a table view of typed sections
authorSteven Barth <steven@midlink.org>
Wed, 14 May 2008 12:10:44 +0000 (12:10 +0000)
committerSteven Barth <steven@midlink.org>
Wed, 14 May 2008 12:10:44 +0000 (12:10 +0000)
applications/luci-fw/src/model/cbi/admin_network/portfw.lua
core/src/cbi.lua
core/src/view/cbi/nsection.htm
core/src/view/cbi/tblsection.htm [new file with mode: 0644]
core/src/view/cbi/tsection.htm
core/src/view/cbi/ucisection.htm
core/src/view/cbi/valuefooter.htm
core/src/view/cbi/valueheader.htm
core/src/view/header.htm
modules/admin-core/src/model/cbi/admin_network/routes.lua
themes/fledermaus/root/www/ffluci/media/cascade.css

index 96822b53a23de3a22f532545e409e745abd4ecd8..5ee22336e7afeebb1132585616e729cd16b2f3dd 100644 (file)
@@ -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)
index 3384e5c38ad64fb604b3858ecbf63c0b12f017cd..8a623b62c953fa127b4be559cd86008b761ccf05 100644 (file)
@@ -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
 
index bbc87f1858a8d01c9f087c74bee49bfa07d6e2ba..fff597ad065c3f6a2734aaec0d89215352f6680d 100644 (file)
@@ -6,7 +6,10 @@ section = self.section %>
                                        <% if self.addremove then %><div class="cbi-section-remove right">
                                                <input type="submit" name="cbi.rns.<%=self.config%>.<%=section%>" value="<%:cbi_del Eintrag entfernen%>" />
                                        </div><% end %>
+<div class="cbi-section-node" id="cbi-<%=self.config%>-<%=section%>">
 <%+cbi/ucisection%>
+</div>
+<br />
                                </div>
 <% elseif self.addremove then %>
                                <div class="cbi-section" id="cbi-<%=self.config%>-<%=self.section%>">
diff --git a/core/src/view/cbi/tblsection.htm b/core/src/view/cbi/tblsection.htm
new file mode 100644 (file)
index 0000000..df16efb
--- /dev/null
@@ -0,0 +1,39 @@
+                               <div class="cbi-section" id="cbi-<%=self.config%>-<%=self.sectiontype%>">
+                                       <h2><%=self.title%></h2>
+                                       <div class="cbi-section-descr"><%=self.description%></div>
+                                       <div class="cbi-section-node">
+                                               <div class="cbi-section-row">
+<% for i, k in pairs(self.children) do %>
+                                               <div class="cbi-section-row-head"><%=k.title%></div>                    
+<% end %>
+                                               </div>
+                                               <div class="cbi-section-row">
+<% for i, k in pairs(self.children) do %>
+                                               <div class="cbi-section-row-descr"><%=k.description%></div>                     
+<% end %>
+                                               </div>
+<% for i, k in ipairs(self:cfgsections()) do%>
+                                               <% if not self.anonymous then %><h3 class="table-cell"><%=k%></h3><% end %>
+<%
+section = k 
+scope = {valueheader = "cbi/tiny_valueheader", valuefooter = "cbi/tiny_valuefooter"}
+%>
+<div class="cbi-section-row" id="cbi-<%=self.config%>-<%=section%>">
+<%+cbi/ucisection%>
+                                               <% if self.addremove then %><div class="cbi-section-remove table-cell">
+                                                       <input type="submit" name="cbi.rts.<%=self.config%>.<%=k%>" value="X" />
+                                               </div><% end %>
+</div>
+<% end %>
+<% if self.addremove then %>
+                                       <div class="cbi-section-create">
+                                               <% if self.anonymous then %>
+                                                       <input type="submit" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" value="<%:cbi_add Eintrag hinzufügen%>" />
+                                               <% else %>
+                                                       <input type="text" class="cbi-section-create-name" name="cbi.cts.<%=self.config%>.<%=self.sectiontype%>" />
+                                                       <input type="submit" value="<%:cbi_add Eintrag hinzufügen%>" />
+                                               <% end %><% if self.err_invalid then %><div class="cbi-error"><%:cbi_invalid Fehler: Ungültige Eingabe%></div><% end %>
+                                       </div>
+                                       </div>
+<% end %>
+                               </div>
index 666c14b2e61108708190d4192bcd6716284717c3..37b18b5d42b1acce9d2d61709008d53c8d6608a0 100644 (file)
@@ -7,7 +7,10 @@
                                                </div><% end %>
                                                <% if not self.anonymous then %><h3><%=k%></h3><% end %>
 <% section = k %>
+<div class="cbi-section-node" id="cbi-<%=self.config%>-<%=section%>">
 <%+cbi/ucisection%>
+</div>
+<br />
 <% end %>
 <% if self.addremove then %>
                                        <div class="cbi-section-create">
index a1fb39cf45f00508e60560fdceb19a7e80439d05..0abc37e7c63a80c15473bc58b509f6a73164301e 100644 (file)
@@ -1,5 +1,4 @@
-                                       <div class="cbi-section-node" id="cbi-<%=self.config%>-<%=section%>">
-<% self:render_children(section) %>
+<% self:render_children(section, scope or {}) %>
                                                <% if #self.optionals[section] > 0 or self.dynamic then %>
                                                        <div class="cbi-optionals">
                                                        <% if self.dynamic then %>
@@ -18,6 +17,4 @@
                                                        <% end %>
                                                                <input type="submit" value="<%:add hinzufügen%>" />
                                                        </div>
-                                               <% end %>
-                                       </div>
-                                       <br />
\ No newline at end of file
+                                               <% end %>
\ No newline at end of file
index 99de567e0345fc7d3f4a5bb38956fc2988c476d8..bc9d1b127ac57766e834c553ba1f6e31de287aa8 100644 (file)
@@ -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
index 3b7dd5b8208d4df11847742c5b5ed81c86d869b4..8d9802f57fba99d3c1beffa07354541ecdc71174 100644 (file)
@@ -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
index bc65e3e8910e129b2f7322d7239fb8cce588a062..9bb8b8be993c92b23991f7d73839fd3fcf8713e5 100644 (file)
@@ -12,6 +12,7 @@ require("ffluci.http").prepare_content("text/html")
 <head>
        <link rel="stylesheet" type="text/css" href="<%=media%>/cascade.css" />
        <link rel="stylesheet" type="text/css" href="<%=media%>/css/<%=req.category%>_<%=req.module%>.css" />
+       <link rel="stylesheet" type="text/css" href="<%=media%>/css/<%=req.category%>_<%=req.module%>_<%=req.action%>.css" />
        <meta http-equiv="content-type" content="text/xhtml+xml; charset=utf-8" />
        <meta http-equiv="content-script-type" content="text/javascript" />
        <title>FFLuCI</title>
index 49e43218045976754c0a5b5001e270d92bac8f54..ed3838ca5bd7c31999d61c59b4db2bf3012fd71b 100644 (file)
@@ -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
index 9dc24c3dd3166d7beb1c69b32ff43b01a54a07ff..5920254c7813c24e159a89763d10bcf0ef3ca9bf 100644 (file)
@@ -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 {