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:
@@ -0,0 +1,16 @@
|
||||
<%= render Shared::GlobalizeLocalesComponent.new %>
|
||||
|
||||
<%= form_tag admin_site_customization_information_texts_path do %>
|
||||
<% I18n.available_locales.each do |l| %>
|
||||
<%= translation_enabled_tag l, site_customization_enable_translation?(l) %>
|
||||
<% end %>
|
||||
<% contents.each do |group| %>
|
||||
<% group.each do |content| %>
|
||||
<b><%= content.key %></b>
|
||||
<% content.globalize_locales.each do |locale| %>
|
||||
<%= render Admin::SiteCustomization::InformationTexts::FormFieldComponent.new(content, locale: locale) %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
<%= submit_tag t("admin.menu.site_customization.buttons.save"), class: "button" %>
|
||||
<% end %>
|
||||
@@ -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
|
||||
Reference in New Issue
Block a user