Show product properties on producers page

This commit is contained in:
Rohan Mitchell
2016-06-16 11:00:20 +10:00
parent 4338f632f6
commit aae1689a27
6 changed files with 31 additions and 16 deletions

View File

@@ -5,7 +5,7 @@
.active_table .active_table_node
// Header row
@media all and (max-width: 640px)
@media all and (max-width: 640px)
.skinny-head
background-color: $clr-turquoise-light
@include border-radius-mixed(0.5em, 0.5em, 0, 0)
@@ -16,7 +16,7 @@
.follow-icons
&, & *
font-size: 1.5rem
// Producer icons
i.ofn-i_059-producer, i.ofn-i_060-producer-reversed
@@ -41,11 +41,11 @@
&:hover, &:focus, &:active
&.secondary
color: #666
.hub-name, .button-address
.hub-name, .button-address
border-bottom: 1px solid #999
&.primary
color: $clr-brick-bright
.hub-name, .button-address
.hub-name, .button-address
border-bottom: 1px solid $clr-brick-bright
p.word-wrap
@@ -53,7 +53,7 @@
&:last-child
margin-bottom: 1rem
.fat-taxons
.fat-taxons, .fat-properties
background-color: $clr-turquoise-light
.producer-name
@@ -72,7 +72,7 @@
max-height: 160px
width: auto
&.left
padding: 0.25rem 1rem 0.25rem 0
padding: 0.25rem 1rem 0.25rem 0
&.right
padding: 0.25rem 0.5rem 0.25rem 2rem
@@ -87,10 +87,7 @@
&.closed
.active_table_row.closed
border: 1px solid transparent
@media all and (max-width: 640px)
@media all and (max-width: 640px)
border-color: $clr-turquoise-light
&:hover, &:active, &:focus
border-color: $clr-turquoise

View File

@@ -1,7 +1,7 @@
@import branding
@import mixins
.fat-taxons
.fat-taxons, .fat-properties
display: inline-block
line-height: 1
margin-right: 0.5rem
@@ -29,7 +29,7 @@
svg
path
fill: $disabled-dark
.product-header
render-svg
svg

View File

@@ -47,7 +47,7 @@ class Api::CachedEnterpriseSerializer < ActiveModel::Serializer
attributes :taxons, :supplied_taxons
has_one :address, serializer: Api::AddressSerializer
has_many :properties, serializer: Api::PropertySerializer
def taxons
ids_to_objs options[:data].distributed_taxons[object.id]
@@ -57,6 +57,11 @@ class Api::CachedEnterpriseSerializer < ActiveModel::Serializer
ids_to_objs options[:data].supplied_taxons[object.id]
end
def properties
# This results in 2 queries per enterprise
Spree::Property.applied_by(object)
end
def pickup
services = options[:data].shipping_method_services[object.id]
services ? services[:pickup] : false

View File

@@ -1,3 +1,3 @@
class Api::PropertySerializer < ActiveModel::Serializer
attributes :id, :name, :presentation
end

View File

@@ -20,6 +20,12 @@
%render-svg{path: "{{taxon.icon}}"}
%span{"ng-bind" => "::taxon.name"}
%div
%label Product properties
%p.trans-sentence
%span.fat-properties{"ng-repeat" => "property in producer.properties"}
%span{"ng-bind" => "property.presentation"}
%div.show-for-medium-up{"ng-if" => "producer.supplied_taxons.length==0"}
&nbsp;

View File

@@ -21,7 +21,13 @@ feature %q{
let(:shop) { create(:distributor_enterprise) }
let!(:er) { create(:enterprise_relationship, parent: shop, child: producer1) }
before { visit producers_path }
before do
product1.set_property 'Organic', 'NASAA 12345'
product2.set_property 'Biodynamic', 'ABC123'
visit producers_path
end
it "filters by taxon" do
toggle_filters
@@ -41,7 +47,8 @@ feature %q{
it "shows all producers with expandable details" do
page.should have_content producer1.name
expand_active_table_node producer1.name
page.should have_content producer1.supplied_taxons.first.name.split.map(&:capitalize).join(' ')
page.should have_content 'Fruit'
page.should have_content 'Organic'
end
it "doesn't show invisible producers" do