From b4346ff9e6f3330cfcaeafa7b335cdca8d8058b1 Mon Sep 17 00:00:00 2001 From: Matthias Schiffer Date: Sun, 19 Aug 2018 20:20:31 +0200 Subject: [PATCH] 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 --- .../config-mode/wizard/0400-geo-location.lua | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/package/gluon-config-mode-geo-location/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua b/package/gluon-config-mode-geo-location/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua index 718e59ee..456458d2 100644 --- a/package/gluon-config-mode-geo-location/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua +++ b/package/gluon-config-mode-geo-location/luasrc/lib/gluon/config-mode/wizard/0400-geo-location.lua @@ -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)