cart now functional without bugs (at least the ones we know about)

fixed a small issue with ItemGroup REST call
This commit is contained in:
Edin Dazdarevic
2015-05-27 13:58:44 +02:00
parent 2ddfcf2141
commit b5fdc6d173
6 changed files with 72 additions and 25 deletions

View File

@@ -45,7 +45,7 @@ var loadCart = function() {
});
//_deliveryDestination.fetch({
//success: function() {
//success: function() {
//validateDeliveryDestinationForm();
//fetchPlace();
//CartActions.dataLoaded();
@@ -94,6 +94,30 @@ var takeItemOut = function(itemId) {
saveCartStateForItem(itemId);
};
var setItemCount = function(itemId, count) {
var state = states[itemId] || new ItemInCart({
item_id: itemId,
count: 0
});
if (count === "") {
state.set('count', "");
CartStore.emitChange();
return;
}
var cnt = parseInt(count);
if(isNaN(cnt) || cnt <= 0) {
cnt = 1;
}
state.set('count', cnt);
states[itemId] = state;
saveCartStateForItem(itemId);
// CartStore.emitChange();
};
var addNItems = function(item, count) {
@@ -283,6 +307,9 @@ AppDispatcher.register(function(payload) {
case CartConstants.ADD_N_ITEMS:
addNItems(action.item, action.count);
break;
case CartConstants.SET_ITEM_COUNT:
setItemCount(action.itemId, action.count);
break;
default:
return true;
}