Poltergeist in the green, and resourceful refactor
This commit is contained in:
@@ -5,6 +5,8 @@ App.SettingsController = Ember.ObjectController.extend
|
||||
countries: (-> window.countries ).property()
|
||||
saving: false
|
||||
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:
|
||||
saveSettings: ->
|
||||
@set 'saving', true
|
||||
@@ -12,3 +14,5 @@ App.SettingsController = Ember.ObjectController.extend
|
||||
@set 'saving', false
|
||||
$('.top-menu .supplier-name').text @get('model.name')
|
||||
@transitionToRoute 'index'
|
||||
switchToSupplier: (supplier)->
|
||||
window.location = Routes.switch_to_suppliers_supplier_path(supplier.get('id'))
|
||||
|
||||
@@ -52,5 +52,5 @@ App.List = DS.Model.extend
|
||||
$.post Routes.mark_helped_suppliers_list_path(@id)
|
||||
remove_needs_payment: ->
|
||||
@set 'needs_payment', false
|
||||
$.post Routes.supplier_remove_list_needs_payment_path(), list_id: @id
|
||||
$.post Routes.remove_needs_payment_suppliers_list_path(@id)
|
||||
sorted_orders: (-> @get('relevant_orders').sortBy('created_at').reverseObjects()).property('relevant_orders.@each.isLoaded')
|
||||
|
||||
@@ -20,9 +20,9 @@ App.Supplier = DS.Model.extend
|
||||
orders_placed_count: attr('number')
|
||||
|
||||
close: ->
|
||||
$.post Routes.supplier_mark_as_closed_path(), =>
|
||||
$.post Routes.mark_as_closed_suppliers_supplier_path(@id), =>
|
||||
@set 'open', false
|
||||
open_the_place: ->
|
||||
$.post Routes.supplier_mark_as_open_path(), =>
|
||||
$.post Routes.mark_as_open_suppliers_supplier_path(@id), =>
|
||||
@set 'open', true
|
||||
|
||||
|
||||
@@ -1,4 +1,7 @@
|
||||
App.SettingsRoute = Ember.Route.extend
|
||||
beforeModel: ->
|
||||
$.getJSON(Routes.employees_suppliers_path()).then (result) =>
|
||||
@store.pushPayload result
|
||||
model: -> @container.lookup('route:application').supplier
|
||||
# setupController: (controller, model)->
|
||||
# #controller.set 'model', controller.get('controllers.application.supplier')
|
||||
|
||||
@@ -44,3 +44,9 @@ if editIensProfile
|
||||
span.fa.fa-lg.fa-spinner.fa-spin
|
||||
else
|
||||
button.button.submit-supplier-settings{action 'saveSettings'}=t 'settings.save'
|
||||
|
||||
|
||||
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
|
||||
|
||||
@@ -25,7 +25,6 @@ String.prototype.capitalize = function() { return this.charAt(0).toUpperCase() +
|
||||
window.time_zones = <%= ActiveSupport::TimeZone.all.map{|tz| {name: tz.name, formatted: "GMT#{tz.formatted_offset} #{tz.name}"}}.to_json.html_safe %>;
|
||||
window.countries = <%= IsoCountryCodes.all.map{|cc| {name: cc.name}}.to_json.html_safe %>;
|
||||
|
||||
|
||||
var path_mapping = {
|
||||
user_root: '/user',
|
||||
join_occupied_table: '/user/join_occupied_table',
|
||||
|
||||
Reference in New Issue
Block a user