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:
		
							parent
							
								
									688de03db2
								
							
						
					
					
						commit
						b4346ff9e6
					
				| @ -6,19 +6,13 @@ return function(form, uci) | |||||||
| 
 | 
 | ||||||
| 	local location = uci:get_first("gluon-node-info", "location") | 	local location = uci:get_first("gluon-node-info", "location") | ||||||
| 
 | 
 | ||||||
| 	local function show_altitude() | 	local show_altitude = site.config_mode.geo_location.show_altitude(false) | ||||||
| 		if site.config_mode.geo_location.show_altitude(true) then |  | ||||||
| 			return true |  | ||||||
| 		end |  | ||||||
| 
 |  | ||||||
| 		return uci:get_bool("gluon-node-info", location, "altitude") |  | ||||||
| 	end |  | ||||||
| 
 | 
 | ||||||
| 	local text = site_i18n._translate("gluon-config-mode:geo-location-help") or pkg_i18n.translate( | 	local text = site_i18n._translate("gluon-config-mode:geo-location-help") or pkg_i18n.translate( | ||||||
| 		'If you want the location of your node to ' .. | 		'If you want the location of your node to ' .. | ||||||
| 		'be displayed on the map, you can enter its coordinates here.' | 		'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") | 		text = text .. ' ' .. site_i18n.translate("gluon-config-mode:altitude-help") | ||||||
| 	end | 	end | ||||||
| 
 | 
 | ||||||
| @ -30,6 +24,11 @@ return function(form, uci) | |||||||
| 	share_location.default = uci:get_bool("gluon-node-info", location, "share_location") | 	share_location.default = uci:get_bool("gluon-node-info", location, "share_location") | ||||||
| 	function share_location:write(data) | 	function share_location:write(data) | ||||||
| 		uci:set("gluon-node-info", location, "share_location", 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 | 	end | ||||||
| 
 | 
 | ||||||
| 	o = s:option(Value, "latitude", pkg_i18n.translate("Latitude"), pkg_i18n.translatef("e.g. %s", "53.873621")) | 	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) | 		uci:set("gluon-node-info", location, "longitude", data) | ||||||
| 	end | 	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 = 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.default = uci:get("gluon-node-info", location, "altitude") | ||||||
| 		o:depends(share_location, true) | 		o:depends(share_location, true) | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user