User specs in the green
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
App.ButtonChangeListTableComponent = Ember.Component.extend
|
||||
layoutName: 'components/button/change-list-table'
|
||||
tagName: 'button'
|
||||
classNames: ['change-list-table-button']
|
||||
click: ->
|
||||
@modal 'change-list-table',
|
||||
model: @list
|
||||
|
||||
@@ -22,7 +22,7 @@
|
||||
#underscored = @constructor.toString().replace(/[a-zA-Z_-]+\@controller:modals\//, '').replace(/:$/, '').underscore() # ember cli
|
||||
# find translated title or humanize the controller name
|
||||
if convention_translation = ttry("modal.#{underscored}.title", translation_params)
|
||||
tspan(@get("modal.#{underscored}.title"), translation_params).htmlSafe()
|
||||
tspan("modal.#{underscored}.title", translation_params).htmlSafe()
|
||||
else
|
||||
underscored.capitalize().replace(/_/, ' ')
|
||||
).property('model.id', 'modal_options.title_path')
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
App.modals.ChangeListTableController = @App.modals.BaseController.extend
|
||||
list_moving: false
|
||||
sections: Ember.computed -> @store.peekAll('section')
|
||||
actions:
|
||||
moveToTable: (table)->
|
||||
@set 'list_moving', true
|
||||
Ember.$.post Routes.change_table_suppliers_list_path(@get('model.id')), {table_id: table.id}, (response)=>
|
||||
#@set "model.table", table
|
||||
@send 'close'
|
||||
@@ -0,0 +1,3 @@
|
||||
App.TableNumberHelper = Ember.Helper.helper (params, options)->
|
||||
table_number = params[0]
|
||||
"# #{table_number}".htmlSafe()
|
||||
@@ -16,13 +16,29 @@ App.List = DS.Model.extend
|
||||
#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
|
||||
active: ( -> @get('state') is 'active' ).property('state')
|
||||
|
||||
# COMPUTED PROPERTIES
|
||||
active: Ember.computed.equal 'state', 'active'
|
||||
total: (->
|
||||
@get('relevant_orders').getEach('total').reduce(((sum, total) -> sum + total), 0)
|
||||
).property('relevant_orders.@each.total')
|
||||
relevant_orders: (-> @get('orders').filter((o)->o.get('state') isnt 'cancelled')).property('orders.@each.state')
|
||||
active_orders: (-> @get('orders').filter((o)->o.get('state') is 'placed' or o.get('state') is 'active')).property('orders.@each.state')
|
||||
sorted_orders: (-> @get('relevant_orders').sortBy('created_at').reverseObjects()).property('relevant_orders.[]')
|
||||
|
||||
has_active_orders: (->
|
||||
return false unless @get('state') == 'active'
|
||||
!!@get('orders').filter( (order) -> order.get('state') is 'active' or order.get('state') is 'placed').length
|
||||
).property('state', 'orders.@each.state')
|
||||
|
||||
isClosed: ->
|
||||
@set('state', 'closed')
|
||||
#@set 'has_active_orders', false
|
||||
@set 'table', null
|
||||
@isHelped()
|
||||
@isPaid()
|
||||
|
||||
# EVENTS
|
||||
isHelped: ->
|
||||
@set 'needs_help', false
|
||||
isNeedingHelp: ->
|
||||
@@ -31,24 +47,14 @@ App.List = DS.Model.extend
|
||||
@set 'needs_payment', true
|
||||
isPaid: ->
|
||||
@set 'needs_payment', false
|
||||
relevant_orders: (-> @get('orders').filter((o)->o.get('state') isnt 'cancelled')).property('orders.@each.state')
|
||||
active_orders: (-> @get('orders').filter((o)->o.get('state') is 'placed' or o.get('state') is 'active')).property('orders.@each.state')
|
||||
|
||||
total: (->
|
||||
@get('relevant_orders').getEach('total').reduce(((sum, total) -> sum + total), 0)
|
||||
).property('relevant_orders.@each.total')
|
||||
has_active_orders: (->
|
||||
return false unless @get('state') == 'active'
|
||||
!!@get('orders').filter( (order) -> order.get('state') is 'active' or order.get('state') is 'placed').length
|
||||
).property('state', 'orders.@each.state')
|
||||
# TRIGGERS
|
||||
close: ->
|
||||
@isClosed()
|
||||
$.post Routes.close_suppliers_list_path(@id)
|
||||
|
||||
markHelped: ->
|
||||
@isHelped()
|
||||
$.post Routes.mark_helped_suppliers_list_path(@id)
|
||||
remove_needs_payment: ->
|
||||
@set 'needs_payment', false
|
||||
$.post Routes.remove_needs_payment_suppliers_list_path(@id)
|
||||
sorted_orders: (-> @get('relevant_orders').sortBy('created_at').reverseObjects()).property('relevant_orders.@each.isLoaded')
|
||||
|
||||
@@ -6,6 +6,7 @@ App.Section = DS.Model.extend
|
||||
tables: DS.hasMany('table', async: false)
|
||||
section_elements: DS.hasMany('section-element', async: false)
|
||||
section_areas: DS.hasMany('section-area', async: false)
|
||||
sorted_tables: Ember.computed 'tables.[]', -> @get('tables').sortBy('number')
|
||||
|
||||
editmode: false
|
||||
|
||||
|
||||
@@ -138,7 +138,8 @@ App.ApplicationRoute = Ember.Route.extend
|
||||
if data.payload
|
||||
@store.pushPayload(data.payload)
|
||||
try ion.sound.play('water_droplet')
|
||||
list_changed_table: (data) -> @store.pushPayload('list', lists: [data.list])
|
||||
list_changed_table: (data)->
|
||||
@store.pushPayload(data.payload)
|
||||
list_closed: (data) -> list.isClosed() if list = @store.peekRecord('list', data.id)
|
||||
list_helped: (data) -> list.isHelped() if list = @store.peekRecord('list', data.id)
|
||||
remove_list_needs_payment: (data) -> list.set('needs_payment', false) if list = @store.peekRecord('list', data.id)
|
||||
|
||||
+1
@@ -0,0 +1 @@
|
||||
span.fa.fa-random
|
||||
@@ -7,8 +7,16 @@ if list.closed_at
|
||||
.display-field=time list.closed_at
|
||||
.display-row
|
||||
.display-label=t 'attributes.list.state'
|
||||
.display-field
|
||||
=state 'list' list.state
|
||||
.display-field=state 'list' list.state
|
||||
if list.active
|
||||
.display-row
|
||||
.display-label=t 'models.section'
|
||||
.display-field= list.table.section.title
|
||||
.display-row
|
||||
.display-label=t 'models.table'
|
||||
.display-field
|
||||
= table-number list.table.number
|
||||
= button-change-list-table list=list
|
||||
.display-row
|
||||
.display-label
|
||||
.display-field
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
h3= tables.length
|
||||
each sections as |section|
|
||||
h3= section.title
|
||||
ul.change-list-table-section-tables
|
||||
each section.sorted_tables as |table|
|
||||
unless table.active_list
|
||||
li: a{action "moveToTable" table}= table-number table.number
|
||||
@@ -14,7 +14,6 @@
|
||||
errors: <%= I18n.t('errors', locale: :nl).to_json %>
|
||||
date: <%= {day_name: Hash[Date::DAYNAMES.map(&:downcase).zip(I18n.t('date.day_names', locale: :nl))]}.to_json %>
|
||||
|
||||
|
||||
@day_minutes_to_time = (minutes)->
|
||||
return "" unless minutes
|
||||
[("0" + Math.floor(minutes/60)).substr(-2,2), ("0" + Math.floor(minutes%60)).substr(-2,2)].join(":")
|
||||
|
||||
@@ -16,7 +16,19 @@ td.boolean
|
||||
.boolean-false
|
||||
@extend .fa, .fa-lg, .fa-minus
|
||||
|
||||
|
||||
.change-list-table-button
|
||||
+button($bg: $warning-color, $padding: $button-tny)
|
||||
margin: 0
|
||||
.change-list-table-section-tables
|
||||
list-style: none
|
||||
+clearfix
|
||||
li
|
||||
float: left
|
||||
margin-right: 10px
|
||||
margin-bottom: 10px
|
||||
a
|
||||
+button($padding: $button-sml)
|
||||
margin: 0
|
||||
td.colorbox
|
||||
+table-fit
|
||||
.list-orders-container
|
||||
|
||||
Reference in New Issue
Block a user