cart icon is hidden when ordering (cart and delivery)

This commit is contained in:
Senad Uka
2015-06-14 04:30:21 +02:00
parent fb12ea613a
commit ee32d6f7c9
5 changed files with 60 additions and 36 deletions

View File

@@ -32,7 +32,7 @@ var CartIcon = React.createClass({
<li onClick={this._onClick} style={{borderTop: 'solid lightgray 1px', borderBottom: 'solid lightgray 1px', borderLeft: 'solid lightgray 1px', paddingBottom: 22}}><a ><div className="mycart"><span>{normalizeCount(this.state.count)}</span></div></a></li>
<li onClick={this._onClick} style={{borderTop: 'solid lightgray 1px', borderBottom: 'solid lightgray 1px', paddingBottom: 2}}><a href="#" style={{ paddingRight: '5px', backgroundColor: 'transparent' }}><CartTotal items={this.state.items} itemCounts={this.state.itemCounts} deliveryCosts={this.state.deliveryCosts} justMerchandise={true}/> </a></li>
<li onClick={this._onClick} style={{borderTop: 'solid lightgray 1px', borderBottom: 'solid lightgray 1px', borderRight: 'solid lightgray 1px'}}>
<a style={{marginBottom: 10, marginRight: 10}} className="mybutton" href="#">Nastavi narudžbu</a></li>
<a style={{marginBottom: 10, marginRight: 10}} className="mybutton" href="#">Završi narudžbu</a></li>
</ul>

View File

@@ -86,7 +86,7 @@ var CartPage = React.createClass({
</div>
<div className="row">
<div className="col-lg-12 pull-right">
<button className="btn btn-warning" onClick={this._onOrderClick}>Završi narudžbu</button>
<button className="mybutton" onClick={this._onOrderClick}>Završi narudžbu</button>
</div>
</div>

View File

@@ -61,6 +61,7 @@ var ItemList = React.createClass({
return (
<nav>
<ul className="pagination">
{pages}
</ul>

View File

@@ -7,6 +7,7 @@ var React = require('react'),
RouteHandler = Router.RouteHandler,
LoginStatus = require('./shared/loginStatus'),
InitializationStore = require('../stores/initializationStore'),
NavigationStore = require('../stores/navigationStore'),
InitializationActions = require('../actions/initializationActions');
var CartIcon = require('./cart/cartIcon');
@@ -36,12 +37,22 @@ var RootApp = React.createClass({
InitializationStore.removeChangeListener(this._onChange);
},
shouldShowCart: function () {
return !NavigationStore.hideCart();
},
render: function() {
if (!this.state.isEverythingReadyToStartTheShow) {
return (<div>loading...</div>);
}
var cart = "";
if(this.shouldShowCart()) {
cart = (<CartIcon />);
}
return (
<div className="container">
<div>
@@ -57,8 +68,8 @@ var RootApp = React.createClass({
<div style={{padding: '15px 15px'}} className="col-lg-4 col-md-4 hidden-sm hidden-xs">
<nav style={{background: 'none', border: 'none', marginBottom: '0px !important'}} className="navbar mytopnav">
<div className="container-fluid">
<CartIcon />
<div>
{cart}
</div>
</nav>
</div>

View File

@@ -15,33 +15,45 @@ var getGroupIdFromUrl = function() {
var url = document.URL;
var itemIdRegex = /grupa\/(\d+)\//g;
var match = itemIdRegex.exec(url);
var result = Globals.ItemGroupIdOfStartPage;
if(match) {
result = match[1]
if (match) {
result = match[1]
}
return result;
return result;
};
// Extend ItemStore with EventEmitter to add eventing capabilities
var NavigationStore = _.extend({}, EventEmitter.prototype, {
getGroupIdFromUrl: getGroupIdFromUrl,
getGroupIdFromUrl: getGroupIdFromUrl,
// Emit Change event
emitChange: function() {
this.emit('change');
},
// Emit Change event
emitChange: function() {
this.emit('change');
},
// Add change listener
addChangeListener: function(callback) {
this.on('change', callback);
},
// Add change listener
addChangeListener: function(callback) {
this.on('change', callback);
},
// Remove change listener
removeChangeListener: function(callback) {
this.removeListener('change', callback);
}
// Remove change listener
removeChangeListener: function(callback) {
this.removeListener('change', callback);
},
hideCart: function() {
// TODO: figure out how to find this out using Router
var url = document.URL;
var itemIdRegex = /\/(korpa|dostava)/g;
var match = itemIdRegex.exec(url);
if (match) {
return true;
} else {
return false;
}
}
});
@@ -50,25 +62,25 @@ var NavigationStore = _.extend({}, EventEmitter.prototype, {
// Register callback with AppDispatcher
NavigationStore.dispatchToken = AppDispatcher.register(function(payload) {
var action = payload.action;
var action = payload.action;
switch(action.actionType) {
switch (action.actionType) {
case NavigationConstants.CHANGE_URL:
var router = require('../router');
setTimeout(function(){
router.transitionTo(action.url);
}, 0);
break;
case NavigationConstants.CHANGE_URL:
var router = require('../router');
setTimeout(function() {
router.transitionTo(action.url);
}, 0);
break;
default:
return true;
}
default:
return true;
}
// If action was responded to, emit change event
NavigationStore.emitChange();
return true;
// If action was responded to, emit change event
NavigationStore.emitChange();
return true;
});
module.exports = NavigationStore;
module.exports = NavigationStore;