Correctly set status FORM_PROCEED instead of FORM_CHANGED if user
creates / deletes a field or section
This commit is contained in:
parent
a5ffc64063
commit
b9fbed39ca
1 changed files with 14 additions and 4 deletions
|
@ -295,6 +295,7 @@ function Map.__init__(self, config, ...)
|
||||||
self.template = "cbi/map"
|
self.template = "cbi/map"
|
||||||
self.apply_on_parse = nil
|
self.apply_on_parse = nil
|
||||||
self.readinput = true
|
self.readinput = true
|
||||||
|
self.proceed = false
|
||||||
|
|
||||||
self.uci = uci.cursor()
|
self.uci = uci.cursor()
|
||||||
self.save = true
|
self.save = true
|
||||||
|
@ -349,7 +350,7 @@ function Map.parse(self, readinput, ...)
|
||||||
for i, config in ipairs(self.parsechain) do
|
for i, config in ipairs(self.parsechain) do
|
||||||
self.uci:save(config)
|
self.uci:save(config)
|
||||||
end
|
end
|
||||||
if self:submitstate() and (self.autoapply or luci.http.formvalue("cbi.apply")) then
|
if self:submitstate() and not self.proceed and (self.autoapply or luci.http.formvalue("cbi.apply")) then
|
||||||
for i, config in ipairs(self.parsechain) do
|
for i, config in ipairs(self.parsechain) do
|
||||||
self.uci:commit(config)
|
self.uci:commit(config)
|
||||||
|
|
||||||
|
@ -377,7 +378,9 @@ function Map.parse(self, readinput, ...)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
if self:submitstate() then
|
if self.proceed then
|
||||||
|
self.state = FORM_PROCEED
|
||||||
|
elseif self:submitstate() then
|
||||||
if self.save then
|
if self.save then
|
||||||
self.state = self.changed and FORM_CHANGED or FORM_VALID
|
self.state = self.changed and FORM_CHANGED or FORM_VALID
|
||||||
else
|
else
|
||||||
|
@ -725,6 +728,7 @@ function AbstractSection.parse_optionals(self, section)
|
||||||
if field == v.option then
|
if field == v.option then
|
||||||
field = nil
|
field = nil
|
||||||
else
|
else
|
||||||
|
self.map.proceed = true
|
||||||
table.insert(self.optionals[section], v)
|
table.insert(self.optionals[section], v)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -763,6 +767,7 @@ function AbstractSection.parse_dynamic(self, section)
|
||||||
end
|
end
|
||||||
|
|
||||||
if create and key:sub(1, 1) ~= "." then
|
if create and key:sub(1, 1) ~= "." then
|
||||||
|
self.map.proceed = true
|
||||||
self:add_dynamic(key, true)
|
self:add_dynamic(key, true)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -781,7 +786,7 @@ end
|
||||||
|
|
||||||
-- Removes the section
|
-- Removes the section
|
||||||
function AbstractSection.remove(self, section)
|
function AbstractSection.remove(self, section)
|
||||||
self.map.autoapply = false
|
self.map.proceed = true
|
||||||
return self.map:del(section)
|
return self.map:del(section)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -808,7 +813,7 @@ function AbstractSection.create(self, section)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
self.map.autoapply = false
|
self.map.proceed = true
|
||||||
|
|
||||||
return stat
|
return stat
|
||||||
end
|
end
|
||||||
|
@ -1542,6 +1547,11 @@ function DynamicList.value(self, key, val)
|
||||||
table.insert(self.vallist, tostring(val))
|
table.insert(self.vallist, tostring(val))
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function DynamicList.write(self, ...)
|
||||||
|
self.map.proceed = true
|
||||||
|
return AbstractValue.write(self, ...)
|
||||||
|
end
|
||||||
|
|
||||||
function DynamicList.formvalue(self, section)
|
function DynamicList.formvalue(self, section)
|
||||||
local value = AbstractValue.formvalue(self, section)
|
local value = AbstractValue.formvalue(self, section)
|
||||||
value = (type(value) == "table") and value or {value}
|
value = (type(value) == "table") and value or {value}
|
||||||
|
|
Loading…
Reference in a new issue