User app error handling upgrades

This commit is contained in:
2014-08-25 16:56:30 +02:00
parent 7a16650129
commit 1eeda440ab
11 changed files with 86 additions and 6 deletions
@@ -12,3 +12,4 @@ App.Router.map ->
@resource 'join_requests'
@resource 'lists', ->
@resource 'list', path: ':list_id'
@route 'error'
@@ -41,8 +41,47 @@ App.ApplicationRoute = Ember.Route.extend
Ember.$.post '/user/needs_help.json'
#Ember.$.post('/user/needs_help.json').then (res) =>
#@set('list.needs_help', true) # also done by faye
error: (error, transition, klass)->
message = null
if error.status is 404
if klass.routeName is 'table'
message = t('errors.404.model.message', model: t("models.#{klass.routeName}"), id: transition.state.params.table.table_id)
else
message = t('errors.404.general.message')
@transitionTo('index').then (route)->
route.get('controller.controllers.application').set 'notice', message
scanQr: ->
<% 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
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}"
<% else %>
# @transitionTo 'table', 'abc'
@transitionTo 'select_qrcode'
events: ->
error: (error)->
debugger
<% end %>
@@ -0,0 +1,2 @@
.row: h2=t 'app.error.title'
.row: p=t 'app.error.body'