From ea2837bd0012caa247041228c7f6099aa52f607e Mon Sep 17 00:00:00 2001 From: Senad Uka Date: Sun, 12 Apr 2015 11:11:26 +0200 Subject: [PATCH] items are now done and pictures resize on serverside automagically --- front-api/models/multi_media_description.rb | 9 ++++++ front-ui/app/components/items/itemList.js | 4 +-- front-ui/app/components/items/singleItem.js | 36 ++++++++++++++------- front-ui/app/css/main.css | 3 +- front-ui/app/stores/itemDetailsStore.js | 2 +- 5 files changed, 39 insertions(+), 15 deletions(-) diff --git a/front-api/models/multi_media_description.rb b/front-api/models/multi_media_description.rb index 57f7a26..c4bc45d 100644 --- a/front-api/models/multi_media_description.rb +++ b/front-api/models/multi_media_description.rb @@ -2,4 +2,13 @@ class MultiMediaDescription < ActiveRecord::Base belongs_to :item belongs_to :media_type + + def attributes + super.merge('resized_url' => self.resized_url) + end + + def resized_url + url.gsub('/upload/v','/upload/c_lpad,h_170,w_226/v') + end + end diff --git a/front-ui/app/components/items/itemList.js b/front-ui/app/components/items/itemList.js index 1bcb65f..a59a4d8 100644 --- a/front-ui/app/components/items/itemList.js +++ b/front-ui/app/components/items/itemList.js @@ -20,9 +20,9 @@ var ItemList = React.createClass({ return (
-
    +
    {items} -
+
{this.getPages()}
diff --git a/front-ui/app/components/items/singleItem.js b/front-ui/app/components/items/singleItem.js index 0aeb1bb..d7b3811 100644 --- a/front-ui/app/components/items/singleItem.js +++ b/front-ui/app/components/items/singleItem.js @@ -11,22 +11,36 @@ var SingleItem = React.createClass({ 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" } ; + firstImage = firstImage || { resized_url: "https://res.cloudinary.com/lfvt7ps2n/image/upload/c_fit,h_172,w_226/v1421732950/http_www.asms.ru_bitrix_templates_main_images_nophoto_irnofq.png" } ; if (hidePrice) { return ( -
- -

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

-
+
+
+ product image +
+ +

{ this.props.item.get('brand') ? this.props.item.get('brand').name : '' }{ this.props.item.get('name') }

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

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

-
{ this.props.item.get('brand')? this.props.item.get('brand').name : '' }
-
{ this.props.item.get('list_price') } KM
+ return ( + +
+
+ product image +
+
+ +

{ this.props.item.get('brand') ? this.props.item.get('brand').name : '' }{ this.props.item.get('name') }

+

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

+ +
+
+
); } diff --git a/front-ui/app/css/main.css b/front-ui/app/css/main.css index c5f8453..0778003 100644 --- a/front-ui/app/css/main.css +++ b/front-ui/app/css/main.css @@ -105,6 +105,7 @@ background: none; } .productbox{ +cursor: pointer; -moz-box-shadow: 1px 4px 25px #000000; -webkit-box-shadow: 1px 4px 25px #000000; box-shadow: 1px 4px 25px #000000; @@ -138,7 +139,7 @@ text-decoration: underline; } .productbox div span{ -color:#06c3c3; +color: black; margin-left: 8px; diff --git a/front-ui/app/stores/itemDetailsStore.js b/front-ui/app/stores/itemDetailsStore.js index 029bd59..753e238 100644 --- a/front-ui/app/stores/itemDetailsStore.js +++ b/front-ui/app/stores/itemDetailsStore.js @@ -33,7 +33,7 @@ var fetchItemWithDetails = function() { item.fetch({ success: function() { _images = (_itemWithDetails.get("multi_media_descriptions") || []).map(function(mmd) { - return mmd.url; + return mmd.resized_url; }); _count = _images.length; _currentImage = 0;