Model relation fixes and mobile device improvements
This commit is contained in:
@@ -50,7 +50,11 @@ App.MenuProductComponent = Ember.Component.extend
|
||||
removeProductVariant: (product_variant)->
|
||||
product_variant.destroyRecord()
|
||||
didInsertElement: ->
|
||||
@set 'editMode', true if @get('product.isNew')
|
||||
if @get('product.isNew')
|
||||
@set 'editMode', true
|
||||
Ember.run.later =>
|
||||
@$('input:first').focus()
|
||||
, 300
|
||||
namePlaceholder: (-> t "attributes.product.name").property()
|
||||
pricePlaceholder: (-> t "attributes.product.price").property()
|
||||
codePlaceholder: (-> t "attributes.product.code").property()
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
App.SectionsHeaderComponent = Ember.Component.extend
|
||||
classNames: ['sections-switcher-container', 'main-section-header']
|
||||
sections: (-> @get('targetObject.store').peekAll('section') ).property()
|
||||
sections: Ember.computed -> @store.peekAll('section')
|
||||
actions:
|
||||
setSection: (section)->
|
||||
if section and section is @get('active_section')
|
||||
|
||||
+7
-6
@@ -1,14 +1,15 @@
|
||||
App.IndexController = Ember.Controller.extend
|
||||
show_lists: true
|
||||
show_orders: true
|
||||
lists: (-> @store.peekAll('list')).property()
|
||||
loading_data: true
|
||||
lists: Ember.computed -> @store.peekAll('list')
|
||||
orders: Ember.computed -> @store.peekAll('order')
|
||||
sections: (-> @store.peekAll('section')).property()
|
||||
active_section: Ember.computed.alias 'globals.active_section'
|
||||
active_lists: Ember.computed 'lists.@each.state', 'active_section.id', 'lists.@each.table', ->
|
||||
sections: Ember.computed -> @store.peekAll('section')
|
||||
#active_section: Ember.computed.alias 'globals.active_section'
|
||||
active_lists: Ember.computed 'lists.@each.state', 'globals.active_section.id', 'lists.@each.table', ->
|
||||
@get('orders') # trigger orders, otherwise observers are not initialized/triggered (active_orders)
|
||||
if section_id = @get('active_section.id')
|
||||
lists = @get('lists').filter (l)=>( l.get('section.id') == section_id && l.get('state') == 'active' )
|
||||
if section_id = @get('globals.active_section.id')
|
||||
lists = @get('lists').filter (l)=>( l.get('table.section.id') == section_id && l.get('state') == 'active' )
|
||||
else
|
||||
lists = @get('lists').filterBy('state', 'active')
|
||||
lists.sortBy('created_at') # Not reversed, oldest on top, start with oldest order first, work your way down :-) Customer happyness
|
||||
@@ -27,4 +27,5 @@ App.MenuController = Ember.Controller.extend
|
||||
model: @store.createRecord('product_category', position: @get('product_categories.length'))
|
||||
close: -> @get('model').deleteRecord()
|
||||
addProduct: (product_category)->
|
||||
product_category.get('products').addObject @store.createRecord 'product', position: product_category.get('products.length')
|
||||
product = @store.createRecord 'product', position: product_category.get('products.length')
|
||||
product_category.get('products').addObject product
|
||||
|
||||
@@ -14,6 +14,8 @@ App.modals.EmployeeEditController = App.modals.BaseController.extend
|
||||
'#8A2BE2'
|
||||
'#458B00'
|
||||
'#EEAD0E'
|
||||
'#FF1493'
|
||||
'#8B0A50'
|
||||
]
|
||||
).property()
|
||||
actions:
|
||||
|
||||
@@ -11,6 +11,8 @@ App.modals.SectionAreaController = App.modals.BaseController.extend
|
||||
'#8A2BE2'
|
||||
'#458B00'
|
||||
'#EEAD0E'
|
||||
'#FF1493'
|
||||
'#8B0A50'
|
||||
]
|
||||
).property()
|
||||
actions:
|
||||
|
||||
@@ -2,5 +2,5 @@ App.OrdersDisplayController = Ember.Controller.extend
|
||||
sections: Ember.computed -> @store.peekAll('section')
|
||||
orders: Ember.computed 'model.[]', 'globals.active_section.id', ->
|
||||
orders = @get('model').filterBy('needs_supplier_attention')
|
||||
orders = orders.filterBy('list.section.id', id) if id = @get('globals.active_section.id')
|
||||
orders = orders.filterBy('list.table.section.id', id) if id = @get('globals.active_section.id')
|
||||
orders.sortBy('created_at') # Not reversed, oldest on top, start with oldest order first :-) Customer happyness
|
||||
|
||||
@@ -4,6 +4,7 @@ Globals = Ember.Object.extend
|
||||
isDragging: false
|
||||
active_section: null
|
||||
flash_message: ''
|
||||
modal_active: false
|
||||
locale: Qstorage.getItem('locale')
|
||||
App.initializer
|
||||
name: 'injectCurrent'
|
||||
|
||||
@@ -12,10 +12,9 @@ App.List = DS.Model.extend
|
||||
closed_at: DS.attr('date')
|
||||
users: DS.hasMany('user', async: false)
|
||||
#table_number: attr 'number'
|
||||
table: DS.belongsTo('table', inverse: 'active_list', async: false) # should be async, but synchroneously loading now fails with JSONAPI, this seems to work
|
||||
table: DS.belongsTo('table', inverse: 'active_list', async: true) # 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', async: false)
|
||||
section: DS.belongsTo('section', async: false) # should be async, but synchroneously loading now fails with JSONAPI, this seems to work
|
||||
|
||||
# COMPUTED PROPERTIES
|
||||
active: Ember.computed.equal 'state', 'active'
|
||||
|
||||
@@ -6,7 +6,7 @@ App.Table = DS.Model.extend
|
||||
position_x: attr 'number'
|
||||
position_y: attr 'number'
|
||||
# occupied: attr 'boolean'
|
||||
section: DS.belongsTo('section')
|
||||
section: DS.belongsTo('section', async: false)
|
||||
#active_list: DS.belongsTo('list', key: 'active_list')
|
||||
active_list: DS.belongsTo('list', async: true)
|
||||
#list: DS.belongsTo('list')
|
||||
|
||||
@@ -4,7 +4,7 @@ App.User= DS.Model.extend
|
||||
uid: attr('string')
|
||||
provider: attr('string')
|
||||
avatar: attr('string')
|
||||
list: DS.belongsTo('list') # in ember scope not many to many (yet)
|
||||
lists: DS.hasMany('list') # in ember scope not many to many (yet)
|
||||
join_requests: DS.hasMany('join_request')
|
||||
avatar_tag: Ember.computed 'avatar', 'name', ->
|
||||
avatar = @get('avatar') || "#{$asset_path}/supplier/unknown-avatar.png"
|
||||
|
||||
@@ -17,7 +17,8 @@ App.ApplicationRoute = Ember.Route.extend
|
||||
#@sections = @store.findAll 'section'
|
||||
#Ember.RSVP.all([@product_categories, @sections]).then (results)=>
|
||||
@supplier.reload().then =>
|
||||
@store.query('list', state: 'active') #.then (lists) -> lists.invoke('get', 'table')
|
||||
@store.query('list', state: 'active').then => #.then (lists) -> lists.invoke('get', 'table')
|
||||
@controllerFor('index').set 'loading_data', false
|
||||
#@lists = @store.peekAll 'list'
|
||||
# product_categories = controller.set 'product_categories', @store.peekAll('product_category')
|
||||
#@store.findAll 'order', state: 'active' included in list
|
||||
@@ -76,11 +77,13 @@ App.ApplicationRoute = Ember.Route.extend
|
||||
outlet: 'modal'
|
||||
view: 'modal'
|
||||
controller: controller
|
||||
@set 'globals.modal_active', true
|
||||
|
||||
closeModal: ->
|
||||
@disconnectOutlet
|
||||
outlet: 'modal'
|
||||
parentView: 'application'
|
||||
@set 'globals.modal_active', false
|
||||
confirm: (options = {})->
|
||||
@send 'openModal', 'confirm',
|
||||
model: Ember.Object.create
|
||||
@@ -131,7 +134,7 @@ App.ApplicationRoute = Ember.Route.extend
|
||||
@store.pushPayload(data.payload)
|
||||
if order_id = data.payload.data.id
|
||||
order = @store.peekRecord('order', order_id)
|
||||
return if @get('globals.active_section.id') and order.get('list.section.id') isnt @get('globals.active_section.id')
|
||||
return if @get('globals.active_section.id') and order.get('list.table.section.id') isnt @get('globals.active_section.id')
|
||||
@set 'globals.flash_message', order.get('display_with_table')
|
||||
try ion.sound.play('water_droplet')
|
||||
new_list: (data)->
|
||||
|
||||
@@ -34,7 +34,7 @@ if editMode
|
||||
= t 'product_variant.add_product_variant'
|
||||
else
|
||||
if showProduct
|
||||
.row
|
||||
.row.show-menu-product-row
|
||||
.small-3.columns
|
||||
span= product.name
|
||||
= errors product.errors.name includeAttribute="product"
|
||||
|
||||
@@ -11,6 +11,6 @@
|
||||
span.currency=currency list.total
|
||||
.actions
|
||||
= button-mark-list-helped content=list
|
||||
= button-remove-list-needs-payment content=list
|
||||
/= button-remove-list-needs-payment content=list
|
||||
= button-close-list content=list
|
||||
= button-show-list content=list
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
= link-to 'section' order.list.table.section class="link-to-section"
|
||||
span=order.list.table.section.title
|
||||
span.currency=currency order.total
|
||||
.show-list-button-container= button-show-list content=order.list
|
||||
span.time= time order.created_at format="HH:mm"
|
||||
.actions
|
||||
= button-mark-order-active order=order
|
||||
|
||||
@@ -1,37 +1,40 @@
|
||||
.row: .small-12.columns
|
||||
= sections-header active_section=globals.active_section
|
||||
if (can "manage" globals.current_supplier)
|
||||
unless globals.current_supplier.open
|
||||
.alert-box.alert.radius data-alert=true
|
||||
= t 'supplier.you_are_currently_closed_alert'
|
||||
a{ action "markSupplierOpen" }= t 'supplier.open_for_orders'
|
||||
.page-header
|
||||
if active_lists.length
|
||||
h3.dashboard-lists-header{action "toggleDashboardLists"}
|
||||
if show_lists
|
||||
span.icon
|
||||
else
|
||||
span.icon.collapsed
|
||||
=t 'active_lists.title'
|
||||
span= list_number_info
|
||||
else
|
||||
h3=t 'dashboard.active_lists.no_lists'
|
||||
if show_lists_table
|
||||
.active-lists-table
|
||||
each active_lists as |list|
|
||||
= dashboard-active-list list=list
|
||||
.page-header
|
||||
if active_orders.length
|
||||
h3.dashboard-orders-header{action "toggleDashboardOrders"}
|
||||
if show_orders
|
||||
span.icon
|
||||
else
|
||||
span.icon.collapsed
|
||||
=t 'active_orders.title'
|
||||
span= order_number_info
|
||||
else
|
||||
h3= t 'dashboard.active_orders.no_orders'
|
||||
if show_orders_table
|
||||
.active-orders-table
|
||||
each active_orders as |order|
|
||||
= dashboard-active-order order=order
|
||||
if loading_data
|
||||
.row: .small-12.columns: .panel: span.loading
|
||||
else
|
||||
.row: .small-12.columns
|
||||
= sections-header active_section=globals.active_section
|
||||
if (can "manage" globals.current_supplier)
|
||||
unless globals.current_supplier.open
|
||||
.alert-box.alert.radius data-alert=true
|
||||
= t 'supplier.you_are_currently_closed_alert'
|
||||
a{ action "markSupplierOpen" }= t 'supplier.open_for_orders'
|
||||
.page-header
|
||||
if active_lists.length
|
||||
h3.dashboard-lists-header{action "toggleDashboardLists"}
|
||||
if show_lists
|
||||
span.icon
|
||||
else
|
||||
span.icon.collapsed
|
||||
=t 'active_lists.title'
|
||||
span= list_number_info
|
||||
else
|
||||
h3=t 'dashboard.active_lists.no_lists'
|
||||
if show_lists_table
|
||||
.active-lists-table
|
||||
each active_lists as |list|
|
||||
= dashboard-active-list list=list
|
||||
.page-header
|
||||
if active_orders.length
|
||||
h3.dashboard-orders-header{action "toggleDashboardOrders"}
|
||||
if show_orders
|
||||
span.icon
|
||||
else
|
||||
span.icon.collapsed
|
||||
=t 'active_orders.title'
|
||||
span= order_number_info
|
||||
else
|
||||
h3= t 'dashboard.active_orders.no_orders'
|
||||
if show_orders_table
|
||||
.active-orders-table
|
||||
each active_orders as |order|
|
||||
= dashboard-active-order order=order
|
||||
|
||||
@@ -17,9 +17,10 @@ if list.active
|
||||
.display-field
|
||||
= button-change-list-table list=list
|
||||
.display-row
|
||||
.display-label
|
||||
.display-label.show-for-medium-up
|
||||
.display-field
|
||||
= button-mark-list-helped content=list
|
||||
= button-remove-list-needs-payment content=list
|
||||
= button-close-list content=list
|
||||
= users-buttons users=list.users
|
||||
if list.sorted_orders
|
||||
|
||||
Reference in New Issue
Block a user