End of day commit
This commit is contained in:
@@ -14,14 +14,12 @@ Qsupplier.App.IndexController = Ember.ObjectController.extend
|
||||
).property('orders.@each.state', 'sectionId')
|
||||
|
||||
markListAsHelped: (id)->
|
||||
list = Qsupplier.App.List.findCached(id)
|
||||
list.set('needs_help', false)
|
||||
$.post '/supplier/mark_list_as_helped', {list_id: id}
|
||||
if list = Qsupplier.App.List.findCached(id)
|
||||
list.is_helped()
|
||||
|
||||
closeList: (id)->
|
||||
list = Qsupplier.App.List.findCached(id)
|
||||
list.set('state', 'closed')
|
||||
$.post '/supplier/close_list', {list_id: id}
|
||||
if list = Qsupplier.App.List.findCached(id)
|
||||
list.close()
|
||||
|
||||
markOrderDelivered: (id)->
|
||||
$.post('/supplier/order_is_delivered', order_id: id)
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
Qsupplier.App.SectionController = Ember.ObjectController.extend
|
||||
#width: -> $('.section-tables-active').width()
|
||||
#height: -> $('.section-tables-active').height()
|
||||
dummy: -> 3
|
||||
editmode: false
|
||||
makeEditable: -> @set('editmode', true)
|
||||
finishEditable: ->
|
||||
finishEditable: ->
|
||||
@set('editmode', false)
|
||||
@get('model').save()
|
||||
addTables: ->
|
||||
$('#add-tables-modal').modal()
|
||||
arrangeTables: ->
|
||||
$('#arrange-tables-modal').modal()
|
||||
actions:
|
||||
markListAsHelped: (list) -> list.is_helped() if list
|
||||
closeList: (list)-> list.close() if list
|
||||
textures: ['wood1', 'wood2']
|
||||
|
||||
|
||||
@@ -11,8 +11,25 @@ Qsupplier.App.List = DS.Model.extend
|
||||
orders: DS.hasMany('order')
|
||||
section: DS.belongsTo('section')
|
||||
section_id: attr('string')
|
||||
close: ->
|
||||
#@get('orders').forEach (order)->
|
||||
#order.close()
|
||||
#@set('table', null)
|
||||
active: ( -> @get('state') == 'active' ).property('state')
|
||||
markClosed: ->
|
||||
@set('state', 'closed')
|
||||
@set 'has_active_orders', false
|
||||
@markHelped()
|
||||
@markIsPaid()
|
||||
markHelped: ->
|
||||
@set 'needs_help', false
|
||||
markNeedsHelp: ->
|
||||
@set 'needs_help', true
|
||||
markNeedsPayment: ->
|
||||
@set 'needs_payment', true
|
||||
markIsPaid: ->
|
||||
@set 'needs_payment', false
|
||||
|
||||
close: ->
|
||||
@markClosed()
|
||||
$.post Routes.supplier_close_list_path(), list_id: @id
|
||||
|
||||
is_helped: ->
|
||||
@markHelped()
|
||||
$.post Routes.supplier_mark_list_as_helped_path(), list_id: @id
|
||||
|
||||
@@ -17,5 +17,5 @@ Qsupplier.App.Order = DS.Model.extend
|
||||
@get('product_orders').map((po)-> "#{po.product_name} (#{po.quantity})").join(',')
|
||||
).property('product_orders')
|
||||
|
||||
close: ->
|
||||
@set('state', 'closed')
|
||||
markClosed: ->
|
||||
@set 'state', 'closed'
|
||||
|
||||
@@ -7,10 +7,19 @@ DS.Model.reopenClass
|
||||
@store.all(@toString()).findProperty('id', id)
|
||||
updateOrAdd: (attributes)->
|
||||
if cached = @findCached(attributes.id)
|
||||
|
||||
# update relations if needed
|
||||
Ember.get(@, 'relationships').forEach (model, relation)=>
|
||||
relation = relation[0]
|
||||
if relation.kind == 'belongsTo'
|
||||
if id = attributes["#{relation.name}_id"]
|
||||
@store.find(relation.name, id).then (relation_object)->
|
||||
cached.set relation.name, relation_object
|
||||
cached.setProperties attributes
|
||||
cached
|
||||
else
|
||||
#@pushByAttriburtes(attributes)
|
||||
@store.find(@, attributes.id)
|
||||
#@store.find(@, attributes.id)
|
||||
@pushByAttriburtes(attributes)
|
||||
pushByAttriburtes: (attributes)->
|
||||
#store = @all().get('store')
|
||||
|
||||
|
||||
@@ -1,10 +1,18 @@
|
||||
.section-manage-tables.pull-right
|
||||
if editmode
|
||||
.btn-group
|
||||
a.btn.dropdown-toggle data-toggle="dropdown" href="#"
|
||||
a.btn.dropdown-toggle data-toggle="dropdown" href="#section-background"
|
||||
span Background
|
||||
span.caret
|
||||
ul#section-background.dropdown-menu
|
||||
each texture in textures
|
||||
li
|
||||
a{ action setTexture texture } {{texture}}
|
||||
.btn-group
|
||||
a.btn.dropdown-toggle data-toggle="dropdown" href="#section-actions"
|
||||
span Action
|
||||
span.caret
|
||||
ul.dropdown-menu
|
||||
ul#section-actions.dropdown-menu
|
||||
li
|
||||
a{action addTables} {{t 'section.add_tables.button_label'}}
|
||||
li
|
||||
|
||||
@@ -3,3 +3,13 @@
|
||||
span.needs_payment.icon-flag
|
||||
span.needs_help.icon-bell
|
||||
span.active_order.icon-glass
|
||||
div class="table-actions table-actions-#{unbound table.id}"
|
||||
.title {{table.number}}
|
||||
if table.active_list.needs_help
|
||||
.table-action-row
|
||||
button{ action markListAsHelped table.active_list } class="btn btn-info btn-small list-is-helped-button-#{unbound table.active_list.id}" {{t "list.is_helped_button"}}
|
||||
if table.active_list
|
||||
.table-action-row
|
||||
button{ action closeList table.active_list } class="btn btn-warning btn-small close-list" {{t 'list.close_list'}}
|
||||
/.table-action-row
|
||||
a href="suppliers_table_path(@table)" {{t 'section.tables_view.table_actions.got_to_table'}}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
ul
|
||||
if content.list.needs_help
|
||||
li
|
||||
button.btn.btn-info.btn-small id="list-is-helped-button-#{content.list.id}" onclick="Qsupplier.mark_list_as_helped('{{content.list.id}}')" {{t "list.is_helped_button"}}
|
||||
button.btn.btn-warning.btn-small class="of-list-#{content.list.id}" onclick="Qsupplier.close_list('#{content.list.id}')" data-t="list.close_list"
|
||||
if content.list.needs_help
|
||||
li
|
||||
a data-t='section.tables_view.table_actions.got_to_table' href="suppliers_table_path(@table)"
|
||||
button.btn.btn-info.btn-small id="list-is-helped-button-#{content.list.id}" onclick="Qsupplier.mark_list_as_helped('{{content.list.id}}')" {{t "list.is_helped_button"}}
|
||||
button.btn.btn-warning.btn-small class="of-list-#{content.list.id}" onclick="Qsupplier.close_list('#{content.list.id}')" data-t="list.close_list"
|
||||
li
|
||||
a data-t='section.tables_view.table_actions.got_to_table' href="suppliers_table_path(@table)" {{t 'section.tables_view.table_actions.got_to_table'}}
|
||||
|
||||
@@ -3,12 +3,16 @@ Qsupplier.App.SectionTableView = Ember.View.extend DragNDrop.Draggable,
|
||||
classNames: ['section-table']
|
||||
attributeBindings: ['style']
|
||||
classNameBindings: [
|
||||
'content.active_list:occupied',
|
||||
'content.active_list.active:occupied',
|
||||
'controller.editmode:draggable',
|
||||
'content.active_list.needs_help:needs_help',
|
||||
'content.active_list.needs_payment:needs_payment',
|
||||
'content.active_list.has_active_orders:active_order'
|
||||
'content.active_list.has_active_orders:active_order',
|
||||
'uniqueClass'
|
||||
]
|
||||
uniqueClass: (->
|
||||
"section-table-#{@get('content.id')}"
|
||||
).property('content.id')
|
||||
offsetX: (->
|
||||
return 0 unless section_width = @get('content.section.width')
|
||||
(@content.get('position_x') || 0) * @containerWidth() / section_width
|
||||
@@ -41,4 +45,25 @@ Qsupplier.App.SectionTableView = Ember.View.extend DragNDrop.Draggable,
|
||||
$(@get('parentView.element')).width()
|
||||
containerHeight: ->
|
||||
$(@get('parentView.element')).height()
|
||||
click: ->
|
||||
#click: ->
|
||||
#@$('.table-actions').show()
|
||||
didInsertElement: ->
|
||||
@$el = @$(@get('element'))
|
||||
#@$('.table-actions').hide()
|
||||
#title = @$('.table-actions .title').clone()
|
||||
content = @$('.table-actions')
|
||||
#@$('.table-actions .title').remove()
|
||||
content.hide()
|
||||
@$el.on 'click', =>
|
||||
content.toggle()
|
||||
#@$el.qtip
|
||||
#content:
|
||||
#text: content
|
||||
#title: title.html()
|
||||
#style:
|
||||
#classes: 'qtip-wiki qtip-light qtip-shadow'
|
||||
#show: 'click'
|
||||
#hide:
|
||||
#fixed: true
|
||||
#delay: 500
|
||||
#prerender: true
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
Qsupplier.App.TableActionsView = Ember.View.extend
|
||||
Qsupplier.App.TableActionsView = Ember.Component.extend
|
||||
tagName: 'ul'
|
||||
templateName: 'table_actions'
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
// require bootstrap-tooltip
|
||||
// require bootstrap-popover
|
||||
// require bootstrap-typeahead
|
||||
//= require bootstrap
|
||||
// require bootstrap
|
||||
//= require js-routes
|
||||
//= require qwaiter
|
||||
//= require ./qsupplier
|
||||
|
||||
@@ -13,20 +13,20 @@ root.Qsupplier=
|
||||
$('.section-table-list-'+order.list_id()).addClass('active_order')
|
||||
else if(e.event == 'list_needs_help')
|
||||
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
|
||||
list.set('needs_help', true)
|
||||
list.markNeedsHelp()
|
||||
# old stuff
|
||||
$('#list-needs-help-indicator-'+e.data.id).removeClass('hide')
|
||||
$('#list-is-helped-button-'+e.data.id).removeClass('hide')
|
||||
$('.section-table-list-'+e.data.id).addClass('needs_help')
|
||||
else if(e.event == 'list_needs_payment')
|
||||
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
|
||||
list.set('needs_payment', true)
|
||||
list.markNeedsPayment()
|
||||
# old stuff
|
||||
$('#list-needs-payment-indicator-'+e.data.id).removeClass('hide')
|
||||
$('.section-table-list-'+e.data.id).addClass('needs_payment')
|
||||
else if(e.event == 'list_is_paid')
|
||||
if list = Qsupplier.App.List.findCached(e.data.id)
|
||||
list.set('needs_payment', false)
|
||||
list.markIsPaid()
|
||||
else if e.event == 'list_update'
|
||||
Qsupplier.App.List.updateOrAdd(e.data.list) if Qsupplier.App
|
||||
# old stuff
|
||||
@@ -43,16 +43,17 @@ root.Qsupplier=
|
||||
table.addClass('active_order') if list.has_active_orders()
|
||||
else if e.event == 'list_closed'
|
||||
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
|
||||
list.close()
|
||||
list.markClosed()
|
||||
$('.list-row-'+e.data.id).remove()
|
||||
$('.of-list-'+e.data.id).remove()
|
||||
table_list_class = 'section-table-list-'+e.data.id
|
||||
$('.'+table_list_class).removeClass('occupied needs_help needs_payment active_order').removeClass(table_list_class)
|
||||
else if e.event == 'order_closed'
|
||||
order.close() if Qsupplier.App and order = Qsupplier.App.Order.findCached(e.data.id)
|
||||
order.markClosed() if Qsupplier.App and order = Qsupplier.App.Order.findCached(e.data.id)
|
||||
else if e.event == 'list_helped'
|
||||
if Qsupplier.App and list = Qsupplier.App.List.findCached(e.data.id)
|
||||
list.set('needs_help', false)
|
||||
list.markHelped()
|
||||
|
||||
list_id = e.data.id
|
||||
$('#list-needs-help-indicator-'+list_id).addClass('hide')
|
||||
$('#list-is-helped-button-'+list_id).addClass('hide')
|
||||
@@ -64,6 +65,9 @@ root.Qsupplier=
|
||||
$('.order-row-'+e.data.id).remove()
|
||||
$('.section-table-list-'+e.data.list_id).removeClass('active_order')
|
||||
else if e.event == 'list_changed_table'
|
||||
Qsupplier.App && Qsupplier.App.List.updateOrAdd(e.data.list)
|
||||
|
||||
# old stuff
|
||||
list = new List(e.data.list)
|
||||
list_row = $('.list-row-'+list.id())
|
||||
list_row.find('.table_number').text(list.table_number()).addClass('changed')
|
||||
|
||||
@@ -32,6 +32,20 @@
|
||||
float: right
|
||||
.action-button-container
|
||||
margin-right: -20px
|
||||
.table-actions
|
||||
display: none
|
||||
position: absolute
|
||||
left: 100%
|
||||
top: 0
|
||||
width: 140px
|
||||
text-align: center
|
||||
background-color: white
|
||||
border: 1px solid #aaa
|
||||
padding-bottom: 10px
|
||||
.title
|
||||
background-color: #aaa
|
||||
.table-action-row
|
||||
margin-top: 10px
|
||||
&.section-tables-active
|
||||
position: relative
|
||||
padding: 0
|
||||
|
||||
Reference in New Issue
Block a user