Highlight current locale when changing locale from select

When the locale changes the corresponding tab is
highlighted automatically.
When a language is added to the milestone, the tab
is highlighted automatically.
This commit is contained in:
iagirre
2018-04-12 10:00:43 +02:00
parent b318c2be46
commit 285e02ce96
3 changed files with 6 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ App.Globalize =
$(".js-globalize-locale-link").each ->
if $(this).data("locale") == locale
$(this).show()
App.Globalize.highlight_locale($(this))
$(".js-globalize-locale option:selected").removeAttr("selected");
return

View File

@@ -30,6 +30,10 @@ module GlobalizeHelper
globalize_locale == locale ? "highlight" : ""
end
def highlight_current?(locale)
I18n.locale == locale ? 'highlight' : ''
end
def show_delete?(locale)
I18n.locale == locale ? '' : 'display: none'
end

View File

@@ -2,7 +2,7 @@
<span>
<%= link_to name_for_locale(locale), "#",
style: css_to_display_translation?(@milestone, locale),
class: "js-globalize-locale-link",
class: "js-globalize-locale-link #{highlight_current?(locale)}",
data: { locale: locale },
remote: true %>
<%= link_to t("admin.milestones.form.remove_language"), "#",