From 8f6d04a12934a6d45b52b06608b0e50fb77f1d96 Mon Sep 17 00:00:00 2001 From: Rob H Date: Fri, 5 Sep 2014 12:30:52 +1000 Subject: [PATCH] Adding properties to enterprise serialiser to allow differentiation between profile, shopfront and aggregators --- app/serializers/api/enterprise_serializer.rb | 15 +++++++++++++-- app/views/home/_skinny.html.haml | 1 + 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/app/serializers/api/enterprise_serializer.rb b/app/serializers/api/enterprise_serializer.rb index 6fa7264630..ff6ffce12f 100644 --- a/app/serializers/api/enterprise_serializer.rb +++ b/app/serializers/api/enterprise_serializer.rb @@ -30,11 +30,12 @@ class Api::CachedEnterpriseSerializer < ActiveModel::Serializer cached delegate :cache_key, to: :object - attributes :name, :id, :description, :latitude, :longitude, - :long_description, :website, :instagram, :linkedin, :twitter, + attributes :name, :id, :description, :latitude, :longitude, + :long_description, :website, :instagram, :linkedin, :twitter, :facebook, :is_primary_producer, :is_distributor, :phone, :visible, :email, :hash, :logo, :promo_image, :icon, :path, :pickup, :delivery + attributes :has_shopfront, :can_aggregate has_many :distributed_taxons, key: :taxons, serializer: Api::IdSerializer has_many :supplied_taxons, serializer: Api::IdSerializer @@ -77,6 +78,16 @@ class Api::CachedEnterpriseSerializer < ActiveModel::Serializer end end + # TODO: Remove this when flags on enterprises are switched over + def has_shopfront + object.type != 'profile' + end + + # TODO: Remove this when flags on enterprises are switched over + def can_aggregate + object.is_distributor && !object.is_primary_producer + end + # TODO when ActiveSerializers supports URL helpers # Then refactor. See readme https://github.com/rails-api/active_model_serializers def path diff --git a/app/views/home/_skinny.html.haml b/app/views/home/_skinny.html.haml index 2b59132999..828031abb7 100644 --- a/app/views/home/_skinny.html.haml +++ b/app/views/home/_skinny.html.haml @@ -1,6 +1,7 @@ .row.active_table_row{"ng-click" => "toggle()", "ng-class" => "{'closed' : !open()}", bindonce: true} .columns.small-12.medium-6.large-5.skinny-head %a.hub{"bo-href" => "hub.path", "ng-class" => "{primary: hub.active, secondary: !hub.active}", "ofn-empties-cart" => "hub"} + /%i{ ng: { class: "{'ofn-i_063-hub': hub.can_aggregate, 'ofn-i_059-producer': !hub.can_aggregate}" } } %i.ofn-i_040-hub %span %strong {{ hub.name | truncate:40}}