Fix map settings redirection

This commit is contained in:
Senén Rodero Rodríguez
2023-11-27 14:22:15 +01:00
committed by Javi Martín
parent cb91a7421d
commit 91c3bde36b
5 changed files with 19 additions and 2 deletions

View File

@@ -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 tab %>
<div class="small-12 medium-6 large-4 margin-top">
<%= submit_tag t("admin.settings.index.map.form.submit"),

View File

@@ -1,2 +1,7 @@
class Admin::Settings::MapFormComponent < ApplicationComponent
attr_reader :tab
def initialize(tab: nil)
@tab = tab
end
end

View File

@@ -27,7 +27,7 @@ class Admin::SettingsController < Admin::BaseController
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

View File

@@ -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") %>

View File

@@ -222,6 +222,17 @@ describe "Admin settings", :admin do
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