Update information texts translatable fields

This part used the code we deleted in order to make it easier to
refactor the rest of the translatable models. Now we add the code back.
This commit is contained in:
Javi Martín
2018-10-11 10:55:23 +02:00
committed by decabeza
parent 1f033383e5
commit 87484015da
7 changed files with 28 additions and 19 deletions

View File

@@ -1,5 +1,5 @@
class Admin::SiteCustomization::InformationTextsController < Admin::SiteCustomization::BaseController
include Translatable
before_action :delete_translations, only: [:update]
def index
fetch_existing_keys
@@ -9,7 +9,7 @@ class Admin::SiteCustomization::InformationTextsController < Admin::SiteCustomiz
def update
content_params.each do |content|
values = content[:values].slice(*translation_params(I18nContent))
values = content[:values].slice(*translation_params)
unless values.empty?
values.each do |key, value|
@@ -73,4 +73,15 @@ class Admin::SiteCustomization::InformationTextsController < Admin::SiteCustomiz
end
end
def translation_params
I18nContent.translated_attribute_names.product(enabled_translations).map do |attr_name, loc|
I18nContent.localized_attr_name_for(attr_name, loc)
end
end
def enabled_translations
params.fetch(:enabled_translations, {})
.select { |_, v| v == '1' }
.keys
end
end