diff --git a/app/assets/javascripts/darkswarm/filters/show_profiles.js.coffee b/app/assets/javascripts/darkswarm/filters/show_profiles.js.coffee index 32e4438e82..e3fce7d2f6 100644 --- a/app/assets/javascripts/darkswarm/filters/show_profiles.js.coffee +++ b/app/assets/javascripts/darkswarm/filters/show_profiles.js.coffee @@ -4,4 +4,4 @@ Darkswarm.filter 'showProfiles', ()-> show_profiles ?= true enterprises.filter (enterprise)=> - show_profiles or not enterprise.is_profile + show_profiles or enterprise.has_shopfront diff --git a/app/assets/javascripts/darkswarm/services/hubs.js.coffee b/app/assets/javascripts/darkswarm/services/hubs.js.coffee index ac7dc3a0eb..ba3d9f3c24 100644 --- a/app/assets/javascripts/darkswarm/services/hubs.js.coffee +++ b/app/assets/javascripts/darkswarm/services/hubs.js.coffee @@ -2,7 +2,7 @@ Darkswarm.factory 'Hubs', ($filter, Enterprises, visibleFilter) -> new class Hubs constructor: -> @hubs = @order Enterprises.enterprises.filter (hub)-> - hub.is_distributor + hub.has_hub_listing @visible = visibleFilter @hubs order: (hubs)-> diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 30a5939b08..ecd948aa7a 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -215,20 +215,15 @@ class Enterprise < ActiveRecord::Base # Type: full - single - profile becomes Sells: all - own - none # Remove this return later. return "none" if !is_distributor || type == "profile" - return "own" if is_distributor && (suppliers != [self] || type == "full") - "own" - end - - # New boolean field shows whether we can supply products into the system. - def supplies - is_primary_producer && type != "profile" #and has distributors? + return "own" if suppliers == [self] || type == "single" + "all" end # Simplify enterprise categories for frontend logic and icons, and maybe other things. def enterprise_category - # Make this crazy logic human readable so we can argue about it sanely. + # Make this crazy logic human readable so we can argue about it sanely. # This can be simplified later, it's like this for readablitlty during changes. - category = is_primary_producer ? "producer_" : "non_producer_" + category = is_primary_producer ? "producer_" : "non_producer_" category << "sell_" + sells # Map backend cases to front end cases. diff --git a/app/serializers/api/enterprise_serializer.rb b/app/serializers/api/enterprise_serializer.rb index d21cfecabb..6841337024 100644 --- a/app/serializers/api/enterprise_serializer.rb +++ b/app/serializers/api/enterprise_serializer.rb @@ -4,7 +4,7 @@ class Api::EnterpriseSerializer < ActiveModel::Serializer end private - + def cached_serializer_hash Api::CachedEnterpriseSerializer.new(object, @options).serializable_hash end @@ -18,7 +18,7 @@ class Api::UncachedEnterpriseSerializer < ActiveModel::Serializer attributes :orders_close_at, :active #TODO: Remove these later - attributes :icon, :icon_font, :producer_icon_font, :has_shopfront, :is_profile, :enterprise_category + attributes :icon, :icon_font, :producer_icon_font, :has_shopfront, :has_hub_listing, :enterprise_category def orders_close_at OrderCycle.first_closing_for(object).andand.orders_close_at @@ -36,13 +36,14 @@ class Api::UncachedEnterpriseSerializer < ActiveModel::Serializer object.is_distributor && object.type != 'profile' end - def is_profile - object.sells == "none" && !object.supplies + # Used to select enterprises for hub listing + def has_hub_listing + has_shopfront || object.enterprise_category == "hub_profile" end # Map svg icons. def icon - icons = { + icons = { "hub" => "/assets/map_005-hub.svg", "hub_profile" => "/assets/map_006-hub-profile.svg", "producer_hub" => "/assets/map_005-hub.svg", @@ -67,7 +68,7 @@ class Api::UncachedEnterpriseSerializer < ActiveModel::Serializer end # Choose producer page icon font - yes, sadly its got to be different. - # This duplicates some code but covers the producer page edge case where + # This duplicates some code but covers the producer page edge case where # producer-hub has a producer icon without needing to duplicate the category logic in angular. def producer_icon_font icon_fonts = { diff --git a/app/views/home/_skinny.html.haml b/app/views/home/_skinny.html.haml index 440f00c9b0..2010bffe1e 100644 --- a/app/views/home/_skinny.html.haml +++ b/app/views/home/_skinny.html.haml @@ -1,4 +1,4 @@ -.row.active_table_row{"ng-if" => "!hub.is_profile", "ng-click" => "toggle()", "ng-class" => "{'closed' : !open(), 'has_shopfront' : producer.has_shopfront}", bindonce: true} +.row.active_table_row{"ng-if" => "hub.has_shopfront", "ng-click" => "toggle()", "ng-class" => "{'closed' : !open(), 'has_shopfront' : producer.has_shopfront}", 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"} @@ -13,18 +13,18 @@ .columns.small-6.medium-3.large-4.text-right{"bo-if" => "hub.active"} %a.hub.open_closed{"bo-href" => "hub.path", "ng-class" => "{primary: hub.active, secondary: !hub.active}", "ofn-empties-cart" => "hub"} %i.ofn-i_033-open-sign - %span.margin-top{ bo: { if: "current()" } } + %span.margin-top{ bo: { if: "current()" } } %em Shopping here %span.margin-top{ bo: { if: "!current()" } } {{ hub.orders_close_at | sensible_timeframe }} .columns.small-6.medium-3.large-4.text-right{"bo-if" => "!hub.active"} %a.hub.open_closed{"bo-href" => "hub.path", "ng-class" => "{primary: hub.active, secondary: !hub.active}", "ofn-empties-cart" => "hub"} %i.ofn-i_032-closed-sign - %span.margin-top{ bo: { if: "current()" } } + %span.margin-top{ bo: { if: "current()" } } %em Shopping here %span.margin-top{ bo: { if: "!current()" } } Orders closed -.row.active_table_row{"ng-if" => "hub.is_profile", "ng-class" => "closed"} +.row.active_table_row{"ng-if" => "!hub.has_shopfront", "ng-class" => "closed"} .columns.small-12.medium-6.large-5.skinny-head %a.hub{"ng-click" => "openModal(hub)", "ng-class" => "{primary: hub.active, secondary: !hub.active}", "ofn-empties-cart" => "hub"} %i{ng: {class: "hub.icon_font"}}