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:
iagirre
2018-04-12 09:58:02 +02:00
parent f7486b9238
commit b318c2be46
7 changed files with 55 additions and 8 deletions

View File

@@ -5,10 +5,15 @@
class: "js-globalize-locale-link",
data: { locale: locale },
remote: true %>
<%= link_to t("admin.milestones.form.remove_language"), "#",
id: "delete-#{locale}",
style: show_delete?(locale),
class: 'float-right delete-language',
data: { locale: locale } %>
</span>
<% end %>
<%= select_tag :translation_locale,
<%= select_tag :translation_locale,
options_for_locale_select,
prompt: "Añadir idioma",
class: "js-globalize-locale" %>
prompt: t("admin.milestones.form.add_language"),
class: "js-globalize-locale" %>