From 011370e1558935c7433bfdab06311a5ff0658973 Mon Sep 17 00:00:00 2001 From: "joseph@dxw.com" Date: Mon, 25 Nov 2024 15:36:14 +0000 Subject: [PATCH] Use map search instead of zone selector Remove the zone dropdown and instead drive zone selection with the search function of the map. --- app/javascript/controllers/map_controller.js | 3 +++ app/views/forecasts/_location_selector.html.erb | 5 +---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/app/javascript/controllers/map_controller.js b/app/javascript/controllers/map_controller.js index b6dd6951..0da32598 100644 --- a/app/javascript/controllers/map_controller.js +++ b/app/javascript/controllers/map_controller.js @@ -155,6 +155,9 @@ export default class MapController extends Controller { "poi", ], }) + .on("pick", (e) => { + this.updatePredictionZone(e.feature?.geometry?.coordinates); + }) .addTo(this.map); } diff --git a/app/views/forecasts/_location_selector.html.erb b/app/views/forecasts/_location_selector.html.erb index 555a2d43..b718e351 100644 --- a/app/views/forecasts/_location_selector.html.erb +++ b/app/views/forecasts/_location_selector.html.erb @@ -1,8 +1,5 @@ <%= form_tag(false, method: :get, id: "forecast-form", data: { "turbo-stream": "replace", "action": "submit->map#updateMap"}) do %> - <%= select_tag :zone, - options_for_select(Zone.all.order(:name).map(&:name), @zone.name), - data: { "forecast-target": "zoneSelector", action: "change->forecast#changeZone" } - %> + <%= hidden_field_tag :zone, @zone.name, data: { "forecast-target": "zoneSelector", "map-target": "zoneSelector", action: "change->forecast#changeZone" } %> <%= hidden_field_tag :date, @date, data: { "forecast-target": "daySelector", "map-target": "daySelector" } %> <%= hidden_field_tag :lat, @map_lat, data: { "map-target": "latField" } %> <%= hidden_field_tag :lng, @map_lng, data: { "map-target": "lngField" } %>