Fix question options translations not being saved
If we enabled the locale and then added an option, the "add option" link added the partial which was generated before enabling the translation, and so it generated a field where the translation was disabled. Enabling the translation after inserting each field solves the issue.
This commit is contained in:
@@ -39,6 +39,12 @@ App.Globalize =
|
||||
disable_locale: (locale) ->
|
||||
App.Globalize.destroy_locale_field(locale).val(true)
|
||||
|
||||
enabled_locales: ->
|
||||
$.map(
|
||||
$(".js-globalize-locale-link:visible"),
|
||||
(element) -> $(element).data("locale")
|
||||
)
|
||||
|
||||
destroy_locale_field: (locale) ->
|
||||
$(".destroy_locale[data-locale=" + locale + "]")
|
||||
|
||||
@@ -61,3 +67,8 @@ App.Globalize =
|
||||
$(this).hide()
|
||||
App.Globalize.remove_language(locale)
|
||||
|
||||
$(".add_fields_container").on "cocoon:after-insert", ->
|
||||
$.each(
|
||||
App.Globalize.enabled_locales(),
|
||||
(index, locale) -> App.Globalize.enable_locale(locale)
|
||||
)
|
||||
|
||||
@@ -36,10 +36,12 @@
|
||||
<% end %>
|
||||
|
||||
<div class="small-12 medium-9 column">
|
||||
<div class="add_fields_container">
|
||||
<%= link_to_add_association t("admin.legislation.questions.form.add_option"),
|
||||
f, :question_options, class: "button hollow" %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="small-12 medium-6 large-3 clear column end margin-top">
|
||||
<%= f.submit(class: "button success expanded", value: t("admin.legislation.questions.#{admin_submit_action(@question)}.submit_button")) %>
|
||||
|
||||
Reference in New Issue
Block a user