From 1999bfc06644450fd85f688807184194fb39ae28 Mon Sep 17 00:00:00 2001 From: Steven Barth Date: Fri, 19 Sep 2008 10:44:35 +0000 Subject: [PATCH] Overall CBI improvements: DummyValue handling, dependency conflicts, ... --- libs/cbi/htdocs/luci-static/resources/cbi.js | 6 ++---- libs/cbi/luasrc/cbi.lua | 16 +++++++++++++++- libs/cbi/luasrc/view/cbi/dvalue.htm | 9 +-------- libs/cbi/luasrc/view/cbi/ucisection.htm | 2 +- 4 files changed, 19 insertions(+), 14 deletions(-) diff --git a/libs/cbi/htdocs/luci-static/resources/cbi.js b/libs/cbi/htdocs/luci-static/resources/cbi.js index eb2420a1c1..2c7f99f062 100644 --- a/libs/cbi/htdocs/luci-static/resources/cbi.js +++ b/libs/cbi/htdocs/luci-static/resources/cbi.js @@ -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; diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua index 6432a2590d..d2de8685b5 100644 --- a/libs/cbi/luasrc/cbi.lua +++ b/libs/cbi/luasrc/cbi.lua @@ -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 diff --git a/libs/cbi/luasrc/view/cbi/dvalue.htm b/libs/cbi/luasrc/view/cbi/dvalue.htm index 88f38ca7b6..28cd9ab948 100644 --- a/libs/cbi/luasrc/view/cbi/dvalue.htm +++ b/libs/cbi/luasrc/view/cbi/dvalue.htm @@ -15,15 +15,8 @@ $Id$ <%+cbi/valueheader%> <% if self.href then %><% 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 %><%end%>   + <%+cbi/valuefooter%> diff --git a/libs/cbi/luasrc/view/cbi/ucisection.htm b/libs/cbi/luasrc/view/cbi/ucisection.htm index 5504a7476c..5d53436ce1 100644 --- a/libs/cbi/luasrc/view/cbi/ucisection.htm +++ b/libs/cbi/luasrc/view/cbi/ucisection.htm @@ -43,7 +43,7 @@ $Id$