diff --git a/front-api/db/schema.rb b/front-api/db/schema.rb index ee35fb4..c09d243 100644 --- a/front-api/db/schema.rb +++ b/front-api/db/schema.rb @@ -34,7 +34,7 @@ ActiveRecord::Schema.define(version: 20150207120207) do t.string "title" t.string "field_name" t.integer "type" - t.integer "owner_type" + t.string "owner_type" t.integer "owner_id" end @@ -86,8 +86,10 @@ ActiveRecord::Schema.define(version: 20150207120207) do end create_table "sub_categories", force: :cascade do |t| - t.string "name" - t.integer "category_id" + t.string "name" + t.integer "category_id" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false end create_table "units", force: :cascade do |t| diff --git a/front-ui/app/components/cart/addToCart.js b/front-ui/app/components/cart/addToCart.js index ad4b84b..2b1a229 100644 --- a/front-ui/app/components/cart/addToCart.js +++ b/front-ui/app/components/cart/addToCart.js @@ -4,8 +4,8 @@ var CartActions = require('../../actions/cartActions.js'); -var countStyle = { - width: '100%' +var buttonHolderStyle = { + display: 'inline-block' }; var AddToCart = React.createClass({ @@ -14,12 +14,14 @@ var AddToCart = React.createClass({ return (
-
-
-
+
+
+
+
+
); - }, + }, // Add change listeners to stores componentDidMount: function() { diff --git a/front-ui/app/components/cart/cartPage.js b/front-ui/app/components/cart/cartPage.js index a144bd8..307cc44 100644 --- a/front-ui/app/components/cart/cartPage.js +++ b/front-ui/app/components/cart/cartPage.js @@ -3,20 +3,31 @@ var React = require('react'), AddToCart = require('../cart/addToCart'), CartActions = require('../../actions/cartActions'), SingleItem = require('../items/singleItem'), - AddToCart = require('../cart/addToCart'); + AddToCart = require('../cart/addToCart'), + Globals = require('../../globals'); + ; var Router = require('react-router'); -var ItemWithDetailsPage = React.createClass({ +var CartPage = React.createClass({ render: function() { + var counts = this.state.itemCounts; + var displayedItems = this.state.items.map(function (i) { + + var count = counts[i.get('id')].get('count'); + var price = i.get('list_price'); return ( -
-
-
+
+
+
{ Globals.FormatCurrency(price) }
+
X
+
+
=
+
{ Globals.FormatCurrency(count * price) }
) }); @@ -54,4 +65,4 @@ var ItemWithDetailsPage = React.createClass({ }); -module.exports = ItemWithDetailsPage; +module.exports = CartPage; diff --git a/front-ui/app/components/items/singleItem.js b/front-ui/app/components/items/singleItem.js index 96e5471..7be62c0 100644 --- a/front-ui/app/components/items/singleItem.js +++ b/front-ui/app/components/items/singleItem.js @@ -7,17 +7,28 @@ var Router = require('react-router'); var SingleItem = React.createClass({ render: function() { + var hidePrice = this.props.hidePrice || false; var self = this; var itemClick = this.itemClick; var firstImage = this.props.item.get('multi_media_descriptions')[0]; firstImage = firstImage || { url: "https://res.cloudinary.com/lfvt7ps2n/image/upload/c_crop,g_center,w_300/v1421732950/http_www.asms.ru_bitrix_templates_main_images_nophoto_irnofq.png" } ; - return ( + if (hidePrice) { + return (
- -

{ this.props.item.get('name') }

-
{ this.props.item.get('list_price') } KM
+ +

{ this.props.item.get('name') }

+
+ ); + } + else { + return ( +
+ +

{ this.props.item.get('name') }

+
{ this.props.item.get('list_price') } KM
); + } }, itemClick: function(e) { diff --git a/front-ui/app/css/cart.css b/front-ui/app/css/cart.css index 6a054cf..d5bb65b 100644 --- a/front-ui/app/css/cart.css +++ b/front-ui/app/css/cart.css @@ -18,4 +18,14 @@ top: 0px; right: -10px; padding: 5px; +} + +.add-to-cart button { + font-size: 20px; + margin: 5px; +} + +.cart-items { + vertical-align:middle; + font-size: 17px; } \ No newline at end of file diff --git a/front-ui/app/globals.js b/front-ui/app/globals.js index 4f46fce..0f18552 100644 --- a/front-ui/app/globals.js +++ b/front-ui/app/globals.js @@ -1,3 +1,7 @@ module.exports = { - ApiUrl: 'http://localhost:4567' + ApiUrl: 'http://localhost:4567', + FormatCurrency: function(amount_s) { + var amount = parseFloat(amount_s); + return ( amount.toFixed(2) + " KM" ) + } }; diff --git a/front-ui/app/stores/cartStore.js b/front-ui/app/stores/cartStore.js index 880621f..af2ca2f 100644 --- a/front-ui/app/stores/cartStore.js +++ b/front-ui/app/stores/cartStore.js @@ -102,7 +102,8 @@ var CartStore = _.extend({}, EventEmitter.prototype, { var state = { count: numberOfItems, - items: _itemsForDisplay + items: _itemsForDisplay, + itemCounts: states }; return state; },