General functionality improvement

This commit is contained in:
2014-06-26 17:26:15 +02:00
parent 8730d30621
commit 2a30ff5d3d
19 changed files with 71 additions and 52 deletions
@@ -1,4 +1,5 @@
App.ApplicationController = Ember.Controller.extend
join_request_sent: false
notice: ''
actions:
confirmCancel: ->
@@ -39,11 +40,22 @@ App.ApplicationController = Ember.Controller.extend
join_request = @store.createRecord 'join_request', data.join_request
@transitionToRoute 'join_requests'
join_request_rejected: (data)->
# Remove join request from connected users
join_request = @store.all('join_request').findBy 'id', data.id
join_request.eraseRecord() if join_request
# Notify requestor in a proper manner
# NOTE data.id is in the form of: jr-:user_id
requestor_id = data.id.substr(3)
if requestor_id is Qstorage.getItem('user_id')
@set 'notice', t('join_request.requestor.join_request_rejected')
@set 'join_request_sent', false
join_request_approved: ->
@setCurrentList ->
@transitionToRoute 'active_list'
@transitionToRoute('active_list').then =>
@set 'notice', t('join_request.requestor.join_request_approved')
list_changed_table: ->
@setCurrentList()
@@ -69,4 +81,4 @@ App.ApplicationController = Ember.Controller.extend
@set 'list', null
@store.find('list', 'current').then(success, error)
didInsertElement: (e)->
debugger
#debugger
@@ -1,5 +1,5 @@
App.TableController = Ember.ObjectController.extend
join_request_sent: false
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('controllers.application.list')
@@ -14,7 +14,7 @@ App.TableController = Ember.ObjectController.extend
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
if @get('model.occupied') then true else false
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')
actions:
addProduct: (product)->
@@ -25,7 +25,7 @@ App.TableController = Ember.ObjectController.extend
joinOccupiedTable: ->
#@secured =>
Ember.$.post('/user/join_occupied_table.json', table_id: @get('model.id'))
@set 'join_request_sent', true # keeps the button deactivated
@set 'controllers.application.join_request_sent', true # keeps the button deactivated
toggleProductCategory: (product_category)->
product_category.set 'collapsed', not product_category.get('collapsed')
showProductDescription: (product)->