From fb2a9a328d619ecf329e64cb500ff1385e3f8290 Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Fri, 28 Mar 2008 11:00:58 +0000 Subject: [PATCH] * CBI: Generalized templates * admin > network > ifaces: Set default value for protocol allowing new sections to be created. --- src/ffluci/model/cbi/admin_network/ifaces.lua | 1 + src/ffluci/view/cbi/fvalue.htm | 12 +----- src/ffluci/view/cbi/lvalue.htm | 12 +----- src/ffluci/view/cbi/mvalue.htm | 12 +----- src/ffluci/view/cbi/nsection.htm | 30 +++----------- src/ffluci/view/cbi/tsection.htm | 39 +++++-------------- src/ffluci/view/cbi/ucisection.htm | 23 +++++++++++ src/ffluci/view/cbi/value.htm | 13 +------ src/ffluci/view/cbi/valuefooter.htm | 8 ++++ src/ffluci/view/cbi/valueheader.htm | 3 ++ 10 files changed, 57 insertions(+), 96 deletions(-) create mode 100644 src/ffluci/view/cbi/ucisection.htm create mode 100644 src/ffluci/view/cbi/valuefooter.htm create mode 100644 src/ffluci/view/cbi/valueheader.htm diff --git a/src/ffluci/model/cbi/admin_network/ifaces.lua b/src/ffluci/model/cbi/admin_network/ifaces.lua index 62e72462f8..aaabe653e4 100644 --- a/src/ffluci/model/cbi/admin_network/ifaces.lua +++ b/src/ffluci/model/cbi/admin_network/ifaces.lua @@ -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") diff --git a/src/ffluci/view/cbi/fvalue.htm b/src/ffluci/view/cbi/fvalue.htm index cce116af33..b609f1d4f4 100644 --- a/src/ffluci/view/cbi/fvalue.htm +++ b/src/ffluci/view/cbi/fvalue.htm @@ -1,11 +1,3 @@ -
"> -
<%=self.title%>
-
+<%+cbi/valueheader%> " name="cbid.<%=self.config.."."..section.."."..self.option%>"<% if self:cfgvalue(section) == self.enabled then %> checked="checked"<% end %> value="1" /> -
<%=self.description%>
-
-
- <% if #self.deps > 0 then %><% end %> \ No newline at end of file +<%+cbi/valuefooter%> \ No newline at end of file diff --git a/src/ffluci/view/cbi/lvalue.htm b/src/ffluci/view/cbi/lvalue.htm index 943a18886a..f1ae5a0939 100644 --- a/src/ffluci/view/cbi/lvalue.htm +++ b/src/ffluci/view/cbi/lvalue.htm @@ -1,6 +1,4 @@ -
"> -
<%=self.title%>
-
+<%+cbi/valueheader%> <% if self.widget == "select" then %> []"<% 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 %>
<% end end %> <% end %> -
<%=self.description%>
-
-
- <% if #self.deps > 0 then %><% end %> \ No newline at end of file +<%+cbi/valuefooter%> \ No newline at end of file diff --git a/src/ffluci/view/cbi/nsection.htm b/src/ffluci/view/cbi/nsection.htm index 90dbb30414..9c54a99429 100644 --- a/src/ffluci/view/cbi/nsection.htm +++ b/src/ffluci/view/cbi/nsection.htm @@ -1,32 +1,12 @@ -<% if self:cfgvalue(self.section) then %> -
+<% if self:cfgvalue(self.section) then +section = self.section %> +

<%=self.title%>

<%=self.description%>
<% if self.addremove then %>
- +
<% end %> -
-<% self:render_children(self.section) %> - <% if #self.optionals[self.section] > 0 or self.dynamic then %> -
- - <% if self.dynamic then %> - - <% else %> - - - <% end %> -
- <% end %> -
+<%+cbi/ucisection%>
<% elseif self.addremove then %>
diff --git a/src/ffluci/view/cbi/tsection.htm b/src/ffluci/view/cbi/tsection.htm index ffeb91575b..012ae063a8 100644 --- a/src/ffluci/view/cbi/tsection.htm +++ b/src/ffluci/view/cbi/tsection.htm @@ -6,37 +6,16 @@
<% end %> <% if not self.anonymous then %>

<%=k%>

<% end %> -
-<% self:render_children(k) %> - <% if #self.optionals[k] > 0 or self.dynamic then %> -
- <% if self.dynamic then %> - - <% else %> - - - <% end %> - -
- <% end %> -
-
+<% section = k %> +<%+cbi/ucisection%> <% end %> <% if self.addremove then %> -
- <% if self.anonymous then %> - - <% else %> - - <% end %><% if self.err_invalid then %>
<%:cbi_invalid Fehler: Ungültige Eingabe%>
<% end %> -
+
+ <% if self.anonymous then %> + + <% else %> + + <% end %><% if self.err_invalid then %>
<%:cbi_invalid Fehler: Ungültige Eingabe%>
<% end %> +
<% end %>
diff --git a/src/ffluci/view/cbi/ucisection.htm b/src/ffluci/view/cbi/ucisection.htm new file mode 100644 index 0000000000..ef1b6cb0e1 --- /dev/null +++ b/src/ffluci/view/cbi/ucisection.htm @@ -0,0 +1,23 @@ +
+<% self:render_children(section) %> + <% if #self.optionals[section] > 0 or self.dynamic then %> +
+ <% if self.dynamic then %> + + <% else %> + + + <% end %> + +
+ <% end %> +
+
\ No newline at end of file diff --git a/src/ffluci/view/cbi/value.htm b/src/ffluci/view/cbi/value.htm index d027bb4489..b994790d27 100644 --- a/src/ffluci/view/cbi/value.htm +++ b/src/ffluci/view/cbi/value.htm @@ -1,12 +1,3 @@ -
"> -
<%=self.title%>
-
+<%+cbi/valueheader%> size="<%=self.size%>" <% end %><% if self.maxlength then %>maxlength="<%=self.maxlength%>" <% end %>name="cbid.<%=self.config.."."..section.."."..self.option%>" value="<%=(self:cfgvalue(section) or "")%>" /> -
<%=self.description%>
-
- <% if self.tag_invalid[section] then %>
<%:cbi_invalid Fehler: Ungültige Eingabe%>
<% end %> -
- <% if #self.deps > 0 then %><% end %> +<%+cbi/valuefooter%> diff --git a/src/ffluci/view/cbi/valuefooter.htm b/src/ffluci/view/cbi/valuefooter.htm new file mode 100644 index 0000000000..3f92f09e26 --- /dev/null +++ b/src/ffluci/view/cbi/valuefooter.htm @@ -0,0 +1,8 @@ +
<%=self.description%>
+ + <% if self.tag_invalid[section] then %>
<%:cbi_invalid Fehler: Ungültige Eingabe%>
<% end %> + + <% if #self.deps > 0 then %><% 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 index 0000000000..86c782d711 --- /dev/null +++ b/src/ffluci/view/cbi/valueheader.htm @@ -0,0 +1,3 @@ +
"> +
<%=self.title%>
+
\ No newline at end of file -- 2.30.2