Add feature to delete a translation
To delete a translation, a link has been added. This link works for the selected language. It hides all the things related to a language (the tab and the text_area) and empties the text area, so that the value is blank in the param hash. A variable called `delete_translations[]` is changed. e.g. If admin wants to remove English language, delete_translations[:en] will be 1; if not, it will be 0. When the milestone is updated, there is a before_action callback that cleans the selected languages for deletion (looking the delete_translations[] variable). Because of the deleted translations are blank in param hash, them won't be saved in DB.
This commit is contained in:
@@ -9,17 +9,28 @@ App.Globalize =
|
||||
|
||||
display_translations: (locale) ->
|
||||
$(".js-globalize-attribute").each ->
|
||||
console.log("In standard")
|
||||
console.log($(this))
|
||||
if $(this).data("locale") == locale
|
||||
$(this).show()
|
||||
else
|
||||
$(this).hide()
|
||||
$('.delete-language').hide()
|
||||
$('#delete-' + locale).show()
|
||||
|
||||
highlight_locale: (element) ->
|
||||
$('.js-globalize-locale-link').removeClass('highlight');
|
||||
element.addClass('highlight');
|
||||
|
||||
remove_language: (locale) ->
|
||||
$(".js-globalize-attribute[data-locale=" + locale + "]").val('')
|
||||
$(".js-globalize-attribute[data-locale=" + locale + "]").hide()
|
||||
$(".js-globalize-locale-link[data-locale=" + locale + "]").hide()
|
||||
$("#delete-" + locale).hide()
|
||||
next = $(".js-globalize-locale-link:visible").first()
|
||||
App.Globalize.highlight_locale(next)
|
||||
$(".js-globalize-attribute[data-locale=" + next.data("locale") + "]").show()
|
||||
$("#delete-" + next.data("locale")).show()
|
||||
$("#delete_translations_" + locale).val(1)
|
||||
|
||||
initialize: ->
|
||||
$('.js-globalize-locale').on 'change', ->
|
||||
App.Globalize.display_translations($(this).val())
|
||||
@@ -28,4 +39,10 @@ App.Globalize =
|
||||
$('.js-globalize-locale-link').on 'click', ->
|
||||
locale = $(this).data("locale")
|
||||
App.Globalize.display_translations(locale)
|
||||
App.Globalize.highlight_locale($(this))
|
||||
App.Globalize.highlight_locale($(this))
|
||||
|
||||
$('.delete-language').on 'click', ->
|
||||
locale = $(this).data("locale")
|
||||
$(this).hide()
|
||||
App.Globalize.remove_language(locale)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user