* CBI: Generalized templates
authorSteven Barth <steven@midlink.org>
Fri, 28 Mar 2008 11:00:58 +0000 (11:00 +0000)
committerSteven Barth <steven@midlink.org>
Fri, 28 Mar 2008 11:00:58 +0000 (11:00 +0000)
* admin > network > ifaces: Set default value for protocol allowing new sections to be created.

src/ffluci/model/cbi/admin_network/ifaces.lua
src/ffluci/view/cbi/fvalue.htm
src/ffluci/view/cbi/lvalue.htm
src/ffluci/view/cbi/mvalue.htm
src/ffluci/view/cbi/nsection.htm
src/ffluci/view/cbi/tsection.htm
src/ffluci/view/cbi/ucisection.htm [new file with mode: 0644]
src/ffluci/view/cbi/value.htm
src/ffluci/view/cbi/valuefooter.htm [new file with mode: 0644]
src/ffluci/view/cbi/valueheader.htm [new file with mode: 0644]

index 62e72462f877b6f8863c1f113955902c4ec5a860..aaabe653e4b592c6f24be459f16066527c3ac4f2 100644 (file)
@@ -10,6 +10,7 @@ s:depends("proto", "dhcp")
 p = s:option(ListValue, "proto", "Protokoll")
 p:value("static", "statisch")
 p:value("dhcp", "DHCP")
+p.default = "static"
 
 s:option(Value, "ifname", "Schnittstelle")
 
index cce116af333dc33dc6f9d8a18830e8a8f8a6456e..b609f1d4f45afdef9b4129632bf6092c47f9e02f 100644 (file)
@@ -1,11 +1,3 @@
-                                               <div class="cbi-value" id="cbi-<%=self.config.."-"..section.."-"..self.option%>">
-                                                       <div class="cbi-value-title left"><%=self.title%></div>
-                                                       <div class="cbi-value-field">
+<%+cbi/valueheader%>
                                                                <input onchange="cbi_d_update(this.id)" type="checkbox" id="cbid.<%=self.config.."."..section.."."..self.option%>" name="cbid.<%=self.config.."."..section.."."..self.option%>"<% if self:cfgvalue(section) == self.enabled then %> checked="checked"<% end %> value="1" />
-                                                               <div class="cbi-value-description inline"><%=self.description%></div>
-                                                       </div>
-                                               </div>
-                                               <% if #self.deps > 0 then %><script type="text/javascript">
-                                                       <% for j, d in ipairs(self.deps) do %>cbi_d_add("cbi-<%=self.config.."-"..section.."-"..self.option%>", "cbid.<%=self.config.."."..section.."."..d.field%>", "<%=d.value%>");
-                                                       <% end %>
-                                               </script><% end %>
\ No newline at end of file
+<%+cbi/valuefooter%>
\ No newline at end of file
index 943a18886a7949df13491793a9bb16572a3034e3..f1ae5a093900db90c816d219646ad805d5d413c0 100644 (file)
@@ -1,6 +1,4 @@
-                                               <div class="cbi-value" id="cbi-<%=self.config.."-"..section.."-"..self.option%>">
-                                                       <div class="cbi-value-title left"><%=self.title%></div>
-                                                       <div class="cbi-value-field">
+<%+cbi/valueheader%>
 <% if self.widget == "select" then %>
                                                                <select onchange="cbi_d_update(this.id)" id="cbid.<%=self.config.."."..section.."."..self.option%>" name="cbid.<%=self.config.."."..section.."."..self.option%>"<% if self.size then %> size="<%=self.size%>"<% end %>>
 <%for i, key in pairs(self.keylist) do%>
 <% if c == self.size then c = 0 %><br />
 <% end end %>
 <% end %>
-                                                               <div class="cbi-value-description inline"><%=self.description%></div>
-                                                       </div>
-                                               </div>
-                                               <% if #self.deps > 0 then %><script type="text/javascript">
-                                                       <% for j, d in ipairs(self.deps) do %>cbi_d_add("cbi-<%=self.config.."-"..section.."-"..self.option%>", "cbid.<%=self.config.."."..section.."."..d.field%>", "<%=d.value%>");
-                                                       <% end %>
-                                               </script><% end %>
\ No newline at end of file
+<%+cbi/valuefooter%>
\ No newline at end of file
index 7becb4f48b155dff858acc9bde8aa29c19b6cb29..97a1c4295aa7b06506839646eb6e499b764c8420 100644 (file)
@@ -1,9 +1,7 @@
 <%
 local v = self:valuelist(section)      
 %>
-                                               <div class="cbi-value" id="cbi-<%=self.config.."-"..section.."-"..self.option%>">
-                                                       <div class="cbi-value-title left"><%=self.title%></div>
-                                                       <div class="cbi-value-field">
+<%+cbi/valueheader%>
 <% if self.widget == "select" then %>
                                                                <select multiple="multiple" name="cbid.<%=self.config.."."..section.."."..self.option%>[]"<% if self.size then %> size="<%=self.size%>"<% end %>>
 <%for i, key in pairs(self.keylist) do %>
