diff --git a/app/controllers/api/v1/settings_controller.rb b/app/controllers/api/v1/settings_controller.rb index 2bbcfea7..650d0d50 100644 --- a/app/controllers/api/v1/settings_controller.rb +++ b/app/controllers/api/v1/settings_controller.rb @@ -5,7 +5,7 @@ class Api::V1::SettingsController < ApiController def index render json: { - settings: current_api_user.settings, + settings: current_api_user.safe_settings.config, status: 'success' }, status: :ok end diff --git a/app/javascript/controllers/maps/maplibre/layer_manager.js b/app/javascript/controllers/maps/maplibre/layer_manager.js index 0611e6b7..ccdb0406 100644 --- a/app/javascript/controllers/maps/maplibre/layer_manager.js +++ b/app/javascript/controllers/maps/maplibre/layer_manager.js @@ -93,23 +93,17 @@ export class LayerManager { this.map.getCanvas().style.cursor = '' }) // Areas hover handlers for all sub-layers - this.map.on('mouseenter', 'areas-fill', () => { - this.map.getCanvas().style.cursor = 'pointer' - }) - this.map.on('mouseleave', 'areas-fill', () => { - this.map.getCanvas().style.cursor = '' - }) - this.map.on('mouseenter', 'areas-outline', () => { - this.map.getCanvas().style.cursor = 'pointer' - }) - this.map.on('mouseleave', 'areas-outline', () => { - this.map.getCanvas().style.cursor = '' - }) - this.map.on('mouseenter', 'areas-labels', () => { - this.map.getCanvas().style.cursor = 'pointer' - }) - this.map.on('mouseleave', 'areas-labels', () => { - this.map.getCanvas().style.cursor = '' + const areaLayers = ['areas-fill', 'areas-outline', 'areas-labels'] + areaLayers.forEach(layerId => { + // Only add handlers if layer exists + if (this.map.getLayer(layerId)) { + this.map.on('mouseenter', layerId, () => { + this.map.getCanvas().style.cursor = 'pointer' + }) + this.map.on('mouseleave', layerId, () => { + this.map.getCanvas().style.cursor = '' + }) + } }) } diff --git a/app/services/users/safe_settings.rb b/app/services/users/safe_settings.rb index fb7740a6..64c7a8f9 100644 --- a/app/services/users/safe_settings.rb +++ b/app/services/users/safe_settings.rb @@ -28,7 +28,7 @@ class Users::SafeSettings end # rubocop:disable Metrics/MethodLength - def default_settings + def config { fog_of_war_meters: fog_of_war_meters, meters_between_routes: meters_between_routes, diff --git a/app/views/maps/maplibre/_settings_panel.html.erb b/app/views/maps/maplibre/_settings_panel.html.erb index f6b9e04f..7ccb28df 100644 --- a/app/views/maps/maplibre/_settings_panel.html.erb +++ b/app/views/maps/maplibre/_settings_panel.html.erb @@ -527,8 +527,8 @@
- -
+ +