cart icon is hidden when ordering (cart and delivery)
This commit is contained in:
@@ -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', 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', 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'}}>
|
<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>
|
</ul>
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ var CartPage = React.createClass({
|
|||||||
</div>
|
</div>
|
||||||
<div className="row">
|
<div className="row">
|
||||||
<div className="col-lg-12 pull-right">
|
<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>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ var ItemList = React.createClass({
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<nav>
|
<nav>
|
||||||
|
|
||||||
<ul className="pagination">
|
<ul className="pagination">
|
||||||
{pages}
|
{pages}
|
||||||
</ul>
|
</ul>
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ var React = require('react'),
|
|||||||
RouteHandler = Router.RouteHandler,
|
RouteHandler = Router.RouteHandler,
|
||||||
LoginStatus = require('./shared/loginStatus'),
|
LoginStatus = require('./shared/loginStatus'),
|
||||||
InitializationStore = require('../stores/initializationStore'),
|
InitializationStore = require('../stores/initializationStore'),
|
||||||
|
NavigationStore = require('../stores/navigationStore'),
|
||||||
InitializationActions = require('../actions/initializationActions');
|
InitializationActions = require('../actions/initializationActions');
|
||||||
|
|
||||||
var CartIcon = require('./cart/cartIcon');
|
var CartIcon = require('./cart/cartIcon');
|
||||||
@@ -36,12 +37,22 @@ var RootApp = React.createClass({
|
|||||||
InitializationStore.removeChangeListener(this._onChange);
|
InitializationStore.removeChangeListener(this._onChange);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
shouldShowCart: function () {
|
||||||
|
return !NavigationStore.hideCart();
|
||||||
|
},
|
||||||
|
|
||||||
render: function() {
|
render: function() {
|
||||||
|
|
||||||
if (!this.state.isEverythingReadyToStartTheShow) {
|
if (!this.state.isEverythingReadyToStartTheShow) {
|
||||||
return (<div>loading...</div>);
|
return (<div>loading...</div>);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var cart = "";
|
||||||
|
|
||||||
|
if(this.shouldShowCart()) {
|
||||||
|
cart = (<CartIcon />);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="container">
|
<div className="container">
|
||||||
<div>
|
<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">
|
<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">
|
<nav style={{background: 'none', border: 'none', marginBottom: '0px !important'}} className="navbar mytopnav">
|
||||||
<div className="container-fluid">
|
<div>
|
||||||
<CartIcon />
|
{cart}
|
||||||
</div>
|
</div>
|
||||||
</nav>
|
</nav>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -17,31 +17,43 @@ var getGroupIdFromUrl = function() {
|
|||||||
var match = itemIdRegex.exec(url);
|
var match = itemIdRegex.exec(url);
|
||||||
|
|
||||||
var result = Globals.ItemGroupIdOfStartPage;
|
var result = Globals.ItemGroupIdOfStartPage;
|
||||||
if(match) {
|
if (match) {
|
||||||
result = match[1]
|
result = match[1]
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Extend ItemStore with EventEmitter to add eventing capabilities
|
// Extend ItemStore with EventEmitter to add eventing capabilities
|
||||||
var NavigationStore = _.extend({}, EventEmitter.prototype, {
|
var NavigationStore = _.extend({}, EventEmitter.prototype, {
|
||||||
|
|
||||||
getGroupIdFromUrl: getGroupIdFromUrl,
|
getGroupIdFromUrl: getGroupIdFromUrl,
|
||||||
|
|
||||||
// Emit Change event
|
// Emit Change event
|
||||||
emitChange: function() {
|
emitChange: function() {
|
||||||
this.emit('change');
|
this.emit('change');
|
||||||
},
|
},
|
||||||
|
|
||||||
// Add change listener
|
// Add change listener
|
||||||
addChangeListener: function(callback) {
|
addChangeListener: function(callback) {
|
||||||
this.on('change', callback);
|
this.on('change', callback);
|
||||||
},
|
},
|
||||||
|
|
||||||
// Remove change listener
|
// Remove change listener
|
||||||
removeChangeListener: function(callback) {
|
removeChangeListener: function(callback) {
|
||||||
this.removeListener('change', 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,24 +62,24 @@ var NavigationStore = _.extend({}, EventEmitter.prototype, {
|
|||||||
|
|
||||||
// Register callback with AppDispatcher
|
// Register callback with AppDispatcher
|
||||||
NavigationStore.dispatchToken = AppDispatcher.register(function(payload) {
|
NavigationStore.dispatchToken = AppDispatcher.register(function(payload) {
|
||||||
var action = payload.action;
|
var action = payload.action;
|
||||||
|
|
||||||
switch(action.actionType) {
|
switch (action.actionType) {
|
||||||
|
|
||||||
case NavigationConstants.CHANGE_URL:
|
case NavigationConstants.CHANGE_URL:
|
||||||
var router = require('../router');
|
var router = require('../router');
|
||||||
setTimeout(function(){
|
setTimeout(function() {
|
||||||
router.transitionTo(action.url);
|
router.transitionTo(action.url);
|
||||||
}, 0);
|
}, 0);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// If action was responded to, emit change event
|
// If action was responded to, emit change event
|
||||||
NavigationStore.emitChange();
|
NavigationStore.emitChange();
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user