From c01050361e01056262135c9d04dfd20fe82dbf17 Mon Sep 17 00:00:00 2001 From: Rob H Date: Fri, 11 Apr 2014 10:33:49 +1000 Subject: [PATCH] Use coffeescript syntactic sugar --- .../admin/bulk_order_management.js.coffee | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/app/assets/javascripts/admin/bulk_order_management.js.coffee b/app/assets/javascripts/admin/bulk_order_management.js.coffee index 02ac040d99..5066055642 100644 --- a/app/assets/javascripts/admin/bulk_order_management.js.coffee +++ b/app/assets/javascripts/admin/bulk_order_management.js.coffee @@ -73,28 +73,27 @@ orderManagementModule.factory "pendingChanges",[ pendingChanges: {} add: (id, attrName, changeObj) -> - this.pendingChanges["#{id}"] = {} unless this.pendingChanges.hasOwnProperty("#{id}") - this.pendingChanges["#{id}"]["#{attrName}"] = changeObj + @pendingChanges["#{id}"] = {} unless @pendingChanges.hasOwnProperty("#{id}") + @pendingChanges["#{id}"]["#{attrName}"] = changeObj removeAll: -> - this.pendingChanges = {} + @pendingChanges = {} remove: (id, attrName) -> - if this.pendingChanges.hasOwnProperty("#{id}") - delete this.pendingChanges["#{id}"]["#{attrName}"] - delete this.pendingChanges["#{id}"] if this.changeCount( this.pendingChanges["#{id}"] ) < 1 + if @pendingChanges.hasOwnProperty("#{id}") + delete @pendingChanges["#{id}"]["#{attrName}"] + delete @pendingChanges["#{id}"] if @changeCount( @pendingChanges["#{id}"] ) < 1 submitAll: -> all = [] - for id,lineItem of this.pendingChanges + for id,lineItem of @pendingChanges for attrName,changeObj of lineItem - all.push this.submit(id, attrName, changeObj) + all.push @submit(id, attrName, changeObj) all submit: (id, attrName, change) -> - factory = this - dataSubmitter(change).then (data) -> - factory.remove id, attrName + dataSubmitter(change).then (data) => + @remove id, attrName change.element.dbValue = data["#{attrName}"] changeCount: (lineItem) ->