Extract map configuration tab partial to a component

This commit is contained in:
Senén Rodero Rodríguez
2024-01-18 16:44:07 +01:00
committed by Javi Martín
parent 6876f080a2
commit f56dc654f3
3 changed files with 15 additions and 3 deletions

View File

@@ -1,9 +1,8 @@
<% if feature?(:map) %> <% if feature?(:map) %>
<h2><%= t("admin.settings.index.map.title") %></h2> <h2><%= t("admin.settings.index.map.title") %></h2>
<% tab = "#tab-map-configuration" %>
<%= render Admin::Settings::TableComponent.new(setting_name: "setting") do %> <%= render Admin::Settings::TableComponent.new(setting_name: "setting") do %>
<% %w[map.latitude map.longitude map.zoom].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 %>
<% end %> <% end %>

View File

@@ -0,0 +1,13 @@
class Admin::Settings::MapTabComponent < ApplicationComponent
def tab
"#tab-map-configuration"
end
def settings
%w[
map.latitude
map.longitude
map.zoom
]
end
end

View File

@@ -15,7 +15,7 @@
</div> </div>
<div class="tabs-panel" id="tab-map-configuration"> <div class="tabs-panel" id="tab-map-configuration">
<%= render "map_configuration_tab" %> <%= render Admin::Settings::MapTabComponent.new %>
</div> </div>
<div class="tabs-panel" id="tab-images-and-documents"> <div class="tabs-panel" id="tab-images-and-documents">