Extract remote census configuration tab partial to a component

This commit is contained in:
Senén Rodero Rodríguez
2024-01-18 16:33:27 +01:00
committed by Javi Martín
parent 684a830515
commit 347a9d3d5b
3 changed files with 40 additions and 9 deletions

View File

@@ -1,21 +1,18 @@
<% if feature?(:remote_census) %>
<h2><%= t("admin.settings.index.remote_census.title") %></h2>
<% tab = "#tab-remote-census-configuration" %>
<%= render Admin::Settings::TableComponent.new(setting_name: "remote_census_general_name") do %>
<%= render Admin::Settings::RowComponent.new("remote_census.general.endpoint", tab: tab) %>
<% general_settings.each do |key| %>
<%= render Admin::Settings::RowComponent.new(key, tab: tab) %>
<% end %>
<% end %>
<%= render Admin::Settings::TableComponent.new(setting_name: "remote_census_request_name") do %>
<% %w[remote_census.request.method_name remote_census.request.structure
remote_census.request.document_type remote_census.request.document_number
remote_census.request.date_of_birth remote_census.request.postal_code].each do |key| %>
<% request_settings.each do |key| %>
<%= render Admin::Settings::RowComponent.new(key, tab: tab) %>
<% end %>
<% end %>
<%= render Admin::Settings::TableComponent.new(setting_name: "remote_census_response_name") do %>
<% %w[remote_census.response.date_of_birth remote_census.response.postal_code
remote_census.response.district remote_census.response.gender remote_census.response.name
remote_census.response.surname remote_census.response.valid].each do |key| %>
<% response_settings.each do |key| %>
<%= render Admin::Settings::RowComponent.new(key, tab: tab) %>
<% end %>
<% end %>

View File

@@ -0,0 +1,34 @@
class Admin::Settings::RemoteCensusTabComponent < ApplicationComponent
def tab
"#tab-remote-census-configuration"
end
def general_settings
%w[
remote_census.general.endpoint
]
end
def request_settings
%w[
remote_census.request.method_name
remote_census.request.structure
remote_census.request.document_type
remote_census.request.document_number
remote_census.request.date_of_birth
remote_census.request.postal_code
]
end
def response_settings
%w[
remote_census.response.date_of_birth
remote_census.response.postal_code
remote_census.response.district
remote_census.response.gender
remote_census.response.name
remote_census.response.surname
remote_census.response.valid
]
end
end

View File

@@ -27,7 +27,7 @@
</div>
<div class="tabs-panel" id="tab-remote-census-configuration">
<%= render "remote_census_configuration_tab" %>
<%= render Admin::Settings::RemoteCensusTabComponent.new %>
</div>
<div class="tabs-panel" id="tab-sdg-configuration">