Add remove list needs payment functionality
This commit is contained in:
@@ -49,4 +49,7 @@ App.List = DS.Model.extend
|
||||
is_helped: ->
|
||||
@markHelped()
|
||||
$.post Routes.supplier_mark_list_as_helped_path(), list_id: @id
|
||||
remove_needs_payment: ->
|
||||
@set 'needs_payment', false
|
||||
$.post Routes.supplier_remove_list_needs_payment_path(), list_id: @id
|
||||
sorted_orders: (-> @get('relevant_orders').sortBy('created_at').reverseObjects()).property('relevant_orders.@each.isLoaded')
|
||||
|
||||
@@ -17,6 +17,7 @@ td.actions
|
||||
i.fa.fa-bell.fa-stack-small
|
||||
i.fa.fa-ban.revoke
|
||||
App.MarkListHelpedButtonView content=view.content
|
||||
App.RemoveListNeedsPaymentView content=view.content
|
||||
App.CloseListButtonView content=view.content
|
||||
|
||||
button.show-list.button{action "showList" view.content.id}: span
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
span.fa-stack.fa-2x.fa-stack-sized
|
||||
i.fa.fa-money.fa-stack-small
|
||||
i.fa.fa-ban.revoke
|
||||
@@ -0,0 +1,7 @@
|
||||
App.RemoveListNeedsPaymentView = Ember.View.extend
|
||||
templateName: 'remove_list_needs_payment_button'
|
||||
classNames: ['remove_list_needs_payment']
|
||||
classNameBindings: ['content.needs_payment:show:hide']
|
||||
tagName: 'button'
|
||||
click: (e)->
|
||||
@get('content').then (l)->l.remove_needs_payment()
|
||||
@@ -60,6 +60,10 @@ root.Qsupplier =
|
||||
else if e.event == 'order_being_delivered'
|
||||
order.markDelivered() if order = App.Order.findCached(e.data.id)
|
||||
|
||||
else if e.event == 'remove_list_needs_payment'
|
||||
if list = App.List.findCached(e.data.id)
|
||||
list.set 'needs_payment', false
|
||||
|
||||
else if e.event == 'orders_in_process_count'
|
||||
$('.supplier-orders-in-process-count-number').text e.data.count
|
||||
else if e.event == 'orders_placed_count'
|
||||
|
||||
@@ -78,6 +78,9 @@ App.ApplicationController = Ember.Controller.extend
|
||||
# list.get('orders').addObject(order)
|
||||
|
||||
|
||||
remove_list_needs_payment: (data)->
|
||||
if list = @store.all('list').findBy 'id', data.id
|
||||
list.set 'needs_payment', false
|
||||
setCurrentList: (callback)->
|
||||
success = (list)=>
|
||||
#@store.find('list', 'current').deleteRecord() # gets not replaced, buty stays as dummy
|
||||
|
||||
@@ -19,6 +19,12 @@ $button-spacing: 8px
|
||||
padding-left: 8px //do not ask me why, just looks
|
||||
padding-right: 2px //do not ask me why, just looks
|
||||
margin-right: $button-spacing
|
||||
.remove_list_needs_payment
|
||||
+button-icon-only
|
||||
vertical-align: top
|
||||
padding-left: 8px //do not ask me why, just looks
|
||||
padding-right: 2px //do not ask me why, just looks
|
||||
margin-right: $button-spacing
|
||||
.close-list-button
|
||||
+button-icon-only
|
||||
.active-orders-table
|
||||
|
||||
@@ -66,7 +66,7 @@ class SupplierController < ApplicationController
|
||||
ho[:list_id] = order.list_id
|
||||
list_total += ho[:total_amount]
|
||||
h[:orders] << ho
|
||||
end
|
||||
end
|
||||
h[:total_amount] = list_total.round(2)
|
||||
render json: h, layout: 'tablet'
|
||||
end
|
||||
@@ -87,7 +87,7 @@ class SupplierController < ApplicationController
|
||||
hl = list.with_info_as_json
|
||||
grand_total += hl[:total_amount]
|
||||
h[:lists] << hl
|
||||
end
|
||||
end
|
||||
h[:total_amount] = grand_total.round(2)
|
||||
render json: h, layout: 'tablet'
|
||||
end
|
||||
@@ -101,13 +101,20 @@ class SupplierController < ApplicationController
|
||||
render nothing: true
|
||||
end
|
||||
|
||||
# POST /orders/1/is_helped
|
||||
# POST /supplier/mark_list_as_helped
|
||||
def mark_list_as_helped
|
||||
@list = List.find_by_supplier_id_and_id(current_supplier.id, params[:list_id])
|
||||
@list.is_helped!
|
||||
render nothing: true
|
||||
end
|
||||
|
||||
#POST /supplier/remove_list_needs_payment
|
||||
def remove_list_needs_payment
|
||||
@list = List.find_by_supplier_id_and_id(current_supplier.id, params[:list_id])
|
||||
@list.remove_needs_payment!
|
||||
render nothing: true
|
||||
end
|
||||
|
||||
# POST /orders/1/is_being_processed
|
||||
def mark_order_in_process
|
||||
@order = Order.find_by_supplier_id_and_id!(current_supplier.id, params[:order_id])
|
||||
|
||||
@@ -172,6 +172,14 @@ class List
|
||||
end
|
||||
end
|
||||
|
||||
def remove_needs_payment!
|
||||
self.needs_payment = false
|
||||
if save
|
||||
broadcast_users 'remove_list_needs_payment', id: id
|
||||
broadcast_supplier supplier_id, 'remove_list_needs_payment', id: id
|
||||
end
|
||||
end
|
||||
|
||||
def needs_payment!
|
||||
self.needs_payment = true
|
||||
if save
|
||||
|
||||
Reference in New Issue
Block a user