Skip to content

Commit

Permalink
Fix map settings redirection
Browse files Browse the repository at this point in the history
  • Loading branch information
Senen committed Nov 27, 2023
1 parent 220f9d6 commit 9fceb4f
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions app/components/admin/settings/map_form_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<%= hidden_field_tag :latitude, Setting["map.latitude"] %>
<%= hidden_field_tag :longitude, Setting["map.longitude"] %>
<%= hidden_field_tag :zoom, Setting["map.zoom"] %>
<%= hidden_field_tag :tab, tab if defined?(tab) %>

<div class="small-12 medium-6 large-4 margin-top">
<%= submit_tag t("admin.settings.index.map.form.submit"),
Expand Down
5 changes: 5 additions & 0 deletions app/components/admin/settings/map_form_component.rb
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
class Admin::Settings::MapFormComponent < ApplicationComponent
attr_reader :tab

def initialize(tab: nil)
@tab = tab
end
end
2 changes: 1 addition & 1 deletion app/controllers/admin/settings_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def update_map
Setting["map.latitude"] = params[:latitude].to_f
Setting["map.longitude"] = params[:longitude].to_f
Setting["map.zoom"] = params[:zoom].to_i
redirect_to admin_settings_path, notice: t("admin.settings.index.map.flash.update")
redirect_to request_referer, notice: t("admin.settings.index.map.flash.update")
end

def update_content_types
Expand Down
2 changes: 1 addition & 1 deletion app/views/admin/settings/_map_configuration_tab.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<p><%= t("admin.settings.index.map.help") %></p>

<%= render Admin::Settings::MapFormComponent.new %>
<%= render Admin::Settings::MapFormComponent.new(tab: "#tab-map-configuration") %>
<% else %>
<div class="callout primary">
<%= t("admin.settings.index.map.how_to_enable") %>
Expand Down
11 changes: 11 additions & 0 deletions spec/system/admin/settings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,17 @@
expect(page).to have_current_path(admin_settings_path)
expect(page).to have_css("div#tab-map-configuration.is-active")
end

scenario "On #tab-map-configuration when using the interactive map" do
visit admin_settings_path(anchor: "tab-map-configuration")
within "#map-form" do
click_button "Update"
end

expect(page).to have_content("Map configuration updated successfully.")
expect(page).to have_current_path(admin_settings_path)
expect(page).to have_css("div#tab-map-configuration.is-active")
end
end

scenario "On #tab-proposals" do
Expand Down

0 comments on commit 9fceb4f

Please sign in to comment.