Files
mozo-backend/app/assets/javascripts/user/app/routes/application_route.js.coffee
T
2014-03-26 13:17:34 +01:00

46 lines
1.6 KiB
CoffeeScript

App.ApplicationRoute = Ember.Route.extend
setupController: (controller)->
@controllerFor('product_orders').set 'model', @store.all('product_order')
controller.secured ->
faye = new Faye.Client(event_host)
user_id = Qstorage.getItem('user_id')
faye.subscribe "/user/"+user_id, (e)=>
console.log e
@events[e.event].call(@) if @events[e.event]
@getList()
unauthorized: ->
Qstorage.setItem('auth_token', '')
@controllerFor('application').set 'list', null
@transitionTo('obtain_token').then =>
@controllerFor('application').set('notice', t('messages.unauthorized'))
actions:
openModal: (modalName, model)->
@controllerFor(modalName).set('model', model)
@render modalName,
into: 'application'
outlet: 'modal'
closeModal: ->
@disconnectOutlet
outlet: 'modal'
parentView: 'application'
confirm: (options = {})->
@send 'openModal', 'modal_confirm', Ember.Object.create
title: options.title
body: options.body
cancel: options.cancel
ok: options.ok
listNeedsPayment: ->
@get('controller').secured ->
$.post(data_host + '/user/list_needs_payment.json', @authentication_object).then (res) =>
@set('list.needs_payment', true)
listNeedsHelp: ->
@get('controller').secured ->
$.post(data_host + '/user/needs_help.json', @authentication_object).then (res) =>
@set('list.needs_help', true)
scanQr: ->
@transitionTo 'select_qrcode'
events: ->
error: (error)->
debugger