Add language switcher as component

This commit is contained in:
2015-02-27 15:58:04 +01:00
parent 42838ac4ca
commit 0e08a04df8
6 changed files with 20 additions and 11 deletions
@@ -0,0 +1,11 @@
App.SuppliersSwitcherComponent = Ember.Component.extend
classNames: ['suppliers-switcher-container']
suppliers: (-> @get('targetObject.store').all 'supplier').property()
other_suppliers: ( -> @get('suppliers').rejectBy 'id', @get('targetObject.controllers.application.supplier.id')).property('suppliers.@each')
actions:
switchTo: (locale)->
setLocale locale
@set 'current_locale', locale
@get('targetObject.store').all("page").invoke 'reload'
switchTo: (supplier)->
window.location = Routes.switch_to_suppliers_supplier_path(supplier.get('id'))
@@ -5,8 +5,6 @@ App.SettingsController = Ember.ObjectController.extend
countries: (-> window.countries ).property() countries: (-> window.countries ).property()
saving: false saving: false
editIensProfile: (-> @get('model.country') is 'Netherlands' ).property('model.country') editIensProfile: (-> @get('model.country') is 'Netherlands' ).property('model.country')
suppliers: (-> @store.all 'supplier').property()
other_suppliers: ( -> @get('suppliers').rejectBy 'id', @get('controllers.application.supplier.id')).property('suppliers.@each')
actions: actions:
saveSettings: -> saveSettings: ->
@set 'saving', true @set 'saving', true
@@ -14,5 +12,3 @@ App.SettingsController = Ember.ObjectController.extend
@set 'saving', false @set 'saving', false
$('.top-menu .supplier-name').text @get('model.name') $('.top-menu .supplier-name').text @get('model.name')
@transitionToRoute 'index' @transitionToRoute 'index'
switchToSupplier: (supplier)->
window.location = Routes.switch_to_suppliers_supplier_path(supplier.get('id'))
@@ -0,0 +1,4 @@
if other_suppliers
ul.button-group.stack-for-small.round
each supplier in other_suppliers
li: a.warning.button{action "switchTo" supplier}= t 'suppliers_switcher.switch_to_button' supplier
@@ -45,8 +45,4 @@ if editIensProfile
else else
button.button.submit-supplier-settings{action 'saveSettings'}=t 'settings.save' button.button.submit-supplier-settings{action 'saveSettings'}=t 'settings.save'
.row: .small-12.columns= suppliers-switcher
if other_suppliers
.row: .small-12.columns: ul.button-group.stack-for-small.round
each supplier in other_suppliers
li: a.warning.button{action "switchToSupplier" supplier}= t 'settings.switch_to_supplier' supplier
+2 -1
View File
@@ -125,7 +125,6 @@ en:
reviews: reviews:
title: Reviews title: Reviews
explanation: Fill in your Iens id. You can find this id in the web location of your page explanation: Fill in your Iens id. You can find this id in the web location of your page
switch_to_supplier: Switch to %{name}
product_category: product_category:
# week days depricated # week days depricated
week_days: week_days:
@@ -209,3 +208,5 @@ en:
save_button: Save save_button: Save
destroy_button: Destroy destroy_button: Destroy
destroy_confirmation: Are you sure? destroy_confirmation: Are you sure?
suppliers_switcher:
switch_to_button: Switch to %{name}
+2 -1
View File
@@ -124,7 +124,6 @@ nl:
reviews: reviews:
title: Reviews title: Reviews
explanation: Vul hier je iens id in. Deze kan je halen uit de url van je iens pagina explanation: Vul hier je iens id in. Deze kan je halen uit de url van je iens pagina
switch_to_supplier: Switch to %{name}
product_category: product_category:
week_days: week_days:
abbreviation: abbreviation:
@@ -212,3 +211,5 @@ nl:
save_button: Save save_button: Save
destroy_button: Verwijder destroy_button: Verwijder
destroy_confirmation: 'Weet je zeker dat je de ${models.employee_shift} wilt verwijderen?' destroy_confirmation: 'Weet je zeker dat je de ${models.employee_shift} wilt verwijderen?'
suppliers_switcher:
switch_to_button: Switch to %{name}