luci-0.10: merge r6821 and r6822 (#199)

This commit is contained in:
Jo-Philipp Wich 2011-02-12 16:33:05 +00:00
parent 0b37d5908f
commit 39c2331d23
3 changed files with 19 additions and 23 deletions

View file

@ -51,6 +51,7 @@ AUTO = true
CREATE_PREFIX = "cbi.cts." CREATE_PREFIX = "cbi.cts."
REMOVE_PREFIX = "cbi.rts." REMOVE_PREFIX = "cbi.rts."
RESORT_PREFIX = "cbi.sts." RESORT_PREFIX = "cbi.sts."
FEXIST_PREFIX = "cbi.cbe."
-- Loads a CBI map from given file, creating an environment and returns it -- Loads a CBI map from given file, creating an environment and returns it
function load(cbimap, ...) function load(cbimap, ...)
@ -1481,29 +1482,31 @@ function Flag.__init__(self, ...)
AbstractValue.__init__(self, ...) AbstractValue.__init__(self, ...)
self.template = "cbi/fvalue" self.template = "cbi/fvalue"
self.enabled = "1" self.enabled = "1"
self.disabled = "0" self.disabled = "0"
self.default = self.disabled
end end
-- A flag can only have two states: set or unset -- A flag can only have two states: set or unset
function Flag.parse(self, section) function Flag.parse(self, section)
local fvalue = self:formvalue(section) local fexists = self.map:formvalue(
FEXIST_PREFIX .. self.config .. "." .. section .. "." .. self.option)
if fvalue then if fexists then
fvalue = self.enabled local fvalue = self:formvalue(section) and self.enabled or self.disabled
else if fvalue ~= self.default or (not self.optional and not self.rmempty) then
fvalue = self.disabled
end
if fvalue == self.enabled or (not self.optional and not self.rmempty) then
if not(fvalue == self:cfgvalue(section)) then
self:write(section, fvalue) self:write(section, fvalue)
else
self:remove(section)
end end
else else
self:remove(section) self:remove(section)
end end
end end
function Flag.cfgvalue(self, section)
return AbstractValue.cfgvalue(self, section) or self.default
end
--[[ --[[

View file

@ -13,6 +13,9 @@ $Id$
-%> -%>
<%+cbi/valueheader%> <%+cbi/valueheader%>
<input type="hidden" value="1"<%=
attr("name", "cbi.cbe." .. self.config .. "." .. section .. "." .. self.option)
%> />
<input class="cbi-input-checkbox" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)" type="checkbox"<%= <input class="cbi-input-checkbox" onclick="cbi_d_update(this.id)" onchange="cbi_d_update(this.id)" type="checkbox"<%=
attr("id", cbid) .. attr("name", cbid) .. attr("value", self.enabled or 1) .. attr("id", cbid) .. attr("name", cbid) .. attr("value", self.enabled or 1) ..
ifattr((self:cfgvalue(section) or self.default) == self.enabled, "checked", "checked") ifattr((self:cfgvalue(section) or self.default) == self.enabled, "checked", "checked")

View file

@ -398,10 +398,7 @@ if has_pptp or has_pppd or has_pppoe or has_pppoa or has_3g then
defaultroute:depends("proto", "pppoe") defaultroute:depends("proto", "pppoe")
defaultroute:depends("proto", "pptp") defaultroute:depends("proto", "pptp")
defaultroute:depends("proto", "3g") defaultroute:depends("proto", "3g")
defaultroute.rmempty = false defaultroute.default = defaultroute.enabled
function defaultroute.cfgvalue(...)
return ( AbstractValue.cfgvalue(...) or '1' )
end
peerdns = s:taboption("ppp", Flag, "peerdns", peerdns = s:taboption("ppp", Flag, "peerdns",
translate("Use peer DNS"), translate("Use peer DNS"),
@ -412,10 +409,7 @@ if has_pptp or has_pppd or has_pppoe or has_pppoa or has_3g then
peerdns:depends("proto", "pppoe") peerdns:depends("proto", "pppoe")
peerdns:depends("proto", "pptp") peerdns:depends("proto", "pptp")
peerdns:depends("proto", "3g") peerdns:depends("proto", "3g")
peerdns.rmempty = false peerdns.default = peerdns.enabled
function peerdns.cfgvalue(...)
return ( AbstractValue.cfgvalue(...) or '1' )
end
if has_ipv6 then if has_ipv6 then
ipv6 = s:taboption("ppp", Flag, "ipv6", translate("Enable IPv6 on PPP link") ) ipv6 = s:taboption("ppp", Flag, "ipv6", translate("Enable IPv6 on PPP link") )
@ -573,11 +567,7 @@ if has_dnsmasq then
translate("Dynamic <abbr title=\"Dynamic Host Configuration Protocol\">DHCP</abbr>"), translate("Dynamic <abbr title=\"Dynamic Host Configuration Protocol\">DHCP</abbr>"),
translate("Dynamically allocate DHCP addresses for clients. If disabled, only " .. translate("Dynamically allocate DHCP addresses for clients. If disabled, only " ..
"clients having static leases will be served.")) "clients having static leases will be served."))
dd.default = dd.enabled
dd.rmempty = false
function dd.cfgvalue(self, section)
return Flag.cfgvalue(self, section) or "1"
end
s:taboption("advanced", Flag, "force", translate("Force"), s:taboption("advanced", Flag, "force", translate("Force"),
translate("Force DHCP on this network even if another server is detected.")) translate("Force DHCP on this network even if another server is detected."))