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) ->
|
disable_locale: (locale) ->
|
||||||
App.Globalize.destroy_locale_field(locale).val(true)
|
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_field: (locale) ->
|
||||||
$(".destroy_locale[data-locale=" + locale + "]")
|
$(".destroy_locale[data-locale=" + locale + "]")
|
||||||
|
|
||||||
@@ -61,3 +67,8 @@ App.Globalize =
|
|||||||
$(this).hide()
|
$(this).hide()
|
||||||
App.Globalize.remove_language(locale)
|
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,8 +36,10 @@
|
|||||||
<% end %>
|
<% end %>
|
||||||
|
|
||||||
<div class="small-12 medium-9 column">
|
<div class="small-12 medium-9 column">
|
||||||
<%= link_to_add_association t("admin.legislation.questions.form.add_option"),
|
<div class="add_fields_container">
|
||||||
|
<%= link_to_add_association t("admin.legislation.questions.form.add_option"),
|
||||||
f, :question_options, class: "button hollow" %>
|
f, :question_options, class: "button hollow" %>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user