Move information texts form partial to a component

This way it'll be easierto write tests for it when we change it.
This commit is contained in:
Javi Martín
2024-05-23 20:21:56 +02:00
parent 2a5edbb5dd
commit 26b48e527a
5 changed files with 16 additions and 8 deletions

View File

@@ -1,4 +1,4 @@
<%= render "globalize_locales" %> <%= render Shared::GlobalizeLocalesComponent.new %>
<%= form_tag admin_site_customization_information_texts_path do %> <%= form_tag admin_site_customization_information_texts_path do %>
<% I18n.available_locales.each do |l| %> <% I18n.available_locales.each do |l| %>

View File

@@ -0,0 +1,14 @@
class Admin::SiteCustomization::InformationTexts::FormComponent < ApplicationComponent
attr_reader :contents
use_helpers :site_customization_enable_translation?
def initialize(contents)
@contents = contents
end
private
def translation_enabled_tag(locale, enabled)
hidden_field_tag("enabled_translations[#{locale}]", (enabled ? 1 : 0))
end
end

View File

@@ -43,10 +43,6 @@ module GlobalizeHelper
end end
end end
def translation_enabled_tag(locale, enabled)
hidden_field_tag("enabled_translations[#{locale}]", (enabled ? 1 : 0))
end
def globalize(locale, &) def globalize(locale, &)
Globalize.with_locale(locale, &) Globalize.with_locale(locale, &)
end end

View File

@@ -1 +0,0 @@
<%= render Shared::GlobalizeLocalesComponent.new %>

View File

@@ -4,7 +4,6 @@
<%= render "tabs" %> <%= render "tabs" %>
<div class="tabs-panel is-active" role="tab"> <div class="tabs-panel is-active" role="tab">
<%= render "form", contents: [@content] %> <%= render Admin::SiteCustomization::InformationTexts::FormComponent.new([@content]) %>
</div> </div>
</div> </div>