serializer stuff
This commit is contained in:
@@ -2,8 +2,9 @@ attr = DS.attr
|
||||
App.EmployeeShift = DS.Model.extend
|
||||
start_from: attr('moment')
|
||||
end_on: attr('moment')
|
||||
employee: DS.belongsTo 'employee'
|
||||
description: attr('string')
|
||||
employee: DS.belongsTo 'employee', async: false
|
||||
supplier: DS.belongsTo 'supplier', async: false
|
||||
calendar_event: (->
|
||||
id: @id
|
||||
title: @get('title')
|
||||
@@ -11,7 +12,6 @@ App.EmployeeShift = DS.Model.extend
|
||||
end: @get('end_on')
|
||||
color: @get('employee.color')
|
||||
).property('start_from', 'end_on', 'title')
|
||||
supplier: DS.belongsTo('supplier')
|
||||
|
||||
title: Ember.computed 'employee.name', 'description', ->
|
||||
if @get('description')
|
||||
|
||||
@@ -5,18 +5,17 @@ App.List = DS.Model.extend
|
||||
needs_payment: attr 'boolean'
|
||||
user_requests_closing: attr('boolean')
|
||||
# users: DS.hasMany('user', async: true)
|
||||
users: DS.hasMany('user')
|
||||
is_paid: attr 'boolean'
|
||||
price: attr 'number'
|
||||
#has_active_orders: attr 'boolean'
|
||||
|
||||
price: attr 'number'
|
||||
closed_at: DS.attr('date')
|
||||
users: DS.hasMany('user', async: false)
|
||||
#table_number: attr 'number'
|
||||
table: DS.belongsTo('table', inverse: 'active_list', async: true)
|
||||
table: DS.belongsTo('table', inverse: 'active_list', async: false) # should be async, but synchroneously loading now fails with JSONAPI, this seems to work
|
||||
#users: DS.hasMany('user', inverse: 'active_list')
|
||||
orders: DS.hasMany('order')
|
||||
section: DS.belongsTo('section')
|
||||
section_id: attr('string')
|
||||
orders: DS.hasMany('order', async: false)
|
||||
section: DS.belongsTo('section', async: false) # should be async, but synchroneously loading now fails with JSONAPI, this seems to work
|
||||
active: ( -> @get('state') is 'active' ).property('state')
|
||||
isClosed: ->
|
||||
@set('state', 'closed')
|
||||
|
||||
@@ -11,7 +11,7 @@ App.Order = DS.Model.extend
|
||||
active: (-> @get('state') == 'active').property('state')
|
||||
delivered: (-> @get('state') == 'delivered').property('state')
|
||||
placed: (-> @get('state') == 'placed').property('state')
|
||||
needs_supplier_attention: (-> (@get('state') == 'placed') || (@get('state') == 'active')).property('state')
|
||||
needs_supplier_attention: (-> (@get('state') is 'placed') or (@get('state') is 'active')).property('state')
|
||||
|
||||
isClosed: ->
|
||||
@set 'state', 'closed'
|
||||
|
||||
@@ -8,9 +8,9 @@ App.Product = DS.Model.extend Ember.Validations.Mixin,
|
||||
active: attr('boolean', defaultValue: true)
|
||||
position: attr('number', defaultValue: 0)
|
||||
image: attr()
|
||||
product_category: DS.belongsTo('product_category')
|
||||
product_orders: DS.hasMany('product_order')
|
||||
product_variants: DS.hasMany('product_variant')
|
||||
product_category: DS.belongsTo('product_category', async: false)
|
||||
product_orders: DS.hasMany('product_order', async: false)
|
||||
product_variants: DS.hasMany('product_variant', async: false)
|
||||
|
||||
image_src: (->
|
||||
image = @get('image')
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
attr = DS.attr
|
||||
App.ProductCategory = DS.Model.extend Ember.Validations.Mixin,
|
||||
name: attr('string')
|
||||
products: DS.hasMany('product')
|
||||
supplier: DS.belongsTo 'supplier'
|
||||
active_on_sunday: attr('boolean', defaultValue: true)
|
||||
active_on_monday: attr('boolean', defaultValue: true)
|
||||
active_on_tuesday: attr('boolean', defaultValue: true)
|
||||
@@ -15,6 +13,9 @@ App.ProductCategory = DS.Model.extend Ember.Validations.Mixin,
|
||||
end_on: attr('number')
|
||||
position: attr('number')
|
||||
|
||||
products: DS.hasMany('product', async: false)
|
||||
supplier: DS.belongsTo 'supplier', async: false
|
||||
|
||||
sorted_products: (-> @get('products').sortBy('position') ).property('products.@each.position')
|
||||
|
||||
availability_text: Ember.computed 'active_on_sunday', 'active_on_monday', 'active_on_tuesday', 'active_on_wednesday', 'active_on_thursday', 'active_on_friday', 'active_on_saturday', 'full_day', 'start_from', 'end_on', ->
|
||||
|
||||
@@ -5,7 +5,7 @@ App.ProductOrder = DS.Model.extend
|
||||
product_variant: attr('string')
|
||||
product_name: attr('string')
|
||||
product: DS.belongsTo('product', async: true)
|
||||
order: DS.belongsTo('order')
|
||||
order: DS.belongsTo('order', async: false)
|
||||
increment: ->
|
||||
@set('quantity', @get('quantity') + 1)
|
||||
total: (-> @get('quantity') * @get('price')).property('quantity', 'price')
|
||||
|
||||
@@ -6,6 +6,6 @@ App.SectionArea = DS.Model.extend Ember.Validations.Mixin,
|
||||
position_x: attr 'number', defaultValue: 0
|
||||
position_y: attr 'number', defaultValue: 0
|
||||
rounded: attr 'boolean', defaultValue: false
|
||||
section: DS.belongsTo('section')
|
||||
section: DS.belongsTo('section', async: false)
|
||||
validations:
|
||||
title: {presence: true}
|
||||
|
||||
@@ -3,4 +3,4 @@ App.SectionElement = DS.Model.extend App.SvgElementMixin, App.Rotation,
|
||||
position_x: attr 'number', defaultValue: 0
|
||||
position_y: attr 'number', defaultValue: 0
|
||||
rotation: attr 'number', defaultValue: 0
|
||||
section: DS.belongsTo('section')
|
||||
section: DS.belongsTo('section', async: false)
|
||||
|
||||
@@ -15,9 +15,10 @@ App.Supplier = DS.Model.extend
|
||||
lat: attr 'number'
|
||||
lng: attr 'number'
|
||||
week_starts_on_monday: attr 'boolean'
|
||||
product_categories: DS.hasMany 'product_category'
|
||||
orders_in_process_count: attr('number')
|
||||
orders_placed_count: attr('number')
|
||||
|
||||
product_categories: DS.hasMany 'product_category', async: false
|
||||
employee_shifts: DS.hasMany('employee-shift')
|
||||
|
||||
close: ->
|
||||
|
||||
Reference in New Issue
Block a user