Skip to content

Commit 09edd0b

Browse files
committed
Merge pull request unmantained-activeadmin-plugins#11 from edenspiekermann/master
Add options auto_sort to form_builder_extension "translated_inputs"
2 parents 15c6887 + 5066bbb commit 09edd0b

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

lib/active_admin/globalize3/form_builder_extension.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,18 @@ module FormBuilderExtension
66
def translated_inputs(name = "Translations", options = {}, &block)
77
options.symbolize_keys!
88
switch_locale = options.fetch(:switch_locale, false)
9+
auto_sort = options.fetch(:auto_sort, true)
910
form_buffers.last << template.content_tag(:div, class: "activeadmin-translations") do
1011
template.content_tag(:ul, class: "available-locales") do
11-
I18n.available_locales.map do |locale|
12+
(auto_sort ? I18n.available_locales.sort : I18n.available_locales).map do |locale|
1213
template.content_tag(:li) do
1314
I18n.with_locale(switch_locale ? locale : I18n.locale) do
1415
template.content_tag(:a, I18n.t(:"active_admin.globalize3.language.#{locale}"), href:".locale-#{locale}")
1516
end
1617
end
1718
end.join.html_safe
1819
end <<
19-
I18n.available_locales.sort.map do |locale|
20+
(auto_sort ? I18n.available_locales.sort : I18n.available_locales).map do |locale|
2021
translation = object.translations.find { |t| t.locale.to_s == locale.to_s }
2122
translation ||= object.translations.build(locale: locale)
2223
fields = proc do |form|

0 commit comments

Comments
 (0)