Class: ActiveAdmin::Views::AttributesTable
- Inherits:
-
Component
- Object
- Component
- ActiveAdmin::Views::AttributesTable
- Defined in:
- lib/active_admin/globalize/attributes_table_extension.rb
Overview
Provide additional method #translated_row to attribute table
Instance Method Summary collapse
-
#translated_row(field, opts) ⇒ Object
Show a row with their translations and selectors for choosing locale to show.
Instance Method Details
#translated_row(field, opts) ⇒ Object
Show a row with their translations and selectors for choosing locale to show.
If a block is given it will be used to format the translation, otherwise field taken from translation object is used as translation.
Additional options are forwarded to the original row call.
end
end
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/active_admin/globalize/attributes_table_extension.rb', line 42 def translated_row(*args, &block) = args. .reverse_merge!(inline: true, locale: I18n.locale) field = [:field] || args.first raise ArgumentError, "Field '#{field}' is not translatable" unless translatable?(field) # Remove my options from passed options = .symbolize_keys.except(:field, :locale, :inline) # Append remaining options to original args args.push() unless .empty? # Render the table row with translations row(*args) do if [:inline] ''.html_safe.tap do |value| # Add selectors for inline locale value << inline_locale_selectors(field, [:locale], &block) # Build translations spans value << field_translations(field, :span, [:locale], &block) end else content_tag(:div, class: 'activeadmin-translations') do ''.html_safe.tap do |value| # Render selectors as in translation ui value << block_locale_selectors(field, [:locale], &block) # Build translations divs for actual translations value << field_translations(field, :div, [:locale], &block) end end end end end |