@@ -18,10 +16,4 @@ local v = self:valuelist(section)
 <% if c == self.size then c = 0 %><br />
 <% end end %>
 <% end %>
-                                                               <div class="cbi-value-description inline"><%=self.description%></div>
-                                                       </div>
-                                               </div>
-                                               <% if #self.deps > 0 then %><script type="text/javascript">
-                                                       <% for j, d in ipairs(self.deps) do %>cbi_d_add("cbi-<%=self.config.."-"..section.."-"..self.option%>", "cbid.<%=self.config.."."..section.."."..d.field%>", "<%=d.value%>");
-                                                       <% end %>
-                                               </script><% end %>
\ No newline at end of file
+<%+cbi/valuefooter%>
\ No newline at end of file
index 90dbb304145f3e41a9600b7e1b59a64e50bd422b..9c54a99429fc0eb0c8c97f977b30ecd2f949acac 100644 (file)
@@ -1,32 +1,12 @@
-<% if self:cfgvalue(self.section) then %>
-                               <div class="cbi-section" id="cbi-<%=self.config%>-<%=self.section%>">
+<% if self:cfgvalue(self.section) then
+section = self.section %>
+                               <div class="cbi-section" id="cbi-<%=self.config%>-<%=section%>">
                                        <h2><%=self.title%></h2>
                                        <div class="cbi-section-descr"><%=self.description%></div>
                                        <% if self.addremove then %><div class="cbi-section-remove">
-                                               <input type="submit" name="cbi.rns.<%=self.config%>.<%=self.section%>" value="<%:cbi_del Eintrag entfernen%>" />
+                                               <input type="submit" name="cbi.rns.<%=self.config%>.<%=section%>" value="<%:cbi_del Eintrag entfernen%>" />
                                        </div><% end %>
-                                       <fieldset class="cbi-section-node">
-<% self:render_children(self.section) %>
-                                       <% if #self.optionals[self.section] > 0 or self.dynamic then %>
-                                               <div class="cbi-optionals">
-                                                       <input type="submit" value="<%:cbi_addopt Feld hinzufügen%>" />
-                                               <% if self.dynamic then %>
-                                                       <input type="text" name="cbi.opt.<%=self.config%>.<%=self.section%>" />
-                                               <% else %>
-                                                       <select name="cbi.opt.<%=self.config%>.<%=self.section%>">
-                                                               <option><%:cbi_selopt *** Zusätzliche Parameter ***%></option>
-                                                       <% for key, val in pairs(self.optionals[self.section]) do %>
-                                                               <option id="cbi-<%=self.config.."-"..self.section.."-"..val.option%>" value="<%=val.option%>"><%=val.title%></option>
-                                                       <% end %>
-                                                       </select>
-                                                       <script type="text/javascript"><% for key, val in pairs(self.optionals[self.section]) do %>
-                                                               <% if #val.deps > 0 then %><% for j, d in ipairs(val.deps) do %>cbi_d_add("cbi-<%=self.config.."-"..self.section.."-"..val.option%>", "cbid.<%=self.config.."."..self.section.."."..d.field%>", "<%=d.value%>");
-                                                               <% end %><% end %>
-                                                       <% end %></script>
-                                               <% end %>
-                                               </div>
-                                       <% end %>
-                                       </fieldset>
+<%+cbi/ucisection%>
                                </div>
 <% elseif self.addremove then %>
                                <div class="cbi-section" id="cbi-<%=self.config%>-<%=self.section%>">
index ffeb91575b0f6abea3d1dc0301d538263fa624c3..012ae063a8052479f4b6a565aba0149e5c27ee56 100644 (file)
@@ -6,37 +6,16 @@
                                                        <input type="submit" name="cbi.rts.<%=self.config%>.<%=k%>" value="<%:cbi_del Eintrag entfernen%>" />
                                                </div><% end %>
                                                <% if not self.anonymous then %><h3><%=k%></h3><% end %>
-                                       <fieldset class="cbi-section-node" id="cbi-<%=self.config%>-<%=k%>">
-<% self:render_children(k) %>
-                                               <% if #self.optionals[k] > 0 or self.dynamic then %>
-                                                       <div class="cbi-optionals">
-                                                       <% if self.dynamic then %>
-                                                               <input type="text" name="cbi.opt.<%=self.config%>.<%=k%>" />
-                                                       <% else %>
-                                                               <select name="cbi.opt.<%=self.config%>.<%=k%>">
-                                                                       <option><%:cbi_addopt -- Feld --%></option>
-                                                               <% for key, val in pairs(self.optionals[k]) do %>
-                                                                       <option id="cbi-<%=self.config.."-"..k.."-"..val.option%>" value="<%=val.option%>"><%=val.title%></option>
-                                                               <% end %>
-                                                               </select>
-                                                               <script type="text/javascript"><% for key, val in pairs(self.optionals[k]) do %>
-                                                                       <% if #val.deps > 0 then %><% for j, d in ipairs(val.deps) do %>cbi_d_add("cbi-<%=self.config.."-"..k.."-"..val.option%>", "cbid.<%=self.config.."."..k.."."..d.field%>", "<%=d.value%>");
-                                                               <% end %><% end %>
-                                                               <% end %></script>
-                                                       <% end %>
-                                                               <input type="submit" value="<%:add hinzufügen%>" />
-                                                       </div>
-                                               <% end %>
-                                       </fieldset>
-                                       <br />
+<% section = k %>
+<%+cbi/ucisection%>
 <% 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 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>
 <% end %>
                                </div>
