started with cart design

removing of items from cart now possible
This commit is contained in:
Edin Dazdarevic
2015-05-26 18:08:03 +02:00
parent 850e4a267c
commit 8bed4eb3f7
4 changed files with 108 additions and 53 deletions

View File

@@ -29,7 +29,7 @@ var _cartDataLoadCalled = false;
var loadCart = function() {
states = {};
states = {};
_itemsInCart.fetch({
success: function() {
states = {}
@@ -46,7 +46,7 @@ var loadCart = function() {
CartActions.dataLoaded();
}
});
_deliveryDestination.fetch({
success: function() {
validateDeliveryDestinationForm();
@@ -56,8 +56,8 @@ var loadCart = function() {
});
_cartDataLoadCalled = true;
};
};
var fetchPlace = function() {
@@ -82,8 +82,8 @@ var saveCartStateForItem = function(itemId) {
});
};
/* need it for delete - will delete it later
/* need it for delete - will delete it later
*/
var takeItemOut = function(itemId) {
var state = states[itemId] || new ItemInCart({
@@ -91,13 +91,14 @@ var takeItemOut = function(itemId) {
count: 0
})
if (state.get('count') > 0) {
state.set('count', state.get('count') - 1);
// state.set('count', state.get('count') - 1);
state.set('count', 0);
}
states[itemId] = state;
saveCartStateForItem(itemId);
};
*/
var addNItems = function(item, count) {
@@ -108,7 +109,7 @@ var addNItems = function(item, count) {
})
_itemsForDisplay.add(item);
state.set('count', state.get('count') + count);
states[itemId] = state;
@@ -268,11 +269,6 @@ AppDispatcher.register(function(payload) {
case CartConstants.LOAD_CART_CONTENTS:
loadCart();
break;
case CartConstants.ADD_ITEM:
addItem(action.itemId);
break;
case CartConstants.TAKE_ITEM_OUT:
takeItemOut(action.itemId);
break;
@@ -303,4 +299,4 @@ AppDispatcher.register(function(payload) {
});
module.exports = CartStore;
module.exports = CartStore;