diff --git a/app/assets/javascripts/templates/partials/enterprise_header.html.haml b/app/assets/javascripts/templates/partials/enterprise_header.html.haml index 96a4fb207e..871cf9c0b3 100644 --- a/app/assets/javascripts/templates/partials/enterprise_header.html.haml +++ b/app/assets/javascripts/templates/partials/enterprise_header.html.haml @@ -1,12 +1,9 @@ -.highlight +.highlight{ng: {class: "enterprise.has_shopfront"}} .highlight-top %p.right {{ [enterprise.address.city, enterprise.address.state_name] | printArray}} - %h3{"ng-if" => "enterprise.is_distributor"} + %h3 %a{"bo-href" => "enterprise.path", "ofn-empties-cart" => "enterprise", bindonce: true} - %i.ofn-i_040-hub + %i{ng: {class: "enterprise.icon_font"}} %span {{ enterprise.name }} - %h3{"ng-if" => "!enterprise.is_distributor"} - %i.ofn-i_036-producers - %span {{ enterprise.name }} %img.hero-img{"ng-src" => "{{enterprise.promo_image}}"} diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 6ad91ba140..b2a41d9a72 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -210,6 +210,18 @@ class Enterprise < ActiveRecord::Base Spree::Variant.joins(:product => :product_distributions).where('product_distributions.distributor_id=?', self.id) end + # Make this a real database attridbute later. + def sells + case type + when "full" + "all" + when "single" + "own" + when "profile" + "none" + end + end + def enterprise_category # Explanation: I added and extra flag then pared it back to a combo, before realising we allready had one. # Short version: meets front end and back end needs, without changing much at all. @@ -221,15 +233,8 @@ class Enterprise < ActiveRecord::Base # Make this crazy logic human readable so we can argue about it sanely. # This can be simplified later, like this for readablitlty during changes. category = is_primary_producer ? "producer_" : "non_producer_" - case type - when "full" - category << "sell_all_" - when "single" - category << "sell_own_" - when "profile" - category << "cant_sell_" - end - category << (can_supply ? "can_supply" : "cant_supply") + category << "sell_" + sells + category << (supplies ? "can_supply" : "cant_supply") # Map backend cases to front end cases. case category @@ -261,12 +266,11 @@ class Enterprise < ActiveRecord::Base end end - # TODO: Remove this when flags on enterprises are switched over - # Obviously this duplicates is_producer currently - def can_supply + def supplies is_primary_producer && type != "profile" #and has distributors? end + # Return all taxons for all distributed products def distributed_taxons Spree::Taxon. diff --git a/app/serializers/api/enterprise_serializer.rb b/app/serializers/api/enterprise_serializer.rb index 4b818f6d17..e2c0bc0a14 100644 --- a/app/serializers/api/enterprise_serializer.rb +++ b/app/serializers/api/enterprise_serializer.rb @@ -32,18 +32,21 @@ class Api::UncachedEnterpriseSerializer < ActiveModel::Serializer object.enterprise_category end - # TODO: Remove this when flags on enterprises are switched over def has_shopfront object.is_distributor && object.type != 'profile' end + def profile_only + object.type = 'profile' + end + # Map svg icons. def icon icons = { "hub" => "/assets/map_005-hub.svg", "hub_profile" => "/assets/map_006-hub-profile.svg", "producer_hub" => "/assets/map_005-hub.svg", - "prodshop_shop" => "/assets/map_003-producer-shop.svg", + "producer_shop" => "/assets/map_003-producer-shop.svg", "producer" => "map_001-producer-only.svg", "producer_profile" => "/assets/map_002-producer-only-profile.svg", } diff --git a/app/views/producers/_skinny.html.haml b/app/views/producers/_skinny.html.haml index 2f3326f7a0..b87bb4cf96 100644 --- a/app/views/producers/_skinny.html.haml +++ b/app/views/producers/_skinny.html.haml @@ -1,4 +1,4 @@ -.row.active_table_row{"ng-click" => "toggle()", "ng-class" => "{'closed' : !open(), 'has_shopfront' : producer.has_shopfront}"} +.row.active_table_row{"ng-click" => "toggle()", "ng-class" => "{'closed' : !open(), 'has_shopfront' : producer.}"} .columns.small-12.medium-4.large-4.skinny-head / This needs logic to show profile only icon when available %i.ofn-i_060-producer-reversed %i{ng: {class: "producer.producer_icon_font"}}