End of day commit
This commit is contained in:
@@ -19,6 +19,7 @@ Ember.Application.initializer
|
||||
Globals = Ember.Object.extend
|
||||
list: null
|
||||
notice: ''
|
||||
join_request_sent: false
|
||||
Ember.Application.initializer
|
||||
name: 'Globals'
|
||||
initialize: (container, application)->
|
||||
|
||||
@@ -2,4 +2,4 @@ App.ActiveListController = Ember.Controller.extend
|
||||
#orders: (->
|
||||
#@get('list.orders')
|
||||
#).property('list.orders')
|
||||
list: (-> @get('controllers.application.list') ).property('controllers.application.list')
|
||||
list: (-> @get('globals.list') ).property('globals.list')
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
App.ApplicationController = Ember.Controller.extend
|
||||
needs: ['product_orders']
|
||||
join_request_sent: false
|
||||
#notice: ''
|
||||
actions:
|
||||
confirmCancel: ->
|
||||
@@ -62,13 +61,14 @@ App.ApplicationController = Ember.Controller.extend
|
||||
requestor_id = data.id.substr(3)
|
||||
if requestor_id is Qstorage.getItem('user_id')
|
||||
@set 'globals.notice', t('join_request.requestor.join_request_rejected')
|
||||
@set 'join_request_sent', false
|
||||
@set 'globals.join_request_sent', false
|
||||
|
||||
join_request_approved: ->
|
||||
return if @get('list.id')
|
||||
@setCurrentList ->
|
||||
@transitionToRoute('active_list').then =>
|
||||
@set 'globals.notice', t('join_request.requestor.join_request_approved')
|
||||
@set 'globals.join_request_sent', false
|
||||
|
||||
list_changed_table: ->
|
||||
@setCurrentList()
|
||||
@@ -79,7 +79,7 @@ App.ApplicationController = Ember.Controller.extend
|
||||
new_order: (data)->
|
||||
# return if @store.all('order').findProperty('id', data.order.id)
|
||||
@store.pushPayload data
|
||||
@store.findById('list', data.list.id).then (list)=> @set 'controllers.application.list', list
|
||||
@store.findById('list', data.list.id).then (list)=> @set 'globals.list', list
|
||||
# @store.findById('order', data.order.id).then (order)->
|
||||
# list = order.get('list')
|
||||
# list.get('orders').addObject(order)
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
App.JoinRequestsController = Ember.Controller.extend
|
||||
join_requests: (-> @get('controllers.application.list.join_requests') ).property('controllers.application.list.join_requests')
|
||||
join_requests: (-> @get('globals.list.join_requests') ).property('globals.list.join_requests')
|
||||
actions:
|
||||
rejectRequest: (join_request)->
|
||||
Ember.$.post("#{$data_host}/user/reject_join_request", user_id: join_request.get('user.id')).then (response)->
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
@App.modals.BaseController = Ember.Controller.extend
|
||||
alert_message: ""
|
||||
#modal_options: Ember.Object.create(closeOnOverlay: true, closeOnModalClick: false)
|
||||
title: (->
|
||||
# return title if directly set by options
|
||||
return @get('modal_options.title') if @get('modal_options.title')
|
||||
|
||||
@@ -0,0 +1,2 @@
|
||||
@App.modals.ConfirmController = @App.modals.BaseController.extend
|
||||
body: Ember.computed 'modal_options.body', -> @get('modal_options.body')
|
||||
@@ -12,14 +12,14 @@ App.ProductOrdersController = Ember.Controller.extend
|
||||
# @get('product_orders').invoke 'eraseRecord'
|
||||
orderProducts: ->
|
||||
# table = @get('controllers.table.model')
|
||||
# list = @get('controllers.application.list')
|
||||
# list = @get('globals.list')
|
||||
# order = @store.createRecord('order', list: list, table: table)
|
||||
# new_product_orders = @store.all('product_order').filterProperty('order', null)
|
||||
# order.get('product_orders').pushObjects(new_product_orders)
|
||||
#
|
||||
# order.save().then (response)=>
|
||||
# new_product_orders.invoke 'eraseRecord'
|
||||
# if @get('controllers.application.list')
|
||||
# if @get('globals.list')
|
||||
# @transitionToRoute 'active_list'
|
||||
# else
|
||||
# # Get list info from the server
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
App.TableController = Ember.Controller.extend
|
||||
join_request_sent: (-> @get('controllers.application.join_request_sent')).property('controllers.application.join_request_sent')
|
||||
tableCanTakeOrders: (->
|
||||
return false unless @get('supplier.can_take_orders')
|
||||
list = @get('globals.list')
|
||||
@@ -10,14 +9,14 @@ App.TableController = Ember.Controller.extend
|
||||
else
|
||||
# no list and open supplier
|
||||
if @get('model.occupied') then false else true
|
||||
).property('controllers.application.list.id', 'supplier.can_take_orders', 'model.occupied', 'model.id', 'controllers.application.list.table.id')
|
||||
).property('globals.list.id', 'supplier.can_take_orders', 'model.occupied', 'model.id', 'globals.list.table.id')
|
||||
supplier: Ember.computed 'model.supplier', -> @get('model.supplier')
|
||||
showJoinButton: (->
|
||||
return false unless @get('supplier.can_take_orders')
|
||||
return false if @get('controllers.application.list') # if you already have an active list, do not join another
|
||||
return false if @get('globals.list') # if you already have an active list, do not join another
|
||||
if @get('model.occupied') then true else false # no point in joining tables that are not occupied
|
||||
).property('controllers.application.list.id', 'supplier.can_take_orders', 'model.occupied', 'model.id', 'controllers.application.list.table.id')
|
||||
).property('globals.list.id', 'supplier.can_take_orders', 'model.occupied', 'model.id', 'globals.list.table.id')
|
||||
actions:
|
||||
joinOccupiedTable: ->
|
||||
Ember.$.post("#{$data_host}/user/join_occupied_table.json", table_id: @get('model.id'))
|
||||
@set 'controllers.application.join_request_sent', true # keeps the button deactivated
|
||||
@set 'globals.join_request_sent', true # keeps the button deactivated
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
App.ActiveListRoute = Ember.Route.extend App.ResetScroll
|
||||
#model: ->
|
||||
#@get('controllers.application.list')
|
||||
#@get('globals.list')
|
||||
#afterModel: ->
|
||||
#controller = @controllerFor('application')
|
||||
#table_id = controller.get('list.table.id')
|
||||
|
||||
@@ -55,7 +55,7 @@ App.ApplicationRoute = Ember.Route.extend
|
||||
defaultModalOptions =
|
||||
closeOnOverlay: true
|
||||
closeOnModalClick: false
|
||||
controller.set 'modal_options', $.extend(defaultModalOptions, options)
|
||||
controller.set 'modal_options', Ember.Object.create($.extend(defaultModalOptions, options))
|
||||
@render "modals/#{modalName}",
|
||||
into: 'application'
|
||||
outlet: 'modal'
|
||||
@@ -68,11 +68,8 @@ App.ApplicationRoute = Ember.Route.extend
|
||||
parentView: 'application'
|
||||
|
||||
confirm: (options = {})->
|
||||
@send 'openModal', 'confirm',
|
||||
model: Ember.Object.create(body: options.body)
|
||||
title: options.title
|
||||
cancel: options.cancel
|
||||
ok: options.ok
|
||||
options.model ||= Ember.Object.create()
|
||||
@send 'openModal', 'confirm', options
|
||||
sendFeedback: (feedback, callback)->
|
||||
return unless feedback
|
||||
$.post $user_feedback_path, feedback: feedback, callback
|
||||
@@ -124,8 +121,8 @@ App.ApplicationRoute = Ember.Route.extend
|
||||
else
|
||||
## Offer to move table
|
||||
@send 'confirm',
|
||||
title: t('move_table.confirmation_title')
|
||||
body: t('move_table.confirmation_body')
|
||||
title: t('move_table.confirmation_title', res.table)
|
||||
body: t('move_table.confirmation_body', res.table)
|
||||
ok: =>
|
||||
Ember.$.post "#{$data_host}/user/move_table.json", table_id: table._id, (res2)=>
|
||||
if res2.occupied
|
||||
|
||||
@@ -3,9 +3,9 @@
|
||||
span.supplier-name= supplier.name
|
||||
span.table-number
|
||||
' #
|
||||
= number
|
||||
= model.number
|
||||
if showJoinButton
|
||||
if join_request_sent
|
||||
if globals.join_request_sent
|
||||
button.disabled
|
||||
span.fa.fa-spinner.fa-spin.fa-lg
|
||||
span=t 'join_request.requestor.waiting_for_approval'
|
||||
|
||||
@@ -9,5 +9,4 @@
|
||||
|
||||
$.extend($translations.en, <%= I18n.t('user', locale: :en).to_json %>);
|
||||
$.extend($translations.nl, <%= I18n.t('user', locale: :nl).to_json %>);
|
||||
|
||||
setLocale()
|
||||
|
||||
Reference in New Issue
Block a user