diff --git a/src/ffluci/view/cbi/ucisection.htm b/src/ffluci/view/cbi/ucisection.htm
new file mode 100644 (file)
index 0000000..ef1b6cb
--- /dev/null
@@ -0,0 +1,23 @@
+                                       <fieldset class="cbi-section-node" id="cbi-<%=self.config%>-<%=section%>">
+<% self:render_children(section) %>
+                                               <% if #self.optionals[section] > 0 or self.dynamic then %>
+                                                       <div class="cbi-optionals">
+                                                       <% if self.dynamic then %>
+                                                               <input type="text" name="cbi.opt.<%=self.config%>.<%=section%>" />
+                                                       <% else %>
+                                                               <select name="cbi.opt.<%=self.config%>.<%=section%>">
+                                                                       <option><%:cbi_addopt -- Feld --%></option>
+                                                               <% for key, val in pairs(self.optionals[section]) do %>
+                                                                       <option id="cbi-<%=self.config.."-"..section.."-"..val.option%>" value="<%=val.option%>"><%=val.title%></option>
+                                                               <% end %>
+                                                               </select>
+                                                               <script type="text/javascript"><% for key, val in pairs(self.optionals[section]) do %>
+                                                                       <% if #val.deps > 0 then %><% for j, d in ipairs(val.deps) do %>cbi_d_add("cbi-<%=self.config.."-"..section.."-"..val.option%>", "cbid.<%=self.config.."."..section.."."..d.field%>", "<%=d.value%>");
+                                                               <% end %><% end %>
+                                                               <% end %></script>
+                                                       <% end %>
+                                                               <input type="submit" value="<%:add hinzufügen%>" />
+                                                       </div>
+                                               <% end %>
+                                       </fieldset>
+                                       <br />
\ No newline at end of file
index d027bb448959394b787d77efa8e97103594f5c7c..b994790d2753498bf676fe166c989630a62ef3db 100644 (file)
@@ -1,12 +1,3 @@
-                                               <div class="cbi-value clear" id="cbi-<%=self.config.."-"..section.."-"..self.option%>">
-                                                       <div class="cbi-value-title left"><%=self.title%></div>
-                                                       <div class="cbi-value-field">
+<%+cbi/valueheader%>
                                                                <input type="text" onchange="cbi_d_update(this.id)" <% if self.size then %>size="<%=self.size%>" <% end %><% if self.maxlength then %>maxlength="<%=self.maxlength%>" <% end %>name="cbid.<%=self.config.."."..section.."."..self.option%>" value="<%=(self:cfgvalue(section) or "")%>" />
-                                                               <div class="cbi-value-description inline"><%=self.description%></div>
-                                                       </div>
-                                                       <% if self.tag_invalid[section] then %><div class="cbi-error"><%:cbi_invalid Fehler: Ungültige Eingabe%></div><% end %>
-                                               </div>
-                                               <% if #self.deps > 0 then %><script type="text/javascript">
-                                                       <% for j, d in ipairs(self.deps) do %>cbi_d_add("cbi-<%=self.config.."-"..section.."-"..self.option%>", "cbid.<%=self.config.."."..section.."."..d.field%>", "<%=d.value%>");
-                                                       <% end %>
-                                               </script><% end %>
+<%+cbi/valuefooter%>
diff --git a/src/ffluci/view/cbi/valuefooter.htm b/src/ffluci/view/cbi/valuefooter.htm
new file mode 100644 (file)
index 0000000..3f92f09
--- /dev/null
@@ -0,0 +1,8 @@
+                                                               <div class="cbi-value-description inline"><%=self.description%></div>
+                                                       </div>
+                                                       <% if self.tag_invalid[section] then %><div class="cbi-error"><%:cbi_invalid Fehler: Ungültige Eingabe%></div><% end %>
+                                               </div>
+                                               <% if #self.deps > 0 then %><script type="text/javascript">
+                                                       <% for j, d in ipairs(self.deps) do %>cbi_d_add("cbi-<%=self.config.."-"..section.."-"..self.option%>", "cbid.<%=self.config.."."..section.."."..d.field%>", "<%=d.value%>");
+                                                       <% end %>
+                                               </script><% end %>
\ No newline at end of file
diff --git a/src/ffluci/view/cbi/valueheader.htm b/src/ffluci/view/cbi/valueheader.htm
new file mode 100644 (file)
index 0000000..86c782d
--- /dev/null
@@ -0,0 +1,3 @@
+                                               <div class="cbi-value clear" id="cbi-<%=self.config.."-"..section.."-"..self.option%>">
+                                                       <div class="cbi-value-title left"><%=self.title%></div>
+                                                       <div class="cbi-value-field">
\ No newline at end of file