User foundation setup

This commit is contained in:
2014-03-26 13:17:34 +01:00
parent 6c2427e082
commit 4e75c72097
87 changed files with 861 additions and 120 deletions
@@ -0,0 +1,45 @@
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
@@ -0,0 +1,18 @@
App.ListProductsForTableRoute = Ember.Route.extend {}
#setupController: (controller)->
#controller.secured ->
#src = '/user/list_products_for_table.json'
#data = {}
#$.getJSON(data_host + src, $.extend(@authentication_object, data)).then (res) =>
#if res.not_present
#@redirect_to 'index', message: 'the_list_has_been_closed'
#return
#for pc in res.categories
#product_category = @store.createRecord 'product_category',
#name: pc.name
#for pp in pc.products
#pp.id = pp._id
#pp.product_category = product_category
#product = @store.createRecord 'product', pp
#controller.set 'model', @store.all('product_category')
#debugger
@@ -0,0 +1,17 @@
App.ListProductsRoute = Ember.Route.extend {}
#setupController: (controller)->
#controller.secured ->
#src = '/user/list_products.json'
#data = {}
#$.getJSON(data_host + src, $.extend(@authentication_object, data)).then (res) =>
#if res.not_present
#@redirect_to 'index', message: 'the_list_has_been_closed'
#return
#for pc in res.categories
#product_category = @store.createRecord 'product_category',
#name: pc.name
#for pp in pc.products
#pp.id = pp._id
#pp.product_category = product_category
#product = @store.createRecord 'product', pp
#controller.set 'model', @store.all('product_category')
@@ -0,0 +1,9 @@
App.SelectQrcodeRoute = Ember.Route.extend
setupController: (controller)->
$.ajax
url: Routes.select_qrcode_path()
type: "GET"
dataType: 'json'
async: false
success: (res)->
controller.set 'tables', res