Add new setting to enable/disable map marker clustering

This commit is contained in:
Senén Rodero Rodríguez
2023-06-30 18:35:25 +02:00
committed by Senén Rodero Rodríguez
parent 095ec8f267
commit 0643606dcd
6 changed files with 44 additions and 5 deletions

View File

@@ -5,6 +5,7 @@
<% settings.each do |key| %> <% settings.each do |key| %>
<%= render Admin::Settings::RowComponent.new(key, tab: tab) %> <%= render Admin::Settings::RowComponent.new(key, tab: tab) %>
<% end %> <% end %>
<%= render Admin::Settings::RowComponent.new("map.feature.marker_clustering", type: :feature, tab: tab) %>
<% end %> <% end %>
<p><%= t("admin.settings.index.map.help") %></p> <p><%= t("admin.settings.index.map.help") %></p>

View File

@@ -9,7 +9,7 @@ module SettingsHelper
end end
def feature?(name) def feature?(name)
setting["feature.#{name}"].presence || setting["process.#{name}"].presence setting["feature.#{name}"].presence || setting["process.#{name}"].presence || setting[name].presence
end end
def setting def setting

View File

@@ -99,6 +99,7 @@ class Setting < ApplicationRecord
"map.latitude": 51.48, "map.latitude": 51.48,
"map.longitude": 0.0, "map.longitude": 0.0,
"map.zoom": 10, "map.zoom": 10,
"map.feature.marker_clustering": false,
"process.debates": true, "process.debates": true,
"process.proposals": true, "process.proposals": true,
"process.polls": true, "process.polls": true,

View File

@@ -169,6 +169,9 @@ en:
valid: "Condition for detecting a valid response" 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" valid_description: "What response path has to come informed to be considered a valid response and user verified"
map: 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: "Latitude"
latitude_description: "Latitude to show the map position" latitude_description: "Latitude to show the map position"
longitude: "Longitude" longitude: "Longitude"

View File

@@ -169,6 +169,9 @@ es:
valid: "Condición para detectar una respuesta válida" 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" valid_description: "Que ruta de la respuesta tiene que venir informado para considerarse una respuesta válida"
map: 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: "Latitud"
latitude_description: "Latitud para mostrar la posición del mapa" latitude_description: "Latitud para mostrar la posición del mapa"
longitude: "Longitud" longitude: "Longitud"

View File

@@ -13,15 +13,46 @@ RSpec.describe SettingsHelper do
end end
describe "#feature?" do 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.f1"] = "active"
Setting["feature.f2"] = "" Setting["feature.f2"] = true
Setting["feature.f3"] = nil Setting["feature.f3"] = false
Setting["feature.f4"] = ""
Setting["feature.f5"] = nil
expect(feature?("f1")).to eq("active") 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?("f3")).to be nil
expect(feature?("f4")).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 end
end end