diff --git a/app/components/admin/settings/map_tab_component.html.erb b/app/components/admin/settings/map_tab_component.html.erb index c353d58b3..d6527f40e 100644 --- a/app/components/admin/settings/map_tab_component.html.erb +++ b/app/components/admin/settings/map_tab_component.html.erb @@ -5,6 +5,7 @@ <% settings.each do |key| %> <%= render Admin::Settings::RowComponent.new(key, tab: tab) %> <% end %> + <%= render Admin::Settings::RowComponent.new("map.feature.marker_clustering", type: :feature, tab: tab) %> <% end %>

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

diff --git a/app/helpers/settings_helper.rb b/app/helpers/settings_helper.rb index ccd248e63..b5ac46af9 100644 --- a/app/helpers/settings_helper.rb +++ b/app/helpers/settings_helper.rb @@ -9,7 +9,7 @@ module SettingsHelper end def feature?(name) - setting["feature.#{name}"].presence || setting["process.#{name}"].presence + setting["feature.#{name}"].presence || setting["process.#{name}"].presence || setting[name].presence end def setting diff --git a/app/models/setting.rb b/app/models/setting.rb index a1cd0e211..ec26ae211 100644 --- a/app/models/setting.rb +++ b/app/models/setting.rb @@ -99,6 +99,7 @@ class Setting < ApplicationRecord "map.latitude": 51.48, "map.longitude": 0.0, "map.zoom": 10, + "map.feature.marker_clustering": false, "process.debates": true, "process.proposals": true, "process.polls": true, diff --git a/config/locales/en/settings.yml b/config/locales/en/settings.yml index 22e600c0b..de6059657 100644 --- a/config/locales/en/settings.yml +++ b/config/locales/en/settings.yml @@ -169,6 +169,9 @@ en: valid: "Condition for detecting a valid response" valid_description: "What response path has to come informed to be considered a valid response and user verified" map: + feature: + marker_clustering: "Marker clustering" + marker_clustering_description: "Enables map markers clusterization. Useful when there are a lot of markers to show." latitude: "Latitude" latitude_description: "Latitude to show the map position" longitude: "Longitude" diff --git a/config/locales/es/settings.yml b/config/locales/es/settings.yml index 3aea75100..08d0b3ae8 100644 --- a/config/locales/es/settings.yml +++ b/config/locales/es/settings.yml @@ -169,6 +169,9 @@ es: valid: "Condición para detectar una respuesta válida" valid_description: "Que ruta de la respuesta tiene que venir informado para considerarse una respuesta válida" map: + feature: + marker_clustering: "Agrupación de marcadores" + marker_clustering_description: "Activa la agrupación de marcadores en el mapa. Útil cuando hay muchos marcadores que mostrar." latitude: "Latitud" latitude_description: "Latitud para mostrar la posición del mapa" longitude: "Longitud" diff --git a/spec/helpers/settings_helper_spec.rb b/spec/helpers/settings_helper_spec.rb index f7bd9835a..84f0881f0 100644 --- a/spec/helpers/settings_helper_spec.rb +++ b/spec/helpers/settings_helper_spec.rb @@ -13,15 +13,46 @@ RSpec.describe SettingsHelper do end describe "#feature?" do - it "returns presence of feature flag setting value" do + it "finds settings by the given name prefixed with 'feature.' and returns its presence" do Setting["feature.f1"] = "active" - Setting["feature.f2"] = "" - Setting["feature.f3"] = nil + Setting["feature.f2"] = true + Setting["feature.f3"] = false + Setting["feature.f4"] = "" + Setting["feature.f5"] = nil expect(feature?("f1")).to eq("active") - expect(feature?("f2")).to be nil + expect(feature?("f2")).to eq("t") expect(feature?("f3")).to be nil expect(feature?("f4")).to be nil + expect(feature?("f5")).to be nil + end + + it "finds settings by the given name prefixed with 'process.' and returns its presence" do + Setting["process.p1"] = "active" + Setting["process.p2"] = true + Setting["process.p3"] = false + Setting["process.p4"] = "" + Setting["process.p5"] = nil + + expect(feature?("p1")).to eq("active") + expect(feature?("p2")).to eq("t") + expect(feature?("p3")).to be nil + expect(feature?("p4")).to be nil + expect(feature?("p5")).to be nil + end + + it "finds settings by the full key name and returns its presence" do + Setting["map.feature.f1"] = "active" + Setting["map.feature.f2"] = true + Setting["map.feature.f3"] = false + Setting["map.feature.f4"] = "" + Setting["map.feature.f5"] = nil + + expect(feature?("map.feature.f1")).to eq("active") + expect(feature?("map.feature.f2")).to eq("t") + expect(feature?("map.feature.f3")).to be nil + expect(feature?("map.feature.f4")).to be nil + expect(feature?("map.feature.f5")).to be nil end end end