app/assets/javascripts/rightnow_oms/app/models/cart.js.coffee in rightnow_oms-0.1.1 vs app/assets/javascripts/rightnow_oms/app/models/cart.js.coffee in rightnow_oms-0.1.2
- old
+ new
@@ -27,10 +27,24 @@
else
cartItem = RightnowOms.store.createRecord(RightnowOms.CartItem, item)
cartItem
+ updateCartItem: (id, properties) ->
+ cartItem = RightnowOms.CartItem.findById(id)
+ cartItem.setProperties(properties) if cartItem?
+
+ cleanUp: ->
+ cartItemIds = @get('cartItems').map (item) ->
+ return item.get('id')
+
+ cartItemIds.forEach (id) ->
+ item = RightnowOms.CartItem.findById(id)
+
+ # INFO Children will be deleted when the parent is deleted
+ item.deleteRecord() if item && !item.get('hasParent')
+
removeCartItem: (id) ->
cartItem = RightnowOms.CartItem.findById(id)
cartItem.deleteRecord() if cartItem?
@@ -45,8 +59,12 @@
decreaseCartItem: (id) ->
cartItem = RightnowOms.CartItem.findById(id)
cartItem.decrease()
cartItem
+
+ findCartItemsByGroup: (group) ->
+ @get('cartItems').filter (item) ->
+ return true if item.get('group') == group
RightnowOms.Cart.reopenClass
isSingleton: true