diff options
author | Steven Barth <steven@midlink.org> | 2008-09-13 12:20:39 +0000 |
---|---|---|
committer | Steven Barth <steven@midlink.org> | 2008-09-13 12:20:39 +0000 |
commit | f9303705a0210a5c8dd7b44697c3ff31e1473b1a (patch) | |
tree | 6b3ea8bbbd3e80af625905c307233eb803e5acea /libs/cbi/luasrc/cbi.lua | |
parent | b69589fba337ac9c362e02d58c354b2e218900c7 (diff) |
Overall CBI-UVL ineraction fixes
Diffstat (limited to 'libs/cbi/luasrc/cbi.lua')
-rw-r--r-- | libs/cbi/luasrc/cbi.lua | 27 |
1 files changed, 19 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 |