Overall CBI improvements: DummyValue handling, dependency conflicts, ...
authorSteven Barth <steven@midlink.org>
Fri, 19 Sep 2008 10:44:35 +0000 (10:44 +0000)
committerSteven Barth <steven@midlink.org>
Fri, 19 Sep 2008 10:44:35 +0000 (10:44 +0000)
libs/cbi/htdocs/luci-static/resources/cbi.js
libs/cbi/luasrc/cbi.lua
libs/cbi/luasrc/view/cbi/dvalue.htm
libs/cbi/luasrc/view/cbi/ucisection.htm

index eb2420a1c1a27b0947221da8374b9ae65d90f54e..2c7f99f0624dfeb9f1fc43d9d9f07d8d0332bb0b 100644 (file)
@@ -26,11 +26,9 @@ function cbi_d_add(field, dep, next) {
 
 function cbi_d_checkvalue(target, ref) {
        var t = document.getElementById(target);
-       var value
+       var value;
        
-       if (!t) {
-               return true
-       } else if (!t.value) {
+       if (!t || !t.value) {
                value = "";
        } else {
                value = t.value;
index 6432a2590d034782121e85d14b144e6905511cf5..d2de8685b5303c9e8a56c039df8ac9e2829ea608 100644 (file)
@@ -1011,7 +1011,7 @@ function AbstractValue.cfgvalue(self, section)
                        return value[1]
                end
        elseif self.cast == "table" then
-               return {value}
+               return luci.util.split(value, "%s+", nil, true)
        end
 end
 
@@ -1065,6 +1065,20 @@ function DummyValue.__init__(self, ...)
        self.value = nil
 end
 
+function DummyValue.cfgvalue(self, section)
+       local value
+       if self.value then
+               if type(self.value) == "function" then
+                       value = self:value(section)
+               else
+                       value = self.value
+               end
+       else
+               value = AbstractValue.cfgvalue(self, section)
+       end
+       return value
+end
+
 function DummyValue.parse(self)
 
 end
index 88f38ca7b6e064e860e6283cb66323a3ed0c6216..28cd9ab948fdc50e9ac2541dfb1342a6b35fd428 100644 (file)
@@ -15,15 +15,8 @@ $Id$
 
 <%+cbi/valueheader%>
 <% if self.href then %><a href="<%=self.href%>"><% end -%>
-<%- if self.value then
-       if type(self.value) == "function" then %>
-       <%=luci.util.pcdata(self:value(section))%>
-<% else %>
-       <%=luci.util.pcdata(self.value)%>
-<%     end
-else %>
        <%=luci.util.pcdata(self:cfgvalue(section))%>
-<% end -%>
 <%- if self.href then %></a><%end%>
 &#160;
+<input type="hidden" id="<%=cbid%>" value="<%=luci.util.pcdata(self:cfgvalue(section))%>" />
 <%+cbi/valuefooter%>
index 5504a7476c562db0cd9ed2ca580d11212a20a9d6..5d53436ce1106944654af1c8f6de3cde4f36f7b3 100644 (file)
@@ -43,7 +43,7 @@ $Id$
                <select id="cbi.opt.<%=self.config%>.<%=section%>" name="cbi.opt.<%=self.config%>.<%=section%>">
                        <option><%:cbi_addopt%></option>
                        <% for key, val in pairs(self.optionals[section]) do -%>
-                               <option id="cbi-<%=self.config.."-"..section.."-"..val.option%>" value="<%=val.option%>"><%=striptags(val.title)%></option>
+                               <option id="cbid-<%=self.config.."-"..section.."-"..val.option%>" value="<%=val.option%>"><%=striptags(val.title)%></option>
                        <%- end %>
                </select>
                <script type="text/javascript"><% for key, val in pairs(self.optionals[section]) do %>