gluon-config-mode-geo-location: make altitude show behaviour match docs

Do not show by default, delete old altitude value when a form without
altitude shown is saved.

Fixes #1493
This commit is contained in:
Matthias Schiffer 2018-08-19 20:20:31 +02:00
parent 688de03db2
commit b4346ff9e6
No known key found for this signature in database
GPG Key ID: 16EF3F64CB201D9C

View File

@ -6,19 +6,13 @@ return function(form, uci)
local location = uci:get_first("gluon-node-info", "location")
local function show_altitude()
if site.config_mode.geo_location.show_altitude(true) then
return true
end
return uci:get_bool("gluon-node-info", location, "altitude")
end
local show_altitude = site.config_mode.geo_location.show_altitude(false)
local text = site_i18n._translate("gluon-config-mode:geo-location-help") or pkg_i18n.translate(
'If you want the location of your node to ' ..
'be displayed on the map, you can enter its coordinates here.'
)
if show_altitude() then
if show_altitude then
text = text .. ' ' .. site_i18n.translate("gluon-config-mode:altitude-help")
end
@ -30,6 +24,11 @@ return function(form, uci)
share_location.default = uci:get_bool("gluon-node-info", location, "share_location")
function share_location:write(data)
uci:set("gluon-node-info", location, "share_location", data)
-- The config mode does not have a nicer place to put this at the moment...
if not show_altitude then
uci:delete("gluon-node-info", location, "altitude")
end
end
o = s:option(Value, "latitude", pkg_i18n.translate("Latitude"), pkg_i18n.translatef("e.g. %s", "53.873621"))
@ -48,7 +47,7 @@ return function(form, uci)
uci:set("gluon-node-info", location, "longitude", data)
end
if show_altitude() then
if show_altitude then
o = s:option(Value, "altitude", site_i18n.translate("gluon-config-mode:altitude-label"), pkg_i18n.translatef("e.g. %s", "11.51"))
o.default = uci:get("gluon-node-info", location, "altitude")
o:depends(share_location, true)