From f56dc654f3c15d1e25272ea854825da0d3101a04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sen=C3=A9n=20Rodero=20Rodr=C3=ADguez?= Date: Thu, 18 Jan 2024 16:44:07 +0100 Subject: [PATCH] Extract map configuration tab partial to a component --- .../admin/settings/map_tab_component.html.erb} | 3 +-- app/components/admin/settings/map_tab_component.rb | 13 +++++++++++++ app/views/admin/settings/index.html.erb | 2 +- 3 files changed, 15 insertions(+), 3 deletions(-) rename app/{views/admin/settings/_map_configuration_tab.html.erb => components/admin/settings/map_tab_component.html.erb} (82%) create mode 100644 app/components/admin/settings/map_tab_component.rb diff --git a/app/views/admin/settings/_map_configuration_tab.html.erb b/app/components/admin/settings/map_tab_component.html.erb similarity index 82% rename from app/views/admin/settings/_map_configuration_tab.html.erb rename to app/components/admin/settings/map_tab_component.html.erb index 38a6f5438..c353d58b3 100644 --- a/app/views/admin/settings/_map_configuration_tab.html.erb +++ b/app/components/admin/settings/map_tab_component.html.erb @@ -1,9 +1,8 @@ <% if feature?(:map) %>

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

- <% tab = "#tab-map-configuration" %> <%= 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) %> <% end %> <% end %> diff --git a/app/components/admin/settings/map_tab_component.rb b/app/components/admin/settings/map_tab_component.rb new file mode 100644 index 000000000..702721eb4 --- /dev/null +++ b/app/components/admin/settings/map_tab_component.rb @@ -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 diff --git a/app/views/admin/settings/index.html.erb b/app/views/admin/settings/index.html.erb index 8caea8827..daf1fc2d2 100644 --- a/app/views/admin/settings/index.html.erb +++ b/app/views/admin/settings/index.html.erb @@ -15,7 +15,7 @@
- <%= render "map_configuration_tab" %> + <%= render Admin::Settings::MapTabComponent.new %>