address saving now works - masallah, la hawle we la kuwette ila billah :)
This commit is contained in:
@@ -55,7 +55,7 @@ update_delivery_destination = ->() {
|
||||
params = @json_params.reject { |key,_| !allowed_keys.include?(key) }
|
||||
cart.delivery_destination.update_attributes(params)
|
||||
cart.delivery_destination.save!
|
||||
cart.delivery_destination.to_json
|
||||
cart.delivery_destination.to_json(:except => [:created_at, :email_verification_code, :phone_verification_code])
|
||||
}
|
||||
put '/cart/delivery_destination', &update_delivery_destination
|
||||
post '/cart/delivery_destination', &update_delivery_destination
|
||||
@@ -40,7 +40,7 @@ var CartActions = {
|
||||
changeDeliveryDestinationProperty: function(property, value) {
|
||||
AppDispatcher.handleAction({
|
||||
actionType: CartConstants.CHANGE_DELIVERY_DESTINATION_PROPERTY,
|
||||
property: property,
|
||||
propertyName: property,
|
||||
value: value
|
||||
});
|
||||
},
|
||||
|
||||
@@ -30,15 +30,17 @@ var loadCart = function() {
|
||||
});
|
||||
|
||||
_itemsForDisplay.fetch({
|
||||
success: function() {
|
||||
CartActions.dataLoaded();
|
||||
}
|
||||
})
|
||||
_deliveryDestination.fetch({
|
||||
success: function() {
|
||||
success: function() {
|
||||
CartActions.dataLoaded();
|
||||
}
|
||||
})
|
||||
if (!_deliveryDestination.get('id')) {
|
||||
_deliveryDestination.fetch({
|
||||
success: function() {
|
||||
CartActions.dataLoaded();
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@@ -69,13 +71,13 @@ var takeItemOut = function(itemId) {
|
||||
var saveCartStateForItem = function(itemId) {
|
||||
var item = CartStore.getStateFor(itemId);
|
||||
item.save({
|
||||
success: function () {
|
||||
success: function() {
|
||||
CartActions.dataLoaded();
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var changeDeliveryDestinationProperty = function (property, value) {
|
||||
var changeDeliveryDestinationProperty = function(property, value) {
|
||||
_deliveryDestination.set(property, value);
|
||||
};
|
||||
|
||||
@@ -105,12 +107,12 @@ var CartStore = _.extend({}, EventEmitter.prototype, {
|
||||
var numberOfItems = 0;
|
||||
|
||||
for (key in states) {
|
||||
if(states.hasOwnProperty(key)){
|
||||
var value = states[key];
|
||||
if (value.get('count') > 0) {
|
||||
if (states.hasOwnProperty(key)) {
|
||||
var value = states[key];
|
||||
if (value.get('count') > 0) {
|
||||
numberOfItems += value.get('count');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
var state = {
|
||||
@@ -163,12 +165,14 @@ AppDispatcher.register(function(payload) {
|
||||
// do nothing - jsut emmit change
|
||||
break;
|
||||
case CartConstants.SAVE_CART_STATE_FOR_ITEM:
|
||||
// saveCartStateForItem(action.itemId);
|
||||
saveCartStateForItem(action.itemId);
|
||||
break;
|
||||
case CartConstants.CHANGE_DELIVERY_DESTINATION_PROPERTY:
|
||||
changeDeliveryDestinationProperty(action.propety, action.value)
|
||||
changeDeliveryDestinationProperty(action.propertyName, action.value)
|
||||
break;
|
||||
case CartConstants.CONFIRM_DELIVERY:
|
||||
saveDeliveryDestination();
|
||||
break;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user