user upgrades

This commit is contained in:
2014-09-15 15:47:51 +02:00
parent 7ca7dc4d12
commit 04adfbcd66
11 changed files with 75 additions and 34 deletions
@@ -15,3 +15,4 @@ App.Router.map ->
@route 'settings'
@route 'product_orders'
@route 'error'
@route 'scanning'
@@ -101,34 +101,35 @@ App.ApplicationRoute = Ember.Route.extend
<% if Rails.env.user_app? %>
ar = @
scanner = cordova.require("cordova/plugin/BarcodeScanner")
scanner.scan (result)->
if result.cancelled
ar.transitionTo('index')
$log
action: 'qrscan'
result: 'cancel'
else
table_id_index = result.text.indexOf('s?t=');
if table_id_index > -1
table_id = result.text.substr(table_id_index + 4);
# ar.transitionTo 'table', table_id
# ar.actions.selectQr.call(ar, table: {_id: table_id})
ar.send('selectQr', _id: table_id)
else
ar.transitionTo('index').then (route)->
route.get('controller.controllers.application').set 'notice', "we got a barcode: '#{result.text}' but cannot extract a table id"
@transitionTo('scanning').then ->
scanner.scan (result)->
if result.cancelled
ar.transitionTo('index')
$log
action: 'qrscan'
error: 'cannot extract table id'
info: result.text
result: 'cancel'
else
table_id_index = result.text.indexOf('s?t=');
if table_id_index > -1
table_id = result.text.substr(table_id_index + 4);
# ar.transitionTo 'table', table_id
# ar.actions.selectQr.call(ar, table: {_id: table_id})
ar.send('selectQr', _id: table_id)
else
ar.transitionTo('index').then (route)->
route.get('controller.controllers.application').set 'notice', "we got a barcode: '#{result.text}' but cannot extract a table id"
$log
action: 'qrscan'
error: 'cannot extract table id'
info: result.text
, (error)->
$log
action: 'qrscan'
error: 'scan failed'
info: error
ar.transitionTo('index').then (route)->
route.get('controller.controllers.application').set 'notice', "scanning failed: #{error}"
, (error)->
$log
action: 'qrscan'
error: 'scan failed'
info: error
ar.transitionTo('index').then (route)->
route.get('controller.controllers.application').set 'notice', "scanning failed: #{error}"
<% else %>
@transitionTo 'select_qrcode'
<% end %>
@@ -0,0 +1,3 @@
.page-scanning
.scanning-qr-image: span
.scanning-laser