Fixes for user app table scanning and using the data host url for requests
This commit is contained in:
@@ -10,6 +10,7 @@ App.ApplicationController = Ember.Controller.extend
|
|||||||
@set 'notice', null
|
@set 'notice', null
|
||||||
openDebugger: ->
|
openDebugger: ->
|
||||||
debugger
|
debugger
|
||||||
|
|
||||||
currentPathDidChange: (->
|
currentPathDidChange: (->
|
||||||
@set 'notice', ''
|
@set 'notice', ''
|
||||||
).observes('currentPath')
|
).observes('currentPath')
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ App.JoinRequestsController = Ember.ArrayController.extend
|
|||||||
join_requests: (-> @get('controllers.application.list.join_requests') ).property('controllers.application.list.join_requests')
|
join_requests: (-> @get('controllers.application.list.join_requests') ).property('controllers.application.list.join_requests')
|
||||||
actions:
|
actions:
|
||||||
rejectRequest: (join_request)->
|
rejectRequest: (join_request)->
|
||||||
Ember.$.post('/user/reject_join_request', user_id: join_request.get('user.id')).then (response)->
|
Ember.$.post("#{$data_host}/user/reject_join_request", user_id: join_request.get('user.id')).then (response)->
|
||||||
join_request.eraseRecord()
|
join_request.eraseRecord()
|
||||||
approveRequest: (join_request)->
|
approveRequest: (join_request)->
|
||||||
Ember.$.post('/user/approve_join_request', user_id: join_request.get('user.id')).then (response)->
|
Ember.$.post("#{$data_host}/user/approve_join_request", user_id: join_request.get('user.id')).then (response)->
|
||||||
join_request.eraseRecord()
|
join_request.eraseRecord()
|
||||||
|
|||||||
@@ -1,37 +1 @@
|
|||||||
App.SelectQrcodeController = Ember.Controller.extend
|
App.SelectQrcodeController = Ember.Controller.extend {}
|
||||||
actions:
|
|
||||||
selectQr: (table)->
|
|
||||||
@secured ->
|
|
||||||
$.getJSON($data_host + '/user/table_info.json?'+@authentication_string+'&table_id='+table._id).then (res)=>
|
|
||||||
if res.current_table_id
|
|
||||||
if res.other_supplier
|
|
||||||
@redirect_to 'user_root', message: 'table_is_from_other_supplier'
|
|
||||||
else if res.current_table_id == table._id
|
|
||||||
#nothing has changed, show product list
|
|
||||||
@redirect_to 'table', table._id
|
|
||||||
else if res.current_table_id != table._id
|
|
||||||
if res.occupied
|
|
||||||
@redirect_to 'user_root', message: 'table_is_occupied'
|
|
||||||
else if res.reserved
|
|
||||||
@redirect_to 'user_root', message: 'table_is_reserved'
|
|
||||||
else if table.closed
|
|
||||||
@redirect_to 'user_root', message: 'table_is_closed'
|
|
||||||
else if res.supplier_closed
|
|
||||||
@redirect_to 'user_root', message: 'supplier_is_closed'
|
|
||||||
else
|
|
||||||
## Offer to move table
|
|
||||||
@send 'confirm',
|
|
||||||
title: t('move_table.confirmation_title')
|
|
||||||
body: t('move_table.confirmation_body')
|
|
||||||
ok: =>
|
|
||||||
Ember.$.post '/user/move_table.json', table_id: table._id, (res2)=>
|
|
||||||
if res2.occupied
|
|
||||||
@redirect_to 'user_root', message: 'move_table.cannot_move_to_occupied_tabe'
|
|
||||||
else
|
|
||||||
# Now we can move table
|
|
||||||
Qstorage.setItem 'table_id', table._id
|
|
||||||
@redirect_to 'table', table._id, message: 'move_table.moved_to_another_table'
|
|
||||||
cancel: =>
|
|
||||||
@redirect_to 'table', res.current_table_id
|
|
||||||
else
|
|
||||||
@redirect_to 'table', table._id
|
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ App.TableController = Ember.ObjectController.extend
|
|||||||
@store.createRecord 'product_order', product: product, price: product.get('price')
|
@store.createRecord 'product_order', product: product, price: product.get('price')
|
||||||
joinOccupiedTable: ->
|
joinOccupiedTable: ->
|
||||||
#@secured =>
|
#@secured =>
|
||||||
Ember.$.post('/user/join_occupied_table.json', table_id: @get('model.id'))
|
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 'controllers.application.join_request_sent', true # keeps the button deactivated
|
||||||
toggleProductCategory: (product_category)->
|
toggleProductCategory: (product_category)->
|
||||||
product_category.set 'collapsed', not product_category.get('collapsed')
|
product_category.set 'collapsed', not product_category.get('collapsed')
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
ControllerExtensions = Ember.Mixin.create
|
ControllerExtensions = Ember.Mixin.create
|
||||||
|
needs: ['application']
|
||||||
ajaxError: (callback)->
|
ajaxError: (callback)->
|
||||||
handler = (emberError)=>
|
handler = (emberError)=>
|
||||||
console.log "Error: status #{emberError.status}"
|
console.log "Error: status #{emberError.status}"
|
||||||
@@ -14,8 +15,8 @@ ControllerExtensions = Ember.Mixin.create
|
|||||||
@set 'controllers.application.modal.content', options.content if options.content
|
@set 'controllers.application.modal.content', options.content if options.content
|
||||||
Ember.ArrayController.reopen ControllerExtensions
|
Ember.ArrayController.reopen ControllerExtensions
|
||||||
Ember.Controller.reopen ControllerExtensions
|
Ember.Controller.reopen ControllerExtensions
|
||||||
|
Ember.ObjectController.reopen ControllerExtensions
|
||||||
Ember.Controller.reopen
|
Ember.Controller.reopen
|
||||||
needs: ['application']
|
|
||||||
secured: (callback)->
|
secured: (callback)->
|
||||||
unless Qstorage.getItem('auth_token') && typeof(Qstorage.getItem('auth_token')) == 'string' && Qstorage.getItem('auth_token').length > 0
|
unless Qstorage.getItem('auth_token') && typeof(Qstorage.getItem('auth_token')) == 'string' && Qstorage.getItem('auth_token').length > 0
|
||||||
return App.obtain_token()
|
return App.obtain_token()
|
||||||
@@ -58,7 +59,6 @@ Ember.Controller.reopen
|
|||||||
#$('#confirm-modal').css('visibility', 'visible').show()
|
#$('#confirm-modal').css('visibility', 'visible').show()
|
||||||
|
|
||||||
Ember.ArrayController.reopen
|
Ember.ArrayController.reopen
|
||||||
needs: ['application']
|
|
||||||
secured: (callback)->
|
secured: (callback)->
|
||||||
unless Qstorage.getItem('auth_token') && typeof(Qstorage.getItem('auth_token')) == 'string' && Qstorage.getItem('auth_token').length > 0
|
unless Qstorage.getItem('auth_token') && typeof(Qstorage.getItem('auth_token')) == 'string' && Qstorage.getItem('auth_token').length > 0
|
||||||
return App.obtain_token()
|
return App.obtain_token()
|
||||||
@@ -71,6 +71,3 @@ Ember.ArrayController.reopen
|
|||||||
if options.message
|
if options.message
|
||||||
tkey = if options.message.indexOf('.') > -1 then options.message else "messages.#{options.message}"
|
tkey = if options.message.indexOf('.') > -1 then options.message else "messages.#{options.message}"
|
||||||
@set 'controllers.application.notice', t(tkey)
|
@set 'controllers.application.notice', t(tkey)
|
||||||
|
|
||||||
Ember.ObjectController.reopen
|
|
||||||
needs: ['application']
|
|
||||||
|
|||||||
@@ -33,13 +33,13 @@ App.ApplicationRoute = Ember.Route.extend
|
|||||||
ok: options.ok
|
ok: options.ok
|
||||||
listNeedsPayment: ->
|
listNeedsPayment: ->
|
||||||
@get('controller').secured ->
|
@get('controller').secured ->
|
||||||
Ember.$.post '/user/list_needs_payment.json'
|
Ember.$.post "#{$data_host}/user/list_needs_payment.json"
|
||||||
#Ember.$.post('/user/list_needs_payment.json').then (res) =>
|
#Ember.$.post("#{$data_host}/user/list_needs_payment.json").then (res) =>
|
||||||
#@set('list.needs_payment', true) # also done by faye
|
#@set('list.needs_payment', true) # also done by faye
|
||||||
listNeedsHelp: ->
|
listNeedsHelp: ->
|
||||||
@get('controller').secured ->
|
@get('controller').secured ->
|
||||||
Ember.$.post '/user/needs_help.json'
|
Ember.$.post "#{$data_host}/user/needs_help.json"
|
||||||
#Ember.$.post('/user/needs_help.json').then (res) =>
|
#Ember.$.post("#{$data_host}/user/needs_help.json").then (res) =>
|
||||||
#@set('list.needs_help', true) # also done by faye
|
#@set('list.needs_help', true) # also done by faye
|
||||||
error: (error, transition, klass)->
|
error: (error, transition, klass)->
|
||||||
message = null
|
message = null
|
||||||
@@ -53,7 +53,48 @@ App.ApplicationRoute = Ember.Route.extend
|
|||||||
$log
|
$log
|
||||||
action: 'applicationerror'
|
action: 'applicationerror'
|
||||||
error: error.message
|
error: error.message
|
||||||
|
selectQr: (table)->
|
||||||
|
@get('controller').secured ->
|
||||||
|
appcontroller = @
|
||||||
|
$.getJSON( "#{$data_host}/user/table_info.json?table_id=#{table._id}").then (res)=>
|
||||||
|
if res.current_table_id
|
||||||
|
if res.other_supplier
|
||||||
|
@redirect_to 'user_root', message: 'table_is_from_other_supplier'
|
||||||
|
else if res.current_table_id == table._id
|
||||||
|
#nothing has changed, show product list
|
||||||
|
@redirect_to 'table', table._id
|
||||||
|
else if res.current_table_id != table._id
|
||||||
|
if res.occupied
|
||||||
|
@redirect_to 'user_root', message: 'table_is_occupied'
|
||||||
|
else if res.reserved
|
||||||
|
@redirect_to 'user_root', message: 'table_is_reserved'
|
||||||
|
else if table.closed
|
||||||
|
@redirect_to 'user_root', message: 'table_is_closed'
|
||||||
|
else if res.supplier_closed
|
||||||
|
@redirect_to 'user_root', message: 'supplier_is_closed'
|
||||||
|
else
|
||||||
|
## Offer to move table
|
||||||
|
@send 'confirm',
|
||||||
|
title: t('move_table.confirmation_title')
|
||||||
|
body: t('move_table.confirmation_body')
|
||||||
|
ok: =>
|
||||||
|
Ember.$.post "#{$data_host}/user/move_table.json", table_id: table._id, (res2)=>
|
||||||
|
if res2.occupied
|
||||||
|
@redirect_to 'user_root', message: 'move_table.cannot_move_to_occupied_tabe'
|
||||||
|
else
|
||||||
|
# Now we can move table
|
||||||
|
Qstorage.setItem 'table_id', table._id
|
||||||
|
@redirect_to 'table', table._id, message: 'move_table.moved_to_another_table'
|
||||||
|
cancel: =>
|
||||||
|
@redirect_to 'table', res.current_table_id
|
||||||
|
else
|
||||||
|
@redirect_to 'table', table._id
|
||||||
|
, (error)->
|
||||||
|
if error.status is 404
|
||||||
|
message = 'table_not_found'
|
||||||
|
else
|
||||||
|
message = 'general_error'
|
||||||
|
appcontroller.redirect_to 'index', message: message
|
||||||
scanQr: ->
|
scanQr: ->
|
||||||
<% if Rails.env.user_app? %>
|
<% if Rails.env.user_app? %>
|
||||||
ar = @
|
ar = @
|
||||||
@@ -68,7 +109,9 @@ App.ApplicationRoute = Ember.Route.extend
|
|||||||
table_id_index = result.text.indexOf('s?t=');
|
table_id_index = result.text.indexOf('s?t=');
|
||||||
if table_id_index > -1
|
if table_id_index > -1
|
||||||
table_id = result.text.substr(table_id_index + 4);
|
table_id = result.text.substr(table_id_index + 4);
|
||||||
ar.transitionTo 'table', table_id
|
# ar.transitionTo 'table', table_id
|
||||||
|
# ar.actions.selectQr.call(ar, table: {_id: table_id})
|
||||||
|
ar.send('selectQr', _id: table_id)
|
||||||
else
|
else
|
||||||
ar.transitionTo('index').then (route)->
|
ar.transitionTo('index').then (route)->
|
||||||
route.get('controller.controllers.application').set 'notice', "we got a barcode: '#{result.text}' but cannot extract a table id"
|
route.get('controller.controllers.application').set 'notice', "we got a barcode: '#{result.text}' but cannot extract a table id"
|
||||||
@@ -85,6 +128,5 @@ App.ApplicationRoute = Ember.Route.extend
|
|||||||
ar.transitionTo('index').then (route)->
|
ar.transitionTo('index').then (route)->
|
||||||
route.get('controller.controllers.application').set 'notice', "scanning failed: #{error}"
|
route.get('controller.controllers.application').set 'notice', "scanning failed: #{error}"
|
||||||
<% else %>
|
<% else %>
|
||||||
# @transitionTo 'table', 'abc'
|
|
||||||
@transitionTo 'select_qrcode'
|
@transitionTo 'select_qrcode'
|
||||||
<% end %>
|
<% end %>
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ en:
|
|||||||
user:
|
user:
|
||||||
total: Total
|
total: Total
|
||||||
messages:
|
messages:
|
||||||
|
general_error: Something went wrong
|
||||||
cannot_order_on_non_active_list: You cannot place an order on a closed list
|
cannot_order_on_non_active_list: You cannot place an order on a closed list
|
||||||
no_active_list: There is no active list
|
no_active_list: There is no active list
|
||||||
order_is_placed: Your order has been received in good order
|
order_is_placed: Your order has been received in good order
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ nl:
|
|||||||
user:
|
user:
|
||||||
total: Totaal
|
total: Totaal
|
||||||
messages:
|
messages:
|
||||||
|
general_error: Er is iets misgegaan
|
||||||
cannot_order_on_non_active_list: Je kan niet bestellen op een gesloten lijst
|
cannot_order_on_non_active_list: Je kan niet bestellen op een gesloten lijst
|
||||||
no_active_list: Er is momenteel geen lijst actief
|
no_active_list: Er is momenteel geen lijst actief
|
||||||
order_is_placed: Je bestelling is in goede orde aangekomen
|
order_is_placed: Je bestelling is in goede orde aangekomen
|
||||||
|
|||||||
Reference in New Issue
Block a user