summaryrefslogtreecommitdiffhomepage
path: root/libs
diff options
context:
space:
mode:
authorSteven Barth <steven@midlink.org>2008-09-13 12:20:39 +0000
committerSteven Barth <steven@midlink.org>2008-09-13 12:20:39 +0000
commitf9303705a0210a5c8dd7b44697c3ff31e1473b1a (patch)
tree6b3ea8bbbd3e80af625905c307233eb803e5acea /libs
parentb69589fba337ac9c362e02d58c354b2e218900c7 (diff)
Overall CBI-UVL ineraction fixes
Diffstat (limited to 'libs')
-rw-r--r--libs/cbi/luasrc/cbi.lua27
-rw-r--r--libs/uvl/luasrc/uvl.lua2
2 files changed, 21 insertions, 8 deletions
diff --git a/libs/cbi/luasrc/cbi.lua b/libs/cbi/luasrc/cbi.lua
index df7f29252..9e82ce9ce 100644
--- a/libs/cbi/luasrc/cbi.lua
+++ b/libs/cbi/luasrc/cbi.lua
@@ -75,6 +75,8 @@ function load(cbimap, ...)
if not instanceof(map, Node) then
error("CBI map returns no valid map object!")
return nil
+ else
+ map:prepare()
end
end
@@ -166,6 +168,13 @@ function Node._i18n(self, config, section, option, title, description)
end
end
+-- Prepare nodes
+function Node.prepare(self, ...)
+ for k, child in ipairs(self.children) do
+ child:prepare(...)
+ end
+end
+
-- Append child nodes
function Node.append(self, obj)
table.insert(self.children, obj)
@@ -870,7 +879,9 @@ function AbstractValue.__init__(self, map, section, option, ...)
self.default = nil
self.size = nil
self.optional = false
+end
+function AbstractValue.prepare(self)
-- Use defaults from UVL
if not self.override_scheme
and self.map:get_scheme(self.section.sectiontype, self.option) then
@@ -1099,23 +1110,23 @@ function ListValue.__init__(self, ...)
self.vallist = {}
self.size = 1
self.widget = "select"
+end
+function ListValue.prepare(self, ...)
+ AbstractValue.prepare(self, ...)
if not self.override_scheme
and self.map:get_scheme(self.section.sectiontype, self.option) then
local vs = self.map:get_scheme(self.section.sectiontype, self.option)
- if self.value and vs.values and not self.override_values then
- if self.rmempty or self.optional then
- self:value("")
- end
- for k, v in pairs(vs.values) do
+ if self.value and vs.valuelist and not self.override_values then
+ for k, v in ipairs(vs.valuelist) do
local deps = {}
if not self.override_dependencies
- and vs.enum_depends and vs.enum_depends[k] then
- for i, dep in ipairs(vs.enum_depends[k]) do
+ and vs.enum_depends and vs.enum_depends[v.value] then
+ for i, dep in ipairs(vs.enum_depends[v.value]) do
table.insert(deps, _uvl_strip_remote_dependencies(dep))
end
end
- self:value(k, v, unpack(deps))
+ self:value(v.value, v.title or v.value, unpack(deps))
end
end
end
diff --git a/libs/uvl/luasrc/uvl.lua b/libs/uvl/luasrc/uvl.lua
index c75b9bd7d..683d7a9bb 100644
--- a/libs/uvl/luasrc/uvl.lua
+++ b/libs/uvl/luasrc/uvl.lua
@@ -633,8 +633,10 @@ function UVL._parse_enum(self, scheme, k, v)
if not t.values then
t.values = { [v.value] = v.title or v.value }
+ t.valuelist = { {value = v.value, title = v.title} }
else
t.values[v.value] = v.title or v.value
+ t.valuelist[#t.valuelist + 1] = {value = v.value, title = v.title}
end
if not t.enum_depends then