added some models, started creating delivery destination state

This commit is contained in:
Senad Uka
2015-02-22 07:19:13 +01:00
parent 9c152e8adb
commit 2b6d93a437
8 changed files with 52 additions and 11 deletions

View File

@@ -15,7 +15,7 @@ var RootApp = React.createClass({
<div className="container">
<div className='page-header'>
<h1 className="main-heading"><a href="#" style={{color: "#cd3071"}}>ribica.ba</a></h1> <CartIcon />
<h1 className="main-heading"><a href="/" style={{color: "#cd3071"}}>ribica.ba</a></h1> <CartIcon />
<div style={{float:'right'}}>
<LoginStatus />
</div>

View File

@@ -8,5 +8,6 @@ module.exports = keyMirror({
// and not just decrease count by 1
TAKE_ITEM_OUT: null ,
CART_DATA_LOADED: null,
SAVE_CART_STATE_FOR_ITEM: null
SAVE_CART_STATE_FOR_ITEM: null,
CHANGE_DELIVERY_DESTINATION_PROPERTY: null
});

View File

@@ -0,0 +1,22 @@
var Backbone = require('backbone');
var Globals = require('../globals');
var DeliveryDestination = Backbone.Model.extend({
initialize: function() {
$.ajaxPrefilter(
function(options, originalOptions, jqXHR) {
options.xhrFields = {
withCredentials: true
}
}
);
},
url: Globals.ApiUrl + '/cart/delivery_destination',
defaults: {
count: 0
}
});
module.exports = DeliveryDestination;

View File

@@ -5,6 +5,7 @@ var CartActions = require('../actions/cartActions');
var ItemInCart = require('../models/itemInCart');
var ItemInCartCollection = require('../models/itemInCartCollection');
var ItemCollection = require('../models/itemCollection');
var DeliveryDestination = require('../models/deliveryDestination');
var _ = require('underscore');
@@ -13,6 +14,7 @@ var states = {}
var _itemsInCart = new ItemInCartCollection();
var _itemsForDisplay = new ItemCollection();
_itemsForDisplay.setFromCart(true);
var _deliveryDestination = new DeliveryDestination();
var loadCart = function() {
@@ -103,7 +105,8 @@ var CartStore = _.extend({}, EventEmitter.prototype, {
var state = {
count: numberOfItems,
items: _itemsForDisplay,
itemCounts: states
itemCounts: states,
deliveryDestination: _deliveryDestination
};
return state;
},