We were defining one builder in the `app/lib/` folder and another one inside a helper module. So now we're grouping them together. This way we're following the "one class per file" convention that we follow most of the time. And, by extracting the `TranslatableFormBuilder` class to its own file, it'll be easier to add tests for it. Note that, for consistency, we're renaming the `TranslationsFieldsBuilder` class so it ends in `FormBuilder`.
18 lines
532 B
Ruby
18 lines
532 B
Ruby
module TranslatableFormHelper
|
|
def translatable_form_for(record, options = {}, &)
|
|
form_for(record, options.merge(builder: TranslatableFormBuilder), &)
|
|
end
|
|
|
|
def translations_interface_enabled?
|
|
Setting["feature.translation_interface"].present? || backend_translations_enabled?
|
|
end
|
|
|
|
def backend_translations_enabled?
|
|
controller.class.module_parents.intersect?([Admin, Management, Valuation, SDGManagement])
|
|
end
|
|
|
|
def highlight_translation_html_class
|
|
"highlight" if translations_interface_enabled?
|
|
end
|
|
end
|