Commit 265d4a89 by Truong Ba Dieu

Add available for product

parent 63e2710e
...@@ -57,7 +57,7 @@ gem 'vacuum' ...@@ -57,7 +57,7 @@ gem 'vacuum'
gem "breadcrumbs_on_rails" gem "breadcrumbs_on_rails"
gem 'momentjs-rails', '>= 2.8.1' gem 'momentjs-rails', '>= 2.8.1'
gem 'bootstrap3-datetimepicker-rails', '~> 4.7.14' gem 'bootstrap3-datetimepicker-rails', '~> 4.7.14'
gem 'draper', '~> 1.3' gem 'draper', '~> 1.3' # decorator gem
gem 'rsolr' gem 'rsolr'
gem 'validates_timeliness', '~> 3.0' gem 'validates_timeliness', '~> 3.0'
gem "pundit" # verify role gem "pundit" # verify role
...@@ -90,6 +90,6 @@ group :development, :test do ...@@ -90,6 +90,6 @@ group :development, :test do
gem 'rspec-mocks' gem 'rspec-mocks'
gem 'rspec-rails', '~> 3.0.1' gem 'rspec-rails', '~> 3.0.1'
gem 'rspec-support' gem 'rspec-support'
gem "pry" gem "pry" # debug
gem "quiet_assets" gem "quiet_assets"
end end
\ No newline at end of file
...@@ -25,3 +25,12 @@ ...@@ -25,3 +25,12 @@
clear: both; clear: both;
} }
} }
.available, .out-stock{
clear: both;
display: block;
color: green;
}
.out-stock{
color: rgb(255, 60, 60);
}
\ No newline at end of file
...@@ -2,4 +2,9 @@ ...@@ -2,4 +2,9 @@
.xs-mar-top-10{ .xs-mar-top-10{
margin-top:10px!important; margin-top:10px!important;
} }
.products{
.price{
padding-left: 76px;
}
}
} }
\ No newline at end of file
class ProductDecorator < Draper::Decorator
include Draper::LazyHelpers
def available_stock
klass = object.stock > 0 ? 'available' : 'out-stock'
h.content_tag(:b, "(#{object.stock} available)", class: klass)
end
end
...@@ -2,6 +2,8 @@ ...@@ -2,6 +2,8 @@
.col-lg-9 .col-lg-9
.wrap-img.mar-r-10 .wrap-img.mar-r-10
= image_tag product.image.thumb('51x32#').url = image_tag product.image.thumb('51x32#').url
.title= link_to product.title, product_path(product) .title
.col-lg-3 = link_to product.title, product_path(product)
= product.decorate.available_stock
.col-lg-3.price
= "Price: #{currency_number(product.currency, product.price)}" = "Price: #{currency_number(product.currency, product.price)}"
.col-sm-4.text-center .col-sm-4.text-center
= link_to product.title, product_path(product) = link_to product.title, product_path(product)
= product.decorate.available_stock
br br
= image_tag product.image.thumb('71x38>').url = image_tag product.image.thumb('71x38>').url
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment