Upgrades and fixes, maintenance

This commit is contained in:
2014-06-09 19:07:46 +02:00
parent 78a894759b
commit 0e4993e8a6
23 changed files with 87 additions and 57 deletions
@@ -6,11 +6,15 @@ Qsupplier.App.List = DS.Model.extend
user_requests_closing: attr('boolean')
users: DS.hasMany('user')
is_paid: attr 'boolean'
has_active_orders: attr 'boolean'
#has_active_orders: attr 'boolean'
has_active_orders: (->
return false unless @get('state') == 'active'
!!@get('orders').filterProperty('state', 'active').length
).property('state', 'orders.@each.state')
price: attr 'number'
closed_at: DS.attr('date')
#table_number: attr 'number'
table: DS.belongsTo('table', inverse: 'active_list')
#table: DS.belongsTo('table', inverse: 'active_list')
#users: DS.hasMany('user', inverse: 'active_list')
orders: DS.hasMany('order')
section: DS.belongsTo('section')
@@ -18,7 +22,7 @@ Qsupplier.App.List = DS.Model.extend
active: ( -> @get('state') == 'active' ).property('state')
markClosed: ->
@set('state', 'closed')
@set 'has_active_orders', false
#@set 'has_active_orders', false
@markHelped()
@markIsPaid()
markHelped: ->
@@ -7,7 +7,9 @@ Qsupplier.App.Table = DS.Model.extend
position_y: attr 'number'
occupied: attr 'boolean'
section: DS.belongsTo('section')
#active_list: DS.belongsTo('list', key: 'active_list')
active_list: DS.belongsTo('list')
#list: DS.belongsTo('list')
#active_list: (->
#@get('list')
#).property('list')
@@ -1,3 +1,8 @@
Qsupplier.App.ApplicationRoute = Ember.Route.extend
beforeModel: ->
# Preload only active lists and orders
@store.find 'product_category'
#@store.find 'order', state: 'active' included in list
setupController: (controller)->
controller.set 'product_categories', @store.find('product_category')
@store.find 'list', state: 'active'
controller.set 'product_categories', @store.all('product_category')
@@ -1,17 +1,16 @@
Qsupplier.App.IndexRoute = Ember.Route.extend
model: (params, queryParams)->
# Preload only active lists and orders
@store.find 'list', state: 'active'
@store.find 'order', state: 'active'
Ember.Object.create
# Find with condition does not work since the resulting array promise is not updated for newly created records
#lists: Qsupplier.App.List.find({state: 'active'})
#orders: Qsupplier.App.Order.find({state: 'active'})
#lists: @store.filter 'list', (l)-> l.get('state') == 'active' # DOES NOT WORK!!!! (yet)
# use filter to create a scope on all the records
lists: @store.filter 'list', -> true
#lists: @store.filter 'list', -> true
lists: @store.all 'list'
# mayby @store.all 'list' will work better!!!! (2014-04-24 a more experienced benjamin :)
orders: @store.filter 'order', -> true
#orders: @store.filter 'order', -> true
orders: @store.all 'order'
sections: @store.find 'section'
setupController: (controller, model)->
controller.set('model', model)
@@ -1,16 +1,25 @@
$ ->
$('.week-day-toggle').each ->
select = $('#week-day-select-'+$(@).data('day'))
$(@).addClass('active') if select.val() == '1'
$(@).click( -> select.val(Math.abs(select.val() - 1)))
$(@).addClass(if select.val() == '1' then 'active' else 'inactive')
$(@).click ->
new_val = Math.abs(select.val() - 1)
select.val new_val
if new_val == 1
$(@).addClass('active')
$(@).removeClass('inactive')
else
$(@).addClass('inactive')
$(@).removeClass('active')
$('#full_day-controller').each ->
control = $('#product_category_full_day')
if control.is(':checked')
$('#sub-day-container').removeClass('hide')
$(@).removeClass 'active'
else
$('#sub-day-container').addClass('hide')
$(@).addClass('active')
else
$(@).removeClass 'active'
$('#sub-day-container').removeClass('hide')
$(@).click ->
if control.is(':checked')
control.prop 'checked', false