address is now collapsable
This commit is contained in:
@@ -25,6 +25,8 @@ var _deliveryCosts = new Place({
|
||||
postalCode: _deliveryDestination.get('place')
|
||||
})
|
||||
|
||||
var _addressColapsed = false;
|
||||
|
||||
|
||||
var supportedPlaces = [
|
||||
{
|
||||
@@ -82,6 +84,16 @@ var supportedPlaces = [
|
||||
|
||||
var _cartDataLoadCalled = false;
|
||||
|
||||
var nameOfThePlace = function(code) {
|
||||
for(var i=0; i<supportedPlaces.length; i++ ) {
|
||||
var place = supportedPlaces[i];
|
||||
if (place.code === code) {
|
||||
return place.placeLabel;
|
||||
}
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
var loadCart = function() {
|
||||
|
||||
_itemsInCart.fetch({
|
||||
@@ -98,6 +110,7 @@ var loadCart = function() {
|
||||
_deliveryDestination.fetch({
|
||||
success: function() {
|
||||
validateDeliveryDestinationForm();
|
||||
collapseAddressIfNeeded();
|
||||
fetchPlace();
|
||||
CartActions.dataLoaded();
|
||||
}
|
||||
@@ -110,6 +123,13 @@ var loadCart = function() {
|
||||
_cartDataLoadCalled = true;
|
||||
};
|
||||
|
||||
var collapseAddressIfNeeded = function () {
|
||||
if(isDeliveryDestinationValid()) {
|
||||
_addressColapsed = true;
|
||||
} else {
|
||||
_addressColapsed = false;
|
||||
}
|
||||
}
|
||||
|
||||
var fetchPlace = function() {
|
||||
_deliveryCosts = new Place({
|
||||
@@ -339,9 +359,24 @@ var CartStore = _.extend({}, EventEmitter.prototype, {
|
||||
this.removeListener('change', callback);
|
||||
},
|
||||
|
||||
isDeliveryDestinationValid: isDeliveryDestinationValid
|
||||
isDeliveryDestinationValid: isDeliveryDestinationValid,
|
||||
|
||||
isAddressColapsed: function() {
|
||||
return _addressColapsed;
|
||||
|
||||
},
|
||||
|
||||
getHumanReadableAddress: function() {
|
||||
var address = [];
|
||||
address.push(_deliveryDestination.get('name'));
|
||||
address.push(_deliveryDestination.get('address'));
|
||||
address.push(_deliveryDestination.get('place') + " " + nameOfThePlace(_deliveryDestination.get('place')));
|
||||
address.push("Bosna i Hercegovina");
|
||||
address.push("+387" + _deliveryDestination.get('phone'))
|
||||
address.push(_deliveryDestination.get('email'))
|
||||
|
||||
return address;
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
@@ -378,6 +413,9 @@ AppDispatcher.register(function(payload) {
|
||||
case CartConstants.SET_ITEM_COUNT:
|
||||
setItemCount(action.itemId, action.count);
|
||||
break;
|
||||
case CartConstants.SET_ADDRESS_COLAPSED:
|
||||
_addressColapsed = action.isColapsed
|
||||
break;
|
||||
default:
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user