From: Steven Barth Date: Sat, 13 Sep 2008 12:20:39 +0000 (+0000) Subject: Overall CBI-UVL ineraction fixes X-Git-Tag: 0.9.0~1328 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=f9303705a0210a5c8dd7b44697c3ff31e1473b1a;p=oweals%2Fluci.git Overall CBI-UVL ineraction fixes --- 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 diff --git a/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua b/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua index 44f0a4f7b..0f99c6ec0 100644 --- a/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua +++ b/modules/admin-full/luasrc/model/cbi/admin_network/wifi.lua @@ -236,6 +236,7 @@ end ------------------- WiFI-Encryption ------------------- encr = s:option(ListValue, "encryption", translate("encryption")) +encr.override_values = true encr:depends({mode="ap"}) encr:depends({mode="sta"}) encr:depends({mode="adhoc"}) diff --git a/modules/admin-mini/luasrc/model/cbi/mini/wifi.lua b/modules/admin-mini/luasrc/model/cbi/mini/wifi.lua index cbf3d6a25..13ae997fb 100644 --- a/modules/admin-mini/luasrc/model/cbi/mini/wifi.lua +++ b/modules/admin-mini/luasrc/model/cbi/mini/wifi.lua @@ -141,6 +141,7 @@ local hwtype = m:get(wifidevs[1], "type") if hwtype == "atheros" then mode = s:option(ListValue, "mode", translate("mode")) + mode.override_values = true mode:value("", "auto") mode:value("11b", "802.11b") mode:value("11g", "802.11g") @@ -206,6 +207,7 @@ function mode.write(self, section, value) end encr = s:option(ListValue, "encryption", translate("encryption")) +encr.override_values = true encr:value("none", "No Encryption") encr:value("wep", "WEP")