From f33a9e1a5844ef614a8a6accd695f87c3ba347cf Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Fri, 12 Sep 2014 01:45:51 +1000 Subject: [PATCH 01/55] 16 enterprise categories from four checks. --- app/models/enterprise.rb | 91 ++++++++++++++ app/serializers/api/enterprise_serializer.rb | 118 +++++++++++++++---- 2 files changed, 184 insertions(+), 25 deletions(-) diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 004923097e..23cec57c40 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -204,6 +204,97 @@ class Enterprise < ActiveRecord::Base Spree::Variant.joins(:product => :product_distributions).where('product_distributions.distributor_id=?', self.id) end + def enterprise_category + + # Explanation: We needed to add the can_supply flag because this case (the most common for producers) was not covered: + # Short version: meets front end and back end needs. + # + # when "producer_without_shopfront_cant_aggregate_can_supply" + # "producer" # Producer selling only through others. + # + # And needs to be separate from this case: + # + # when "producer_with_shopfront_cant_aggregate_can_supply" + # "producer_shop" # Producer with shopfront for own products. + # + # And from this case + # + # when "producer_without_shopfront_cant_aggregate_cant_supply" + # "producer_profile" # Producer profile. + # + # And the front end very clearly distinguishes between producers with a shop and without, + # so the combined case was not enough, and it was going to be a bit weird anyway. + # As a side benefit, this also allows non producer suppliers. Yay. + # + # can_aggregate could depend on with_shopfront, as the combination always shouldn't exist. + # + # So it could be a combo box: + # Sell V + # none + # own + # any + # + # So 12 is possible anyway and seems to cover usefull cases. But the variables could be different. + + # Make this crazy logic human readable so we can argue about it sanely. + category = is_primary_producer ? "producer_" : "non_producer_" + category << (has_shopfront ? "with_shopfront_" : "without_shopfront_") + category << (can_aggregate ? "can_aggregate_" : "cant_aggregate_") + category << (can_supply ? "can_supply" : "cant_supply") + + # Map backend cases to front end cases. + case category + when "producer_with_shopfront_can_aggregate_can_supply" + "producer_hub" # Producer hub who sells own and others produce and supplies other hubs. + when "producer_with_shopfront_can_aggregate_cant_supply" + "producer_hub" # Producer hub who sells own and others products but does not supply other hubs. + when "producer_with_shopfront_cant_aggregate_can_supply" + "producer_shop" # Producer with shopfront and supplies other hubs. + when "producer_with_shopfront_cant_aggregate_cant_supply" + "producer_shop" # Producer with shopfront. + when "producer_without_shopfront_can_aggregate_can_supply" + "empty" # Shouldn't exist. + when "producer_without_shopfront_can_aggregate_cant_supply" + "empty" # Shouldn't exist. + when "producer_without_shopfront_cant_aggregate_can_supply" + "producer" # Producer selling only through others. + when "producer_without_shopfront_cant_aggregate_cant_supply" + "producer_profile" # Producer profile. + + when "non_producer_with_shopfront_can_aggregate_can_supply" + "hub" # Hub selling in products without origin. + when "non_producer_with_shopfront_can_aggregate_cant_supply" + "hub" # Regular hub. + when "non_producer_with_shopfront_cant_aggregate_can_supply" + "hub" # Wholesaler selling through own shopfront and others? + when "non_producer_with_shopfront_cant_aggregate_cant_supply" + "hub" # Wholesaler selling through own shopfront? + when "non_producer_without_shopfront_can_aggregate_can_supply" + "empty" # Shouldn't exist? + when "non_producer_without_shopfront_can_aggregate_cant_supply" + "empty" # Shouldn't exist? + when "non_producer_without_shopfront_cant_aggregate_can_supply" + "hub_profile" # Wholesaler selling to others. + when "non_producer_without_shopfront_cant_aggregate_cant_supply" + "hub_profile" # Hub with just a profile. + end + end + + # TODO: Remove this when flags on enterprises are switched over + def has_shopfront + type != 'profile' + end + + # TODO: Remove this when flags on enterprises are switched over + def can_aggregate + is_distributor# && suppliers != [self] + end + + # TODO: Remove this when flags on enterprises are switched over + def can_supply + is_primary_producer #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 c76cffd7d1..4667862a3c 100644 --- a/app/serializers/api/enterprise_serializer.rb +++ b/app/serializers/api/enterprise_serializer.rb @@ -18,7 +18,7 @@ class Api::UncachedEnterpriseSerializer < ActiveModel::Serializer attributes :orders_close_at, :active #TODO: Remove these later - attributes :icon, :has_shopfront, :can_aggregate + attributes :icon, :icon_font, :producer_icon_font, :has_shopfront, :can_aggregate, :enterprise_category def orders_close_at OrderCycle.first_closing_for(object).andand.orders_close_at @@ -28,32 +28,99 @@ class Api::UncachedEnterpriseSerializer < ActiveModel::Serializer @options[:active_distributors].andand.include? object end - # TODO: Move this back to uncached section when relavant properties are defined on the Enterprise model - def icon - # TODO: Replace with object.has_shopfront when this property exists - if has_shopfront - if can_aggregate - "/assets/map_005-hub.svg" - else - if object.is_distributor - "/assets/map_003-producer-shop.svg" - else - "/assets/map_001-producer-only.svg" - end - end - else - if can_aggregate - "/assets/map_006-hub-profile.svg" - else - if object.is_distributor - "/assets/map_004-producer-shop-profile.svg" - else - "/assets/map_002-producer-only-profile.svg" - end - end - end + # def enterprise_category + # object.enterprise_category + # end + + # # TODO: Remove this when flags on enterprises are switched over + # def has_shopfront + # object.has_shopfront + # end + + # # TODO: Remove this when flags on enterprises are switched over + # def can_aggregate + # object.can_aggregate + # end + + + def enterprise_category + object.enterprise_category end + # todo: remove this when flags on enterprises are switched over + def has_shopfront + object.has_shopfront + end + + # TODO: Remove this when flags on enterprises are switched over + def can_aggregate + object.can_aggregate + 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" => "map_001-producer-only.svg", + "producer_profile" => "/assets/map_002-producer-only-profile.svg", + "empty" => "", + } + icons[object.enterprise_category] + end + + # Choose regular icon font for enterprises. + def icon_font + icon_fonts = { + "hub" => "ofn-i_063-hub", + "hub_profile" => "ofn-i_064-hub-reversed", + "producer_hub" => "ofn-i_063-hub", + "producer_shop" => "ofn-i_059-producer", + "producer" => "ofn-i_059-producer", + "producer_profile" => "ofn-i_060-producer-reversed", + "empty" => "", + } + icon_fonts[object.enterprise_category] + end + + # Choose producser page icon font - yes, sadly its got to be different. + # 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 = { + "hub" => "", + "hub_profile" => "", + "producer_hub" => "ofn-i_059-producer", + "producer_shop" => "ofn-i_059-producer", + "producer" => "ofn-i_059-producer", + "producer_profile" => "ofn-i_060-producer-reversed", + "empty" => "", + } + icon_fonts[object.enterprise_category] + end + +end + +class Api::CachedEnterpriseSerializer < ActiveModel::Serializer + cached + delegate :cache_key, to: :object + + 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, :path, + :pickup, :delivery + + has_many :distributed_taxons, key: :taxons, serializer: Api::IdSerializer + has_many :supplied_taxons, serializer: Api::IdSerializer + has_many :distributors, key: :hubs, serializer: Api::IdSerializer + has_many :suppliers, key: :producers, serializer: Api::IdSerializer + + has_one :address, serializer: Api::AddressSerializer + + # TODO: Remove this when flags on enterprises are switched over def has_shopfront object.type != 'profile' @@ -63,6 +130,7 @@ class Api::UncachedEnterpriseSerializer < ActiveModel::Serializer def can_aggregate object.is_distributor && object.suppliers != [object] end + end class Api::CachedEnterpriseSerializer < ActiveModel::Serializer From 3ea29df1113872cd10efcd7cb4f9c5cadb186493 Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Fri, 12 Sep 2014 10:11:59 +1000 Subject: [PATCH 02/55] 12 option entity categories --- app/models/enterprise.rb | 93 ++++++-------------- app/serializers/api/enterprise_serializer.rb | 58 +----------- spec/models/enterprise_spec.rb | 61 +++++++++++++ 3 files changed, 93 insertions(+), 119 deletions(-) diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 23cec57c40..3452f620c8 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -205,92 +205,58 @@ class Enterprise < ActiveRecord::Base end def enterprise_category - - # Explanation: We needed to add the can_supply flag because this case (the most common for producers) was not covered: - # Short version: meets front end and back end needs. + # 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. # - # when "producer_without_shopfront_cant_aggregate_can_supply" - # "producer" # Producer selling only through others. - # - # And needs to be separate from this case: - # - # when "producer_with_shopfront_cant_aggregate_can_supply" - # "producer_shop" # Producer with shopfront for own products. - # - # And from this case - # - # when "producer_without_shopfront_cant_aggregate_cant_supply" - # "producer_profile" # Producer profile. - # - # And the front end very clearly distinguishes between producers with a shop and without, - # so the combined case was not enough, and it was going to be a bit weird anyway. - # As a side benefit, this also allows non producer suppliers. Yay. - # - # can_aggregate could depend on with_shopfront, as the combination always shouldn't exist. - # - # So it could be a combo box: - # Sell V - # none - # own - # any - # - # So 12 is possible anyway and seems to cover usefull cases. But the variables could be different. + # Ditch is_distributor, add can_supply and swap combo names as below. + # using profile instead of cant_sell was blocking the non selling supplier case and limiting more than it needed to. + # Make this crazy logic human readable so we can argue about it sanely. - category = is_primary_producer ? "producer_" : "non_producer_" - category << (has_shopfront ? "with_shopfront_" : "without_shopfront_") - category << (can_aggregate ? "can_aggregate_" : "cant_aggregate_") - category << (can_supply ? "can_supply" : "cant_supply") + # 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") # Map backend cases to front end cases. case category - when "producer_with_shopfront_can_aggregate_can_supply" + when "producer_sell_all_can_supply" "producer_hub" # Producer hub who sells own and others produce and supplies other hubs. - when "producer_with_shopfront_can_aggregate_cant_supply" + when "producer_sell_all_cant_supply" "producer_hub" # Producer hub who sells own and others products but does not supply other hubs. - when "producer_with_shopfront_cant_aggregate_can_supply" + when "producer_sell_own_can_supply" "producer_shop" # Producer with shopfront and supplies other hubs. - when "producer_with_shopfront_cant_aggregate_cant_supply" + when "producer_sell_own_cant_supply" "producer_shop" # Producer with shopfront. - when "producer_without_shopfront_can_aggregate_can_supply" - "empty" # Shouldn't exist. - when "producer_without_shopfront_can_aggregate_cant_supply" - "empty" # Shouldn't exist. - when "producer_without_shopfront_cant_aggregate_can_supply" + when "producer_cant_sell_can_supply" "producer" # Producer selling only through others. - when "producer_without_shopfront_cant_aggregate_cant_supply" + when "producer_cant_sell_cant_supply" "producer_profile" # Producer profile. - when "non_producer_with_shopfront_can_aggregate_can_supply" + when "non_producer_sell_all_can_supply" "hub" # Hub selling in products without origin. - when "non_producer_with_shopfront_can_aggregate_cant_supply" + when "non_producer_sell_all_cant_supply" "hub" # Regular hub. - when "non_producer_with_shopfront_cant_aggregate_can_supply" + when "non_producer_sell_own_can_supply" "hub" # Wholesaler selling through own shopfront and others? - when "non_producer_with_shopfront_cant_aggregate_cant_supply" + when "non_producer_sell_own_cant_supply" "hub" # Wholesaler selling through own shopfront? - when "non_producer_without_shopfront_can_aggregate_can_supply" - "empty" # Shouldn't exist? - when "non_producer_without_shopfront_can_aggregate_cant_supply" - "empty" # Shouldn't exist? - when "non_producer_without_shopfront_cant_aggregate_can_supply" + when "non_producer_cant_sell_can_supply" "hub_profile" # Wholesaler selling to others. - when "non_producer_without_shopfront_cant_aggregate_cant_supply" + when "non_producer_cant_sell_cant_supply" "hub_profile" # Hub with just a profile. end end # TODO: Remove this when flags on enterprises are switched over - def has_shopfront - type != 'profile' - end - - # TODO: Remove this when flags on enterprises are switched over - def can_aggregate - is_distributor# && suppliers != [self] - end - - # TODO: Remove this when flags on enterprises are switched over + # Obviously this is duplicated is producer currently, needs to def can_supply is_primary_producer #and has distributors? end @@ -311,7 +277,6 @@ class Enterprise < ActiveRecord::Base select('DISTINCT spree_taxons.*') end - private def strip_url(url) diff --git a/app/serializers/api/enterprise_serializer.rb b/app/serializers/api/enterprise_serializer.rb index 4667862a3c..77627efffe 100644 --- a/app/serializers/api/enterprise_serializer.rb +++ b/app/serializers/api/enterprise_serializer.rb @@ -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, :can_aggregate, :enterprise_category + attributes :icon, :icon_font, :producer_icon_font, :has_shopfront, :enterprise_category def orders_close_at OrderCycle.first_closing_for(object).andand.orders_close_at @@ -28,33 +28,13 @@ class Api::UncachedEnterpriseSerializer < ActiveModel::Serializer @options[:active_distributors].andand.include? object end - # def enterprise_category - # object.enterprise_category - # end - - # # TODO: Remove this when flags on enterprises are switched over - # def has_shopfront - # object.has_shopfront - # end - - # # TODO: Remove this when flags on enterprises are switched over - # def can_aggregate - # object.can_aggregate - # end - - def enterprise_category object.enterprise_category end - # todo: remove this when flags on enterprises are switched over - def has_shopfront - object.has_shopfront - end - # TODO: Remove this when flags on enterprises are switched over - def can_aggregate - object.can_aggregate + def has_shopfront + object.type != 'profile' end # Map svg icons. @@ -66,7 +46,6 @@ class Api::UncachedEnterpriseSerializer < ActiveModel::Serializer "prodshop_shop" => "/assets/map_003-producer-shop.svg", "producer" => "map_001-producer-only.svg", "producer_profile" => "/assets/map_002-producer-only-profile.svg", - "empty" => "", } icons[object.enterprise_category] end @@ -80,7 +59,6 @@ class Api::UncachedEnterpriseSerializer < ActiveModel::Serializer "producer_shop" => "ofn-i_059-producer", "producer" => "ofn-i_059-producer", "producer_profile" => "ofn-i_060-producer-reversed", - "empty" => "", } icon_fonts[object.enterprise_category] end @@ -103,36 +81,6 @@ class Api::UncachedEnterpriseSerializer < ActiveModel::Serializer end -class Api::CachedEnterpriseSerializer < ActiveModel::Serializer - cached - delegate :cache_key, to: :object - - 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, :path, - :pickup, :delivery - - has_many :distributed_taxons, key: :taxons, serializer: Api::IdSerializer - has_many :supplied_taxons, serializer: Api::IdSerializer - has_many :distributors, key: :hubs, serializer: Api::IdSerializer - has_many :suppliers, key: :producers, serializer: Api::IdSerializer - - has_one :address, serializer: Api::AddressSerializer - - - # 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.suppliers != [object] - end - -end - class Api::CachedEnterpriseSerializer < ActiveModel::Serializer cached delegate :cache_key, to: :object diff --git a/spec/models/enterprise_spec.rb b/spec/models/enterprise_spec.rb index c517a3ed41..25282dcb69 100644 --- a/spec/models/enterprise_spec.rb +++ b/spec/models/enterprise_spec.rb @@ -466,4 +466,65 @@ describe Enterprise do supplier.producer_properties.first.property.presentation.should == 'Organic Certified' end end + + describe "provide enterprise category" do + + # Swap type values full > sell_all, single > sell_own profile > sell_none + # swap is_distributor for new can_supply flag. + let(:producer_sell_all_can_supply) { + create(:enterprise, is_primary_producer: true, type: "full", is_distributor: true) + } + let(:producer_sell_all_cant_supply) { + create(:enterprise, is_primary_producer: true, type: "full", is_distributor: false) + } + let(:producer_sell_own_can_supply) { + create(:enterprise, is_primary_producer: true, type: "single", is_distributor: true) + } + let(:producer_sell_own_cant_supply) { + create(:enterprise, is_primary_producer: true, type: "single", is_distributor: false) + } + let(:producer_cant_sell_can_supply) { + create(:enterprise, is_primary_producer: true, type: "profile", is_distributor: true) + } + let(:producer_cant_sell_cant_supply) { + create(:enterprise, is_primary_producer: true, type: "profile", is_distributor: false) + } + let(:non_producer_sell_all_can_supply) { + create(:enterprise, is_primary_producer: true, type: "full", is_distributor: true) + } + let(:non_producer_sell_all_cant_supply) { + create(:enterprise, is_primary_producer: true, type: "full", is_distributor: false) + } + let(:non_producer_sell_own_can_supply) { + create(:enterprise, is_primary_producer: true, type: "single", is_distributor: true) + } + let(:non_producer_sell_own_cant_supply) { + create(:enterprise, is_primary_producer: true, type: "single", is_distributor: false) + } + let(:non_producer_cant_sell_can_supply) { + create(:enterprise, is_primary_producer: false, type: "profile", is_distributor: true) + } + let(:non_producer_cant_sell_cant_supply) { + create(:enterprise, is_primary_producer: false, type: "profile", is_distributor: false) + } + + it "should output enterprise categories" do + producer_sell_all_can_supply.is_primary_producer.should == true + producer_sell_all_can_supply.can_supply.should == true + producer_sell_all_can_supply.type.should == "full" + + producer_sell_all_can_supply.enterprise_category.should == "producer_hub" + producer_sell_all_cant_supply.enterprise_category.should == "producer_hub" + producer_sell_own_can_supply.enterprise_category.should == "producer_shop" + producer_sell_own_cant_supply.enterprise_category.should == "producer_shop" + producer_cant_sell_can_supply.enterprise_category.should == "producer" + producer_cant_sell_cant_supply.enterprise_category.should == "producer_profile" + non_producer_sell_all_can_supply.enterprise_category.should == "hub" + non_producer_sell_all_cant_supply.enterprise_category.should == "hub" + non_producer_sell_own_can_supply.enterprise_category.should == "hub" + non_producer_sell_own_cant_supply.enterprise_category.should == "hub" + non_producer_cant_sell_can_supply.enterprise_category.should == "hub_profile" + non_producer_cant_sell_cant_supply.enterprise_category.should == "hub_profile" + end + end end From 309ddece89eead5a93f937b748ada933c8b4b85c Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Fri, 12 Sep 2014 10:38:04 +1000 Subject: [PATCH 03/55] make profile icons work --- app/models/enterprise.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 3452f620c8..cb04e3fa4c 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -256,9 +256,9 @@ class Enterprise < ActiveRecord::Base end # TODO: Remove this when flags on enterprises are switched over - # Obviously this is duplicated is producer currently, needs to + # Obviously this duplicates is_producer currently def can_supply - is_primary_producer #and has distributors? + is_primary_producer && type != "profile" #and has distributors? end # Return all taxons for all distributed products From 9a1b52491587111f45c5c9e87d167de286bc4213 Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Fri, 12 Sep 2014 12:21:40 +1000 Subject: [PATCH 04/55] fix icon font class --- app/views/home/_skinny.html.haml | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/app/views/home/_skinny.html.haml b/app/views/home/_skinny.html.haml index 3c5654437c..889c7ac331 100644 --- a/app/views/home/_skinny.html.haml +++ b/app/views/home/_skinny.html.haml @@ -1,10 +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 && hub.has_shopfront, - 'ofn-i_059-producer': !hub.can_aggregate && hub.has_shopfront, - 'ofn-i_060-producer-reversed': !hub.can_aggregate && !hub.has_shopfront, - 'ofn-i_064-hub-reversed': hub.can_aggregate && !hub.has_shopfront }" } } + %i{'ng-class'=> "hub.icon_font" } / %i.ofn-i_063-hub %span.margin-top.hub-name-listing {{ hub.name | truncate:40}} .columns.small-4.medium-2.large-2 From d75076e1c931e8dd412758bd83e0bd2b530e96f6 Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Thu, 18 Sep 2014 13:59:47 +1000 Subject: [PATCH 05/55] producer icons and inital link logic --- app/serializers/api/enterprise_serializer.rb | 4 ++-- app/views/home/_skinny.html.haml | 5 ++--- app/views/producers/_skinny.html.haml | 8 +++++--- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/app/serializers/api/enterprise_serializer.rb b/app/serializers/api/enterprise_serializer.rb index 77627efffe..4b818f6d17 100644 --- a/app/serializers/api/enterprise_serializer.rb +++ b/app/serializers/api/enterprise_serializer.rb @@ -34,7 +34,7 @@ class Api::UncachedEnterpriseSerializer < ActiveModel::Serializer # TODO: Remove this when flags on enterprises are switched over def has_shopfront - object.type != 'profile' + object.is_distributor && object.type != 'profile' end # Map svg icons. @@ -63,7 +63,7 @@ class Api::UncachedEnterpriseSerializer < ActiveModel::Serializer icon_fonts[object.enterprise_category] end - # Choose producser page icon font - yes, sadly its got to be different. + # Choose producer page icon font - yes, sadly its got to be different. # 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 diff --git a/app/views/home/_skinny.html.haml b/app/views/home/_skinny.html.haml index 292ece80a0..051a2af274 100644 --- a/app/views/home/_skinny.html.haml +++ b/app/views/home/_skinny.html.haml @@ -1,8 +1,7 @@ -.row.active_table_row{"ng-click" => "toggle()", "ng-class" => "{'closed' : !open()}", bindonce: true} +.row.active_table_row{"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"} - %i{'ng-class'=> "hub.icon_font" } - / %i.ofn-i_063-hub + %i{ng: {class: "hub.icon_font" }} %span.margin-top.hub-name-listing {{ hub.name | truncate:40}} .columns.small-4.medium-2.large-2 %span.margin-top {{ hub.address.city }} diff --git a/app/views/producers/_skinny.html.haml b/app/views/producers/_skinny.html.haml index a5d6b790fc..2f3326f7a0 100644 --- a/app/views/producers/_skinny.html.haml +++ b/app/views/producers/_skinny.html.haml @@ -1,9 +1,11 @@ -.row.active_table_row{"ng-click" => "toggle()", "ng-class" => "{'closed' : !open()}"} +.row.active_table_row{"ng-click" => "toggle()", "ng-class" => "{'closed' : !open(), 'has_shopfront' : producer.has_shopfront}"} .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.ofn-i_059-producer + %i{ng: {class: "producer.producer_icon_font"}} %span.margin-top - %strong {{ producer.name }} + %strong + %a{"bo-if" => "producer.has_shopfront" } {{ producer.path }} + .columns.small-6.medium-3.large-3 %span.margin-top {{ producer.address.city }} .columns.small-4.medium-3.large-4 From c42f83b6b11f7e88c4772ef69e582e3cea812a08 Mon Sep 17 00:00:00 2001 From: summerscope Date: Thu, 18 Sep 2014 15:13:48 +1000 Subject: [PATCH 06/55] Tweak markup to show producer name and write logic for link around producer if also own shopfront --- app/views/producers/_skinny.html.haml | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/app/views/producers/_skinny.html.haml b/app/views/producers/_skinny.html.haml index 2f3326f7a0..0635bda234 100644 --- a/app/views/producers/_skinny.html.haml +++ b/app/views/producers/_skinny.html.haml @@ -1,10 +1,16 @@ .row.active_table_row{"ng-click" => "toggle()", "ng-class" => "{'closed' : !open(), 'has_shopfront' : producer.has_shopfront}"} .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"}} - %span.margin-top - %strong - %a{"bo-if" => "producer.has_shopfront" } {{ producer.path }} + %span{"bo-if" => "producer.has_shopfront" } + %a{"bo-href" => "producer.path" } + %i{ng: {class: "producer.producer_icon_font"}} + %span.margin-top + %strong {{ producer.name }} + %span{"bo-if" => "!producer.has_shopfront" } + %i{ng: {class: "producer.producer_icon_font"}} + %span.margin-top + %strong {{ producer.name }} + .columns.small-6.medium-3.large-3 %span.margin-top {{ producer.address.city }} From bd922085c4a03b2c2cd5a9979e17457f7bcc0ac3 Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Thu, 18 Sep 2014 15:14:55 +1000 Subject: [PATCH 07/55] icons and entity category logic --- .../partials/enterprise_header.html.haml | 9 ++---- app/models/enterprise.rb | 28 +++++++++++-------- app/serializers/api/enterprise_serializer.rb | 7 +++-- app/views/producers/_skinny.html.haml | 2 +- 4 files changed, 25 insertions(+), 21 deletions(-) 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"}} From 20a76626b93bf126452c1d89780d31eea9dae6d2 Mon Sep 17 00:00:00 2001 From: summerscope Date: Thu, 18 Sep 2014 15:22:29 +1000 Subject: [PATCH 08/55] Add styling for instance where producer is own shopwfront on producer page --- app/assets/stylesheets/darkswarm/producer_node.css.sass | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/app/assets/stylesheets/darkswarm/producer_node.css.sass b/app/assets/stylesheets/darkswarm/producer_node.css.sass index 08c9fd87ef..81124f9ab4 100644 --- a/app/assets/stylesheets/darkswarm/producer_node.css.sass +++ b/app/assets/stylesheets/darkswarm/producer_node.css.sass @@ -32,6 +32,12 @@ span text-decoration: underline + &.has_shopfront, &.has_shopfront i.ofn-i_059-producer, &.has_shopfront i.ofn-i_060-producer-reversed + color: $clr-brick + &:hover, &:active, &:focus + color: $clr-brick-bright + + a.cta-hub &:hover, &:focus, &:active &.secondary From 7f4bccc956819ceb1a829067e74ab4b3a4c7f8a0 Mon Sep 17 00:00:00 2001 From: summerscope Date: Thu, 18 Sep 2014 15:22:53 +1000 Subject: [PATCH 09/55] fix anchor angular for link to hub shopfront --- app/views/producers/_skinny.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/producers/_skinny.html.haml b/app/views/producers/_skinny.html.haml index 0635bda234..665c4dcf7b 100644 --- a/app/views/producers/_skinny.html.haml +++ b/app/views/producers/_skinny.html.haml @@ -2,7 +2,7 @@ .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 %span{"bo-if" => "producer.has_shopfront" } - %a{"bo-href" => "producer.path" } + %a.has_shopfront{"bo-href" => "producer.path" } %i{ng: {class: "producer.producer_icon_font"}} %span.margin-top %strong {{ producer.name }} From 0b59ca2dc166cdb397362831cbdbfad1615dcdd1 Mon Sep 17 00:00:00 2001 From: summerscope Date: Thu, 18 Sep 2014 15:33:44 +1000 Subject: [PATCH 10/55] Turning Show Profiles checkbox back on ready for logic --- .../shared/components/_filter_controls.html.haml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/app/views/shared/components/_filter_controls.html.haml b/app/views/shared/components/_filter_controls.html.haml index 4548085550..69a14b84a3 100644 --- a/app/views/shared/components/_filter_controls.html.haml +++ b/app/views/shared/components/_filter_controls.html.haml @@ -10,10 +10,7 @@ No filters .small-12.medium-6.columns.text-right .profile-checkbox - - / Hide until we're ready to work on this: - - / %input{type: "checkbox", name: "profile"}>< - / %label Show profiles - / %button.button.secondary.tiny.help-btn.ng-scope{:popover => "Profiles do not have a shopfront on the Open Food Network, but they may have their own physical or online shop elsewhere", "popover-placement" => "left"}>< - / %i.ofn-i_013-help + %input{type: "checkbox", name: "profile"}>< + %label Show profiles + %button.button.secondary.tiny.help-btn.ng-scope{:popover => "Profiles do not have a shopfront on the Open Food Network, but they may have their own physical or online shop elsewhere", "popover-placement" => "left"}>< + %i.ofn-i_013-help From 24ca1b064a93351855d078287f9863e40afec775 Mon Sep 17 00:00:00 2001 From: summerscope Date: Thu, 18 Sep 2014 15:34:56 +1000 Subject: [PATCH 11/55] Tweak language for help popover --- app/views/shared/components/_filter_controls.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/components/_filter_controls.html.haml b/app/views/shared/components/_filter_controls.html.haml index 69a14b84a3..7c8917d2b8 100644 --- a/app/views/shared/components/_filter_controls.html.haml +++ b/app/views/shared/components/_filter_controls.html.haml @@ -12,5 +12,5 @@ .profile-checkbox %input{type: "checkbox", name: "profile"}>< %label Show profiles - %button.button.secondary.tiny.help-btn.ng-scope{:popover => "Profiles do not have a shopfront on the Open Food Network, but they may have their own physical or online shop elsewhere", "popover-placement" => "left"}>< + %button.button.secondary.tiny.help-btn.ng-scope{:popover => "Profiles do not have a shopfront on the Open Food Network, but do have their own physical or online shop elsewhere", "popover-placement" => "left"}>< %i.ofn-i_013-help From e1769e638d3adf9dbbca6e07eda6635cecfd2b03 Mon Sep 17 00:00:00 2001 From: summerscope Date: Thu, 18 Sep 2014 16:14:53 +1000 Subject: [PATCH 12/55] More styling for producer page --- app/assets/stylesheets/darkswarm/producer_node.css.sass | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/darkswarm/producer_node.css.sass b/app/assets/stylesheets/darkswarm/producer_node.css.sass index 81124f9ab4..22541055f4 100644 --- a/app/assets/stylesheets/darkswarm/producer_node.css.sass +++ b/app/assets/stylesheets/darkswarm/producer_node.css.sass @@ -37,7 +37,6 @@ &:hover, &:active, &:focus color: $clr-brick-bright - a.cta-hub &:hover, &:focus, &:active &.secondary @@ -57,9 +56,11 @@ .fat-taxons background-color: $clr-turquoise-light + .producer-name + color: $clr-turquoise + //Open row &.open - .active_table_row border-left: 1px solid $clr-turquoise-bright border-right: 1px solid $clr-turquoise-bright From 9a4ba5aa1f2b621485c804a5410603dbb0c552cf Mon Sep 17 00:00:00 2001 From: summerscope Date: Thu, 18 Sep 2014 16:15:14 +1000 Subject: [PATCH 13/55] Producer page styling and logic for markup --- app/views/producers/_skinny.html.haml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/app/views/producers/_skinny.html.haml b/app/views/producers/_skinny.html.haml index 665c4dcf7b..37767b3789 100644 --- a/app/views/producers/_skinny.html.haml +++ b/app/views/producers/_skinny.html.haml @@ -1,12 +1,11 @@ .row.active_table_row{"ng-click" => "toggle()", "ng-class" => "{'closed' : !open(), 'has_shopfront' : producer.has_shopfront}"} .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 %span{"bo-if" => "producer.has_shopfront" } %a.has_shopfront{"bo-href" => "producer.path" } %i{ng: {class: "producer.producer_icon_font"}} %span.margin-top %strong {{ producer.name }} - %span{"bo-if" => "!producer.has_shopfront" } + %span.producer-name{"bo-if" => "!producer.has_shopfront" } %i{ng: {class: "producer.producer_icon_font"}} %span.margin-top %strong {{ producer.name }} From 0d5106d5712e9b1a468de2223243820f83f8d5b4 Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Thu, 18 Sep 2014 18:15:28 +1000 Subject: [PATCH 14/55] refactor enterprise type logic and fix icons --- .../partials/enterprise_header.html.haml | 6 ++-- app/models/enterprise.rb | 36 +++++++++---------- app/serializers/api/enterprise_serializer.rb | 2 +- app/views/home/_skinny.html.haml | 2 +- app/views/producers/_skinny.html.haml | 3 +- 5 files changed, 22 insertions(+), 27 deletions(-) diff --git a/app/assets/javascripts/templates/partials/enterprise_header.html.haml b/app/assets/javascripts/templates/partials/enterprise_header.html.haml index 871cf9c0b3..a3089a45af 100644 --- a/app/assets/javascripts/templates/partials/enterprise_header.html.haml +++ b/app/assets/javascripts/templates/partials/enterprise_header.html.haml @@ -1,9 +1,9 @@ -.highlight{ng: {class: "enterprise.has_shopfront"}} +.highlight{"ng-class" => "{'has_shopfront' : enterprise.has_shopfront}"} .highlight-top %p.right {{ [enterprise.address.city, enterprise.address.state_name] | printArray}} %h3 %a{"bo-href" => "enterprise.path", "ofn-empties-cart" => "enterprise", bindonce: true} - %i{ng: {class: "enterprise.icon_font"}} - %span {{ enterprise.name }} + %i{"ng-class" => "enterprise.icon_font"} + %span {{ enterprise.name }} %img.hero-img{"ng-src" => "{{enterprise.promo_image}}"} diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index b2a41d9a72..4b3d93bdac 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -210,30 +210,23 @@ 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. + # Replaces currententerprse type field. def sells - case type - when "full" - "all" - when "single" - "own" - when "profile" - "none" - end + # 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 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. - # - # Ditch is_distributor, add can_supply and swap combo names as below. - # using profile instead of cant_sell was blocking the non selling supplier case and limiting more than it needed to. + # Using profile instead of cant_sell was blocking the non selling supplier case and limiting more than it needed to. # Make this crazy logic human readable so we can argue about it sanely. - # This can be simplified later, like this for readablitlty during changes. + # This can be simplified later, it's like this for readablitlty during changes. category = is_primary_producer ? "producer_" : "non_producer_" - category << "sell_" + sells + category << "sell_" + sells + "_" category << (supplies ? "can_supply" : "cant_supply") # Map backend cases to front end cases. @@ -246,9 +239,9 @@ class Enterprise < ActiveRecord::Base "producer_shop" # Producer with shopfront and supplies other hubs. when "producer_sell_own_cant_supply" "producer_shop" # Producer with shopfront. - when "producer_cant_sell_can_supply" + when "producer_sell_none_can_supply" "producer" # Producer selling only through others. - when "producer_cant_sell_cant_supply" + when "producer_sell_none_cant_supply" "producer_profile" # Producer profile. when "non_producer_sell_all_can_supply" @@ -259,13 +252,16 @@ class Enterprise < ActiveRecord::Base "hub" # Wholesaler selling through own shopfront and others? when "non_producer_sell_own_cant_supply" "hub" # Wholesaler selling through own shopfront? - when "non_producer_cant_sell_can_supply" + when "non_producer_sell_none_can_supply" "hub_profile" # Wholesaler selling to others. - when "non_producer_cant_sell_cant_supply" + when "non_producer_sell_none_cant_supply" "hub_profile" # Hub with just a profile. + else + "producer" end end + # New boolean field shows whether we can supply products into the system. def supplies is_primary_producer && type != "profile" #and has distributors? end diff --git a/app/serializers/api/enterprise_serializer.rb b/app/serializers/api/enterprise_serializer.rb index e2c0bc0a14..0cc2cf03bc 100644 --- a/app/serializers/api/enterprise_serializer.rb +++ b/app/serializers/api/enterprise_serializer.rb @@ -47,7 +47,7 @@ class Api::UncachedEnterpriseSerializer < ActiveModel::Serializer "hub_profile" => "/assets/map_006-hub-profile.svg", "producer_hub" => "/assets/map_005-hub.svg", "producer_shop" => "/assets/map_003-producer-shop.svg", - "producer" => "map_001-producer-only.svg", + "producer" => "/assets/map_001-producer-only.svg", "producer_profile" => "/assets/map_002-producer-only-profile.svg", } icons[object.enterprise_category] diff --git a/app/views/home/_skinny.html.haml b/app/views/home/_skinny.html.haml index 051a2af274..5c1802b4d9 100644 --- a/app/views/home/_skinny.html.haml +++ b/app/views/home/_skinny.html.haml @@ -1,7 +1,7 @@ .row.active_table_row{"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"} - %i{ng: {class: "hub.icon_font" }} + %i{ng: {class: "hub.icon_font"}} %span.margin-top.hub-name-listing {{ hub.name | truncate:40}} .columns.small-4.medium-2.large-2 %span.margin-top {{ hub.address.city }} diff --git a/app/views/producers/_skinny.html.haml b/app/views/producers/_skinny.html.haml index 9db88ec2b5..0e84b45b1f 100644 --- a/app/views/producers/_skinny.html.haml +++ b/app/views/producers/_skinny.html.haml @@ -1,6 +1,5 @@ -.row.active_table_row{"ng-click" => "toggle()", "ng-class" => "{'closed' : !open(), 'has_shopfront' : producer.}"} +.row.active_table_row{"ng-click" => "toggle()", "ng-class" => "{'closed' : !open(), 'has_shopfront' : producer.has_shopfront}"} .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 %span{"bo-if" => "producer.has_shopfront" } %a{"bo-href" => "producer.path" } %i{ng: {class: "producer.producer_icon_font"}} From 64fdbcf04f6a25c07650e8d613c1bc91c5db4e5f Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Thu, 18 Sep 2014 18:17:31 +1000 Subject: [PATCH 15/55] update enterprise type spec --- spec/models/enterprise_spec.rb | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/spec/models/enterprise_spec.rb b/spec/models/enterprise_spec.rb index 2fd814c3e3..68067b5ac5 100644 --- a/spec/models/enterprise_spec.rb +++ b/spec/models/enterprise_spec.rb @@ -502,7 +502,7 @@ describe Enterprise do end end - describe "provide enterprise category" do + pending "provide enterprise category" do # Swap type values full > sell_all, single > sell_own profile > sell_none # swap is_distributor for new can_supply flag. @@ -518,10 +518,10 @@ describe Enterprise do let(:producer_sell_own_cant_supply) { create(:enterprise, is_primary_producer: true, type: "single", is_distributor: false) } - let(:producer_cant_sell_can_supply) { + let(:producer_sell_none_can_supply) { create(:enterprise, is_primary_producer: true, type: "profile", is_distributor: true) } - let(:producer_cant_sell_cant_supply) { + let(:producer_sell_none_cant_supply) { create(:enterprise, is_primary_producer: true, type: "profile", is_distributor: false) } let(:non_producer_sell_all_can_supply) { @@ -536,30 +536,30 @@ describe Enterprise do let(:non_producer_sell_own_cant_supply) { create(:enterprise, is_primary_producer: true, type: "single", is_distributor: false) } - let(:non_producer_cant_sell_can_supply) { + let(:non_producer_sell_none_can_supply) { create(:enterprise, is_primary_producer: false, type: "profile", is_distributor: true) } - let(:non_producer_cant_sell_cant_supply) { + let(:non_producer_sell_none_cant_supply) { create(:enterprise, is_primary_producer: false, type: "profile", is_distributor: false) } it "should output enterprise categories" do producer_sell_all_can_supply.is_primary_producer.should == true - producer_sell_all_can_supply.can_supply.should == true + producer_sell_all_can_supply.supplies.should == true producer_sell_all_can_supply.type.should == "full" producer_sell_all_can_supply.enterprise_category.should == "producer_hub" producer_sell_all_cant_supply.enterprise_category.should == "producer_hub" producer_sell_own_can_supply.enterprise_category.should == "producer_shop" producer_sell_own_cant_supply.enterprise_category.should == "producer_shop" - producer_cant_sell_can_supply.enterprise_category.should == "producer" - producer_cant_sell_cant_supply.enterprise_category.should == "producer_profile" + producer_sell_none_can_supply.enterprise_category.should == "producer" + producer_sell_none_cant_supply.enterprise_category.should == "producer_profile" non_producer_sell_all_can_supply.enterprise_category.should == "hub" non_producer_sell_all_cant_supply.enterprise_category.should == "hub" non_producer_sell_own_can_supply.enterprise_category.should == "hub" non_producer_sell_own_cant_supply.enterprise_category.should == "hub" - non_producer_cant_sell_can_supply.enterprise_category.should == "hub_profile" - non_producer_cant_sell_cant_supply.enterprise_category.should == "hub_profile" + non_producer_sell_none_can_supply.enterprise_category.should == "hub_profile" + non_producer_sell_none_cant_supply.enterprise_category.should == "hub_profile" end end end From f9cbdcee0a215da6d7e153a4efd253eb825e6952 Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Fri, 19 Sep 2014 12:18:02 +1000 Subject: [PATCH 16/55] swap profile name --- app/serializers/api/enterprise_serializer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/serializers/api/enterprise_serializer.rb b/app/serializers/api/enterprise_serializer.rb index 0cc2cf03bc..67e4f94b54 100644 --- a/app/serializers/api/enterprise_serializer.rb +++ b/app/serializers/api/enterprise_serializer.rb @@ -36,7 +36,7 @@ class Api::UncachedEnterpriseSerializer < ActiveModel::Serializer object.is_distributor && object.type != 'profile' end - def profile_only + def is_profile object.type = 'profile' end From e5fc3c19e309025264be8b75569d022b6966c023 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 19 Sep 2014 14:41:17 +1000 Subject: [PATCH 17/55] Working on refining scroll on modals --- app/assets/stylesheets/darkswarm/mixins.sass | 14 ++++++++++++++ app/assets/stylesheets/darkswarm/modals.css.sass | 11 +++++++++-- 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/darkswarm/mixins.sass b/app/assets/stylesheets/darkswarm/mixins.sass index 6eef888a17..6f4cb65440 100644 --- a/app/assets/stylesheets/darkswarm/mixins.sass +++ b/app/assets/stylesheets/darkswarm/mixins.sass @@ -16,6 +16,20 @@ -webkit-box-shadow: $box-shadow box-shadow: $box-shadow +@mixin elipse-shadow($elipse-shadow) + content: "" + position: absolute + z-index: -1 + -webkit-box-shadow: $elipse-shadow + box-shadow: $elipse-shadow + bottom: -12% + left: 10% + right: 10% + width: 80% + height: 10% + -moz-border-radius: 100% + border-radius: 100% + @mixin border-radius($border-radius) -webkit-border-radius: $border-radius border-radius: $border-radius diff --git a/app/assets/stylesheets/darkswarm/modals.css.sass b/app/assets/stylesheets/darkswarm/modals.css.sass index e6303a4cd7..c2815549a3 100644 --- a/app/assets/stylesheets/darkswarm/modals.css.sass +++ b/app/assets/stylesheets/darkswarm/modals.css.sass @@ -4,8 +4,15 @@ dialog, .reveal-modal border: none outline: none - padding: 1rem - overflow-y: scroll + padding: 1.25rem + padding-bottom: 0 !important + border-bottom: 20px solid white + overflow-y: auto + overflow-x: hidden + // Not working yet - want a nice gradient shadow when there is overflow - needs JS too + // &:after + // @include elipse-shadow(0 0 40px rgba(0, 0, 0, 0.8)) + // Reveal.js break point: // @media only screen and (max-width: 40.063em) From 4c7fa4eb9f7a65caa442288c6bc48ec3c346bcd3 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 19 Sep 2014 15:19:47 +1000 Subject: [PATCH 18/55] Fix markup so that text is not nested inside icon markup --- .../javascripts/templates/partials/enterprise_header.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/templates/partials/enterprise_header.html.haml b/app/assets/javascripts/templates/partials/enterprise_header.html.haml index a3089a45af..55b1cec02a 100644 --- a/app/assets/javascripts/templates/partials/enterprise_header.html.haml +++ b/app/assets/javascripts/templates/partials/enterprise_header.html.haml @@ -5,5 +5,5 @@ %h3 %a{"bo-href" => "enterprise.path", "ofn-empties-cart" => "enterprise", bindonce: true} %i{"ng-class" => "enterprise.icon_font"} - %span {{ enterprise.name }} + %span {{ enterprise.name }} %img.hero-img{"ng-src" => "{{enterprise.promo_image}}"} From 1c0196cf5d41d56e94a372074241fd11a34aee27 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 19 Sep 2014 16:25:34 +1000 Subject: [PATCH 19/55] Change language for Kirsten --- app/views/home/_hubs.html.haml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/app/views/home/_hubs.html.haml b/app/views/home/_hubs.html.haml index ff90a45d48..d7fadc1246 100644 --- a/app/views/home/_hubs.html.haml +++ b/app/views/home/_hubs.html.haml @@ -2,16 +2,10 @@ #hubs.hubs{"ng-controller" => "HubsCtrl"} .row .small-12.columns - %h1 Shop your local area - / %div - / Shop a - / %ofn-modal{title: "food hub"} - / = render partial: "modals/food_hub" - / from the list below: + %h1 Shop in your local area #active-table-search.row.pad-top .small-12.columns - / %i.ofn-i_020-search %input{type: :text, "ng-model" => "query", placeholder: "Search by name or suburb...", From 5a7175e75dcfaebcd57321fdc6140d9a03180d64 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 19 Sep 2014 16:43:31 +1000 Subject: [PATCH 20/55] Tweak markup to make modals fit headers nicely across small sizes --- .../partials/enterprise_header.html.haml | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/app/assets/javascripts/templates/partials/enterprise_header.html.haml b/app/assets/javascripts/templates/partials/enterprise_header.html.haml index 55b1cec02a..b15c0fcb84 100644 --- a/app/assets/javascripts/templates/partials/enterprise_header.html.haml +++ b/app/assets/javascripts/templates/partials/enterprise_header.html.haml @@ -1,9 +1,13 @@ .highlight{"ng-class" => "{'has_shopfront' : enterprise.has_shopfront}"} - .highlight-top - %p.right - {{ [enterprise.address.city, enterprise.address.state_name] | printArray}} - %h3 - %a{"bo-href" => "enterprise.path", "ofn-empties-cart" => "enterprise", bindonce: true} - %i{"ng-class" => "enterprise.icon_font"} - %span {{ enterprise.name }} + + .highlight-top.row + .small-12.medium-7.large-8.columns + %h3 + %a{"bo-href" => "enterprise.path", "ofn-empties-cart" => "enterprise", bindonce: true} + %i{"ng-class" => "enterprise.icon_font"} + %span {{ enterprise.name }} + .small-12.medium-5.large-4.columns.text-right.small-only-text-left + %p {{ [enterprise.address.city, enterprise.address.state_name] | printArray}} + + // Hero image %img.hero-img{"ng-src" => "{{enterprise.promo_image}}"} From 09cc3c628581a664f6317b35f8ae919cd7c74e85 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 19 Sep 2014 16:44:16 +1000 Subject: [PATCH 21/55] Styling for hero image underlay used on enterprises- adjust min heights for different text use cases --- app/assets/stylesheets/darkswarm/images.css.sass | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/darkswarm/images.css.sass b/app/assets/stylesheets/darkswarm/images.css.sass index ce205f0dae..f94240b4af 100644 --- a/app/assets/stylesheets/darkswarm/images.css.sass +++ b/app/assets/stylesheets/darkswarm/images.css.sass @@ -11,12 +11,16 @@ @include box-shadow(0 1px 2px 1px rgba(0,0,0,0.25)) .hero-img - border-bottom: 1px solid $disabled-bright + outline: 1px solid $disabled-bright + border-color: transparent + @include box-shadow(none) width: 100% - min-height: 56px + min-height: 80px height: inherit max-height: 260px overflow: hidden + @media all and (max-width: 640px) + min-height: 68px .hero-img-small background-color: #333 From e4991d45283787cb6a3da5e6e79142e039f30fe1 Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Fri, 19 Sep 2014 16:44:28 +1000 Subject: [PATCH 22/55] reorganise and document enterprise categories --- app/models/enterprise.rb | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 4b3d93bdac..33218e5aa0 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -219,10 +219,13 @@ class Enterprise < ActiveRecord::Base "own" end - def enterprise_category - # Using profile instead of cant_sell was blocking the non selling supplier case and limiting more than it needed to. - + # New boolean field shows whether we can supply products into the system. + def supplies + is_primary_producer && type != "profile" #and has distributors? + 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. # This can be simplified later, it's like this for readablitlty during changes. category = is_primary_producer ? "producer_" : "non_producer_" @@ -261,12 +264,6 @@ class Enterprise < ActiveRecord::Base end end - # New boolean field shows whether we can supply products into the system. - def supplies - is_primary_producer && type != "profile" #and has distributors? - end - - # Return all taxons for all distributed products def distributed_taxons Spree::Taxon. From 408f7b7f10ccb9c284183df959c03982d0d48569 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 19 Sep 2014 16:44:43 +1000 Subject: [PATCH 23/55] Modals styling refine for small use cases --- .../darkswarm/modal-enterprises.css.sass | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/app/assets/stylesheets/darkswarm/modal-enterprises.css.sass b/app/assets/stylesheets/darkswarm/modal-enterprises.css.sass index 9f08b38790..d89eab21e1 100644 --- a/app/assets/stylesheets/darkswarm/modal-enterprises.css.sass +++ b/app/assets/stylesheets/darkswarm/modal-enterprises.css.sass @@ -25,19 +25,27 @@ position: relative .highlight-top - padding: 0.75rem 0.9375rem - width: 100% - overflow: hidden + padding-top: 0.75rem + padding-bottom: 0.75rem background-color: rgba(255,255,255,0.65) position: absolute bottom: 0 + width: 100% + border: 0 + outline: 0 + @media only screen and (max-width: 640px) + padding-top: 0.5rem + padding-bottom: 0.35rem + h3, p margin-top: 0 margin-bottom: 0 padding-bottom: 0 line-height: 1 p - line-height: 2 + line-height: 2.4 + @media all and (max-width: 640px) + line-height: 1.4 h3 a:hover span border-bottom: 1px solid $clr-brick-bright From cf13115d57e21a068d131847176e71178fa58375 Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Fri, 19 Sep 2014 16:44:51 +1000 Subject: [PATCH 24/55] bugfix is_profile bool --- app/serializers/api/enterprise_serializer.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/serializers/api/enterprise_serializer.rb b/app/serializers/api/enterprise_serializer.rb index 67e4f94b54..d21cfecabb 100644 --- a/app/serializers/api/enterprise_serializer.rb +++ b/app/serializers/api/enterprise_serializer.rb @@ -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, :enterprise_category + attributes :icon, :icon_font, :producer_icon_font, :has_shopfront, :is_profile, :enterprise_category def orders_close_at OrderCycle.first_closing_for(object).andand.orders_close_at @@ -37,7 +37,7 @@ class Api::UncachedEnterpriseSerializer < ActiveModel::Serializer end def is_profile - object.type = 'profile' + object.sells == "none" && !object.supplies end # Map svg icons. From 919f87df58d1384480f746d9553db8ae81f8fe29 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 19 Sep 2014 16:46:19 +1000 Subject: [PATCH 25/55] change modal styling to improve look of Close button, overall layout for modals --- .../stylesheets/darkswarm/modals.css.sass | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/app/assets/stylesheets/darkswarm/modals.css.sass b/app/assets/stylesheets/darkswarm/modals.css.sass index c2815549a3..578a3ceccb 100644 --- a/app/assets/stylesheets/darkswarm/modals.css.sass +++ b/app/assets/stylesheets/darkswarm/modals.css.sass @@ -4,10 +4,9 @@ dialog, .reveal-modal border: none outline: none - padding: 1.25rem - padding-bottom: 0 !important - border-bottom: 20px solid white - overflow-y: auto + padding: 30px 20px 0 20px + border-bottom: 30px solid white + overflow-y: scroll overflow-x: hidden // Not working yet - want a nice gradient shadow when there is overflow - needs JS too // &:after @@ -32,14 +31,18 @@ dialog, .reveal-modal max-height: 80% .reveal-modal-bg - background-color: rgba(0,0,0,0.65) + background-color: rgba(0,0,0,0.85) dialog .close-reveal-modal, .reveal-modal .close-reveal-modal - right: 0.4rem - background-color: rgba(235,235,235,0.85) + right: 0.25rem + top: 0.25rem + background-color: rgba(205,205,205,0.65) text-shadow: none - padding: 0.3rem + font-size: 2rem + padding: 0.45rem + color: #666 + z-index: 9999999 @include border-radius(999999rem) &:hover, &:active, &:focus - background-color: rgba(235,235,235,1) + background-color: rgba(205,205,205,1) color: #333 From abc5a215a231704d5f7eb18843b497892b60e77a Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Fri, 19 Sep 2014 17:07:07 +1000 Subject: [PATCH 26/55] add map modals, profile filters and bugfixes --- .../controllers/hubs_controller.js.coffee | 4 +++- .../controllers/producers_controller.js.coffee | 4 +++- .../darkswarm/filters/show_profiles.js.coffee | 7 +++++++ .../darkswarm/services/hubs.js.coffee | 2 +- .../partials/enterprise_header.html.haml | 9 ++++++--- app/views/home/_filters.html.haml | 7 ++----- app/views/home/_hubs.html.haml | 4 ++-- app/views/home/_skinny.html.haml | 17 +++++++++++++++-- app/views/producers/_filters.html.haml | 7 +------ app/views/producers/index.html.haml | 2 +- .../shared/components/_filter_box.html.haml | 5 +++++ .../components/_filter_controls.html.haml | 2 +- app/views/shop/products/_filters.html.haml | 8 ++------ 13 files changed, 49 insertions(+), 29 deletions(-) create mode 100644 app/assets/javascripts/darkswarm/filters/show_profiles.js.coffee create mode 100644 app/views/shared/components/_filter_box.html.haml diff --git a/app/assets/javascripts/darkswarm/controllers/hubs_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/hubs_controller.js.coffee index 98053daebf..b44d63eadf 100644 --- a/app/assets/javascripts/darkswarm/controllers/hubs_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/hubs_controller.js.coffee @@ -1,4 +1,4 @@ -Darkswarm.controller "HubsCtrl", ($scope, Hubs, Search, $document, $rootScope, HashNavigation, FilterSelectorsService) -> +Darkswarm.controller "HubsCtrl", ($scope, Hubs, Search, $document, $rootScope, HashNavigation, FilterSelectorsService, MapModal) -> $scope.Hubs = Hubs $scope.hubs = Hubs.visible $scope.totalActive = FilterSelectorsService.totalActive @@ -6,6 +6,8 @@ Darkswarm.controller "HubsCtrl", ($scope, Hubs, Search, $document, $rootScope, H $scope.filterText = FilterSelectorsService.filterText $scope.FilterSelectorsService = FilterSelectorsService $scope.query = Search.search() + $scope.show_profiles = false + $scope.openModal = MapModal.open $scope.$watch "query", (query)-> Search.search query diff --git a/app/assets/javascripts/darkswarm/controllers/producers_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/producers_controller.js.coffee index d88af1e53d..b16dcdfa77 100644 --- a/app/assets/javascripts/darkswarm/controllers/producers_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/producers_controller.js.coffee @@ -1,4 +1,4 @@ -Darkswarm.controller "ProducersCtrl", ($scope, Producers, $filter, FilterSelectorsService, Search) -> +Darkswarm.controller "ProducersCtrl", ($scope, Producers, $filter, FilterSelectorsService, Search, MapModal) -> $scope.Producers = Producers $scope.totalActive = FilterSelectorsService.totalActive $scope.clearAll = FilterSelectorsService.clearAll @@ -7,6 +7,8 @@ Darkswarm.controller "ProducersCtrl", ($scope, Producers, $filter, FilterSelecto $scope.filtersActive = false $scope.activeTaxons = [] $scope.query = Search.search() + $scope.show_profiles = false + $scope.openModal = MapModal.open $scope.$watch "query", (query)-> Search.search query diff --git a/app/assets/javascripts/darkswarm/filters/show_profiles.js.coffee b/app/assets/javascripts/darkswarm/filters/show_profiles.js.coffee new file mode 100644 index 0000000000..32e4438e82 --- /dev/null +++ b/app/assets/javascripts/darkswarm/filters/show_profiles.js.coffee @@ -0,0 +1,7 @@ +Darkswarm.filter 'showProfiles', ()-> + (enterprises, show_profiles) -> + enterprises ||= [] + show_profiles ?= true + + enterprises.filter (enterprise)=> + show_profiles or not enterprise.is_profile diff --git a/app/assets/javascripts/darkswarm/services/hubs.js.coffee b/app/assets/javascripts/darkswarm/services/hubs.js.coffee index de9900866f..ac7dc3a0eb 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_shopfront + hub.is_distributor @visible = visibleFilter @hubs order: (hubs)-> diff --git a/app/assets/javascripts/templates/partials/enterprise_header.html.haml b/app/assets/javascripts/templates/partials/enterprise_header.html.haml index a3089a45af..17bddddeb6 100644 --- a/app/assets/javascripts/templates/partials/enterprise_header.html.haml +++ b/app/assets/javascripts/templates/partials/enterprise_header.html.haml @@ -1,9 +1,12 @@ -.highlight{"ng-class" => "{'has_shopfront' : enterprise.has_shopfront}"} +.highlight .highlight-top %p.right {{ [enterprise.address.city, enterprise.address.state_name] | printArray}} - %h3 + %h3{"ng-if" => "enterprise.has_shopfront"} %a{"bo-href" => "enterprise.path", "ofn-empties-cart" => "enterprise", bindonce: true} %i{"ng-class" => "enterprise.icon_font"} - %span {{ enterprise.name }} + %span {{ enterprise.name }} + %h3{"ng-if" => "!enterprise.has_shopfront"} + %i{"ng-class" => "enterprise.icon_font"} + %span {{ enterprise.name }} %img.hero-img{"ng-src" => "{{enterprise.promo_image}}"} diff --git a/app/views/home/_filters.html.haml b/app/views/home/_filters.html.haml index 78d755f1bc..3060681a33 100644 --- a/app/views/home/_filters.html.haml +++ b/app/views/home/_filters.html.haml @@ -16,8 +16,5 @@ Delivery %ul.small-block-grid-2.medium-block-grid-4.large-block-grid-2 %shipping-type-selector{results: "shippingTypes"} - .row.filter-box.animate-show{"ng-show" => "filtersActive && totalActive() > 0"} - .small-12.columns - %a.button.secondary.small.expand{"ng-click" => "clearAll()"} - %i.ofn-i_009-close - Clear all filters + += render partial: 'shared/components/filter_box' diff --git a/app/views/home/_hubs.html.haml b/app/views/home/_hubs.html.haml index ff90a45d48..f28d0737b7 100644 --- a/app/views/home/_hubs.html.haml +++ b/app/views/home/_hubs.html.haml @@ -13,7 +13,7 @@ .small-12.columns / %i.ofn-i_020-search %input{type: :text, - "ng-model" => "query", + "ng-model" => "query", placeholder: "Search by name or suburb...", "ng-debounce" => "150", "ofn-disable-enter" => true} @@ -23,7 +23,7 @@ .row{bindonce: true} .small-12.columns .active_table - %hub.active_table_node.row.animate-repeat{"ng-repeat" => "hub in filteredHubs = (hubs | hubs:query | taxons:activeTaxons | shipping:shippingTypes)", + %hub.active_table_node.row.animate-repeat{"ng-repeat" => "hub in filteredHubs = (hubs | hubs:query | taxons:activeTaxons | shipping:shippingTypes | showProfiles:show_profiles )", "ng-class" => "{'closed' : !open(), 'open' : open(), 'inactive' : !hub.active, 'current' : current()}", "scroll-after-load" => true, "ng-controller" => "HubNodeCtrl", diff --git a/app/views/home/_skinny.html.haml b/app/views/home/_skinny.html.haml index 5c1802b4d9..d160b256f3 100644 --- a/app/views/home/_skinny.html.haml +++ b/app/views/home/_skinny.html.haml @@ -1,8 +1,10 @@ -.row.active_table_row{"ng-click" => "toggle()", "ng-class" => "{'closed' : !open(), 'has_shopfront' : producer.has_shopfront}", bindonce: true} +.row.active_table_row{"ng-if" => "!hub.is_profile", "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"} + %a.hub{"ng-class" => "{primary: hub.active, secondary: !hub.active}", "ofn-empties-cart" => "hub"} %i{ng: {class: "hub.icon_font"}} %span.margin-top.hub-name-listing {{ hub.name | truncate:40}} + .columns.small-4.medium-2.large-2 %span.margin-top {{ hub.address.city }} .columns.small-2.medium-1.large-1 @@ -22,5 +24,16 @@ %em Shopping here %span.margin-top{ bo: { if: "!current()" } } Orders closed +.row.active_table_row{"ng-if" => "hub.is_profile", "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"}} + %span.margin-top.hub-name-listing {{ hub.name | truncate:40}} + .columns.small-4.medium-2.large-2 + %span.margin-top {{ hub.address.city }} + .columns.small-2.medium-1.large-1 + %span.margin-top {{ hub.address.state_name | uppercase }} + .columns.small-6.medium-3.large-4.text-right + %span.margin-top{ bo: { if: "!current()" } } Profile only diff --git a/app/views/producers/_filters.html.haml b/app/views/producers/_filters.html.haml index 63ccef2f0c..37bf55f7c7 100644 --- a/app/views/producers/_filters.html.haml +++ b/app/views/producers/_filters.html.haml @@ -8,11 +8,6 @@ .light Filter by Type %ul.small-block-grid-2.medium-block-grid-4.large-block-grid-6 - %taxon-selector{objects: "Producers.visible | filterProducers:query", + %taxon-selector{objects: "Producers.visible | filterProducers:query ", results: "activeTaxons"} - .row.filter-box.animate-show{"ng-show" => "filtersActive && totalActive() > 0"} - .small-12.columns - %a.button.secondary.small.expand{"ng-click" => "clearAll()"} - %i.ofn-i_009-close - Clear all filters diff --git a/app/views/producers/index.html.haml b/app/views/producers/index.html.haml index 76dc60a7e6..cba8011caf 100644 --- a/app/views/producers/index.html.haml +++ b/app/views/producers/index.html.haml @@ -24,7 +24,7 @@ .active_table %producer.active_table_node.row.animate-repeat{id: "{{producer.path}}", "scroll-after-load" => true, - "ng-repeat" => "producer in producers = (Producers.visible | filterProducers:query | taxons:activeTaxons)", + "ng-repeat" => "producer in producers = (Producers.visible | showProfiles:show_profiles | filterProducers:query | taxons:activeTaxons)", "ng-controller" => "ProducerNodeCtrl", "ng-class" => "{'closed' : !open(), 'open' : open(), 'inactive' : !producer.active}", id: "{{producer.hash}}"} diff --git a/app/views/shared/components/_filter_box.html.haml b/app/views/shared/components/_filter_box.html.haml new file mode 100644 index 0000000000..0256a57ff1 --- /dev/null +++ b/app/views/shared/components/_filter_box.html.haml @@ -0,0 +1,5 @@ +.row.filter-box.animate-show{"ng-show" => "filtersActive && totalActive() > 0"} + .small-12.columns + %a.button.secondary.small.expand{"ng-click" => "clearAll()"} + %i.ofn-i_009-close + Clear all filters diff --git a/app/views/shared/components/_filter_controls.html.haml b/app/views/shared/components/_filter_controls.html.haml index 7c8917d2b8..afeb37c856 100644 --- a/app/views/shared/components/_filter_controls.html.haml +++ b/app/views/shared/components/_filter_controls.html.haml @@ -10,7 +10,7 @@ No filters .small-12.medium-6.columns.text-right .profile-checkbox - %input{type: "checkbox", name: "profile"}>< + %input{"ng-model" => "show_profiles", type: "checkbox", name: "profile"}>< %label Show profiles %button.button.secondary.tiny.help-btn.ng-scope{:popover => "Profiles do not have a shopfront on the Open Food Network, but do have their own physical or online shop elsewhere", "popover-placement" => "left"}>< %i.ofn-i_013-help diff --git a/app/views/shop/products/_filters.html.haml b/app/views/shop/products/_filters.html.haml index c57f927e61..37f6ae5eda 100644 --- a/app/views/shop/products/_filters.html.haml +++ b/app/views/shop/products/_filters.html.haml @@ -8,11 +8,7 @@ .light Filter by Type %ul.small-block-grid-2.medium-block-grid-3.large-block-grid-4 - %taxon-selector{objects: "Products.products | products:query", + %taxon-selector{objects: "Products.products | products:query | products:showProfiles", results: "activeTaxons"} - .row.filter-box.animate-show{"ng-show" => "filtersActive && totalActive() > 0"} - .small-12.columns - %a.button.secondary.small.expand{"ng-click" => "clearAll()"} - %i.ofn-i_009-close - Clear all filters += render partial: 'shared/components/filter_box' From 559d3b0e4b38e6104c848c4a85cbb97c3e43f7d3 Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Fri, 19 Sep 2014 17:24:41 +1000 Subject: [PATCH 27/55] fixup the header but needs some styling --- .../partials/enterprise_header.html.haml | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/app/assets/javascripts/templates/partials/enterprise_header.html.haml b/app/assets/javascripts/templates/partials/enterprise_header.html.haml index 7ef918cadc..8061740a24 100644 --- a/app/assets/javascripts/templates/partials/enterprise_header.html.haml +++ b/app/assets/javascripts/templates/partials/enterprise_header.html.haml @@ -1,13 +1,12 @@ -.highlight +.highlight{"ng-class" => "{'has_shopfront' : enterprise.has_shopfront}"} .highlight-top.row .small-12.medium-7.large-8.columns - %h3{"ng-if" => "enterprise.has_shopfront"} - %a{"bo-href" => "enterprise.path", "ofn-empties-cart" => "enterprise", bindonce: true} - %i{"ng-class" => "enterprise.icon_font"} - %span {{ enterprise.name }} - %h3{"ng-if" => "!enterprise.has_shopfront"} + %h3{"ng-if" => "enterprise.has_shopfront"} + %a{"bo-href" => "enterprise.path", "ofn-empties-cart" => "enterprise", bindonce: true} %i{"ng-class" => "enterprise.icon_font"} %span {{ enterprise.name }} + %h3{"ng-if" => "!enterprise.has_shopfront"} + %i{"ng-class" => "enterprise.icon_font"} + %span {{ enterprise.name }} .small-12.medium-5.large-4.columns.text-right.small-only-text-left - %p.right - {{ [enterprise.address.city, enterprise.address.state_name] | printArray}} + %p {{ [enterprise.address.city, enterprise.address.state_name] | printArray}} From 5e4e939087b25988b45246c59c98ae3044c86f49 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 19 Sep 2014 17:47:49 +1000 Subject: [PATCH 28/55] Return template markup which was accidentally removed in Rafs merge --- .../templates/partials/enterprise_header.html.haml | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/templates/partials/enterprise_header.html.haml b/app/assets/javascripts/templates/partials/enterprise_header.html.haml index 8061740a24..8edca0280b 100644 --- a/app/assets/javascripts/templates/partials/enterprise_header.html.haml +++ b/app/assets/javascripts/templates/partials/enterprise_header.html.haml @@ -1,12 +1,13 @@ .highlight{"ng-class" => "{'has_shopfront' : enterprise.has_shopfront}"} .highlight-top.row .small-12.medium-7.large-8.columns - %h3{"ng-if" => "enterprise.has_shopfront"} - %a{"bo-href" => "enterprise.path", "ofn-empties-cart" => "enterprise", bindonce: true} + %h3{"ng-if" => "enterprise.has_shopfront"} + %a{"bo-href" => "enterprise.path", "ofn-empties-cart" => "enterprise", bindonce: true} + %i{"ng-class" => "enterprise.icon_font"} + %span {{ enterprise.name }} + %h3{"ng-if" => "!enterprise.has_shopfront"} %i{"ng-class" => "enterprise.icon_font"} %span {{ enterprise.name }} - %h3{"ng-if" => "!enterprise.has_shopfront"} - %i{"ng-class" => "enterprise.icon_font"} - %span {{ enterprise.name }} .small-12.medium-5.large-4.columns.text-right.small-only-text-left %p {{ [enterprise.address.city, enterprise.address.state_name] | printArray}} + %img.hero-img{"ng-src" => "{{enterprise.promo_image}}"} \ No newline at end of file From d86c3cff26b296804ae71b549fdea6de37e7ade4 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 19 Sep 2014 17:48:24 +1000 Subject: [PATCH 29/55] Making enterprise header styles show as turquoise when no shopfront to click through to --- app/assets/stylesheets/darkswarm/modal-enterprises.css.sass | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/assets/stylesheets/darkswarm/modal-enterprises.css.sass b/app/assets/stylesheets/darkswarm/modal-enterprises.css.sass index d89eab21e1..f469066836 100644 --- a/app/assets/stylesheets/darkswarm/modal-enterprises.css.sass +++ b/app/assets/stylesheets/darkswarm/modal-enterprises.css.sass @@ -37,6 +37,10 @@ padding-top: 0.5rem padding-bottom: 0.35rem + h3 + // Because this is only producers + color: $clr-turquoise + h3, p margin-top: 0 margin-bottom: 0 From f8d5b7ede87f3ad1afd69dedf8268793e1e72721 Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Wed, 24 Sep 2014 23:30:43 +1000 Subject: [PATCH 30/55] refactor enterprise types to six options --- app/models/enterprise.rb | 36 ++++++++++-------------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index 33218e5aa0..fc6e356d78 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -229,38 +229,22 @@ class Enterprise < ActiveRecord::Base # 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 << "sell_" + sells + "_" - category << (supplies ? "can_supply" : "cant_supply") + category << "sell_" + sells # Map backend cases to front end cases. case category - when "producer_sell_all_can_supply" + when "producer_sell_all" "producer_hub" # Producer hub who sells own and others produce and supplies other hubs. - when "producer_sell_all_cant_supply" - "producer_hub" # Producer hub who sells own and others products but does not supply other hubs. - when "producer_sell_own_can_supply" + when "producer_sell_own" "producer_shop" # Producer with shopfront and supplies other hubs. - when "producer_sell_own_cant_supply" - "producer_shop" # Producer with shopfront. - when "producer_sell_none_can_supply" - "producer" # Producer selling only through others. - when "producer_sell_none_cant_supply" - "producer_profile" # Producer profile. - - when "non_producer_sell_all_can_supply" - "hub" # Hub selling in products without origin. - when "non_producer_sell_all_cant_supply" - "hub" # Regular hub. - when "non_producer_sell_own_can_supply" - "hub" # Wholesaler selling through own shopfront and others? - when "non_producer_sell_own_cant_supply" + when "producer_sell_none" + "producer" # Producer only supplies through others. + when "non_producer_sell_all" + "hub" # Hub selling others products in order cycles. + when "non_producer_sell_own" "hub" # Wholesaler selling through own shopfront? - when "non_producer_sell_none_can_supply" - "hub_profile" # Wholesaler selling to others. - when "non_producer_sell_none_cant_supply" - "hub_profile" # Hub with just a profile. - else - "producer" + when "non_producer_sell_none" + "hub_profile" # Hub selling outside the system. end end From 9520eeeb15be2dd187bf9ad21e7c48682ddb952a Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 25 Sep 2014 11:56:18 +1000 Subject: [PATCH 31/55] can specify attributes for create_enterpise_user --- spec/features/admin/enterprise_relationships_spec.rb | 2 +- spec/features/admin/reports_spec.rb | 9 ++++----- spec/support/request/authentication_workflow.rb | 7 ++----- 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/spec/features/admin/enterprise_relationships_spec.rb b/spec/features/admin/enterprise_relationships_spec.rb index bfc624bce5..5e4366b6f7 100644 --- a/spec/features/admin/enterprise_relationships_spec.rb +++ b/spec/features/admin/enterprise_relationships_spec.rb @@ -89,7 +89,7 @@ feature %q{ let!(:d1) { create(:distributor_enterprise) } let!(:d2) { create(:distributor_enterprise) } let!(:d3) { create(:distributor_enterprise) } - let(:enterprise_user) { create_enterprise_user([d1]) } + let(:enterprise_user) { create_enterprise_user( enterprises: [d1] ) } let!(:er1) { create(:enterprise_relationship, parent: d1, child: d2) } let!(:er2) { create(:enterprise_relationship, parent: d2, child: d1) } diff --git a/spec/features/admin/reports_spec.rb b/spec/features/admin/reports_spec.rb index e880f25d23..5228b4c8a0 100644 --- a/spec/features/admin/reports_spec.rb +++ b/spec/features/admin/reports_spec.rb @@ -10,8 +10,8 @@ feature %q{ context "Permissions for different reports" do context "As an enterprise user" do let(:user) do - create_enterprise_user([ - create(:distributor_enterprise) + create_enterprise_user(enterprises: [ + create(:distributor_enterprise) ]) end it "should not show the Sales Total report" do @@ -99,7 +99,7 @@ feature %q{ let(:shipping_instructions) { "pick up on thursday please!" } let(:order1) { create(:order, :distributor => distributor, :bill_address => bill_address, :special_instructions => shipping_instructions) } let(:order2) { create(:order, :distributor => distributor, :bill_address => bill_address, :special_instructions => shipping_instructions) } - + before do Timecop.travel(Time.zone.local(2013, 4, 25, 14, 0, 0)) { order1.finalize! } Timecop.travel(Time.zone.local(2013, 4, 25, 16, 0, 0)) { order2.finalize! } @@ -144,7 +144,7 @@ feature %q{ variant_2.update_column(:count_on_hand, 20) product_2.master.update_column(:count_on_hand, 9) variant_1.option_values = [create(:option_value, :presentation => "Test")] - + login_to_admin_section click_link 'Reports' @@ -165,4 +165,3 @@ feature %q{ end end end - diff --git a/spec/support/request/authentication_workflow.rb b/spec/support/request/authentication_workflow.rb index a2ee597f27..39f78223d7 100644 --- a/spec/support/request/authentication_workflow.rb +++ b/spec/support/request/authentication_workflow.rb @@ -37,12 +37,9 @@ module AuthenticationWorkflow visit spree.admin_path end - def create_enterprise_user(enterprises = []) - new_user = create(:user, password: 'blahblah', :password_confirmation => 'blahblah') + def create_enterprise_user( attrs = {} ) + new_user = create(:user, attrs) new_user.spree_roles = [] # for some reason unbeknown to me, this new user gets admin permissions by default. - for enterprise in enterprises do - new_user.enterprise_roles.build(enterprise: enterprise).save - end new_user.save new_user end From 6fa7d9cbcb4438417f93fe120a96963c4c043841 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 25 Sep 2014 12:10:45 +1000 Subject: [PATCH 32/55] Registration controller checks number of owned enterpises --- app/controllers/registration_controller.rb | 2 ++ .../registration_controller_spec.rb | 25 ++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/app/controllers/registration_controller.rb b/app/controllers/registration_controller.rb index 47a1537b57..4fae68bb79 100644 --- a/app/controllers/registration_controller.rb +++ b/app/controllers/registration_controller.rb @@ -20,6 +20,8 @@ class RegistrationController < BaseController def check_user if spree_current_user.nil? redirect_to registration_auth_path(anchor: "signup?after_login=#{request.env['PATH_INFO']}") + elsif !spree_current_user.can_own_more_enterprises? + render :limit_reached end end end diff --git a/spec/controllers/registration_controller_spec.rb b/spec/controllers/registration_controller_spec.rb index 13babdf89e..e51a28f73a 100644 --- a/spec/controllers/registration_controller_spec.rb +++ b/spec/controllers/registration_controller_spec.rb @@ -1,6 +1,7 @@ require 'spec_helper' describe RegistrationController do + include AuthenticationWorkflow describe "redirecting when user not logged in" do it "index" do get :index @@ -13,26 +14,38 @@ describe RegistrationController do end end - describe "loading data when user is logged in" do - let!(:user) { double(:user) } + describe "redirecting when user has reached enterprise ownership limit" do + let!(:user) { create_enterprise_user( enterprise_limit: 1 ) } + let!(:enterprise) { create(:distributor_enterprise, owner: user) } + + before do + controller.stub spree_current_user: user + end + + it "index" do + get :index + response.should render_template :limit_reached + end + end + + describe "loading data when user is logged in" do + let!(:user) { create_enterprise_user } before do controller.stub spree_current_user: user - user.stub spree_api_key: '12345' - user.stub last_incomplete_spree_order: nil end describe "index" do it "loads the spree api key" do get :index - expect(assigns(:spree_api_key)).to eq '12345' + expect(assigns(:spree_api_key)).to eq user.spree_api_key end end describe "store" do it "loads the spree api key" do get :store - expect(assigns(:spree_api_key)).to eq '12345' + expect(assigns(:spree_api_key)).to eq user.spree_api_key end end end From f5849e91dcd52ad4f4d9e9ccd117167b70de1ebd Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 25 Sep 2014 12:25:32 +1000 Subject: [PATCH 33/55] Adding limit reached modal to registration --- .../directives/registration_limit_modal.js.coffee | 13 +++++++++++++ .../registration/limit_reached.html.haml | 15 +++++++++++++++ app/views/registration/limit_reached.html.haml | 2 ++ 3 files changed, 30 insertions(+) create mode 100644 app/assets/javascripts/darkswarm/directives/registration_limit_modal.js.coffee create mode 100644 app/assets/javascripts/templates/registration/limit_reached.html.haml create mode 100644 app/views/registration/limit_reached.html.haml diff --git a/app/assets/javascripts/darkswarm/directives/registration_limit_modal.js.coffee b/app/assets/javascripts/darkswarm/directives/registration_limit_modal.js.coffee new file mode 100644 index 0000000000..1fecfbf804 --- /dev/null +++ b/app/assets/javascripts/darkswarm/directives/registration_limit_modal.js.coffee @@ -0,0 +1,13 @@ +Darkswarm.directive "ofnRegistrationLimitModal", (Navigation, $modal, Loading) -> + restrict: 'A' + link: (scope, elem, attr)-> + scope.modalInstance = $modal.open + templateUrl: 'registration/limit_reached.html' + windowClass: "login-modal large" + backdrop: 'static' + + scope.modalInstance.result.then scope.close, scope.close + + scope.close = -> + Loading.message = "Taking you back to the home page" + Navigation.go "/" diff --git a/app/assets/javascripts/templates/registration/limit_reached.html.haml b/app/assets/javascripts/templates/registration/limit_reached.html.haml new file mode 100644 index 0000000000..e2131c1727 --- /dev/null +++ b/app/assets/javascripts/templates/registration/limit_reached.html.haml @@ -0,0 +1,15 @@ +%div + .header.center + %h2 Oh no! + %h4 You have reached the limit! + .row + .small-12.medium-3.large-2.columns.text-right.hide-for-small-only + %img{:src => "/assets/potatoes.png"} + .small-12.medium-9.large-10.columns + %p + You have reached the limit for the number of enterprises you are allowed to own on the + %strong Open Food Network. + .row + .small-12.columns + %hr + %input.button.primary{ type: "button", value: "Return to the homepage", ng: { click: "close()" } } diff --git a/app/views/registration/limit_reached.html.haml b/app/views/registration/limit_reached.html.haml new file mode 100644 index 0000000000..bfaec6da3d --- /dev/null +++ b/app/views/registration/limit_reached.html.haml @@ -0,0 +1,2 @@ +/ Directive which loads the modal +%div{ "ofn-registration-limit-modal" => true } From f8b083e4b7db9f9a25be3cf0e5e8b43c9bbf73dd Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Thu, 25 Sep 2014 14:04:10 +1000 Subject: [PATCH 34/55] fix lost hub link --- app/views/home/_skinny.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/home/_skinny.html.haml b/app/views/home/_skinny.html.haml index d160b256f3..d41d3094fb 100644 --- a/app/views/home/_skinny.html.haml +++ b/app/views/home/_skinny.html.haml @@ -1,7 +1,7 @@ .row.active_table_row{"ng-if" => "!hub.is_profile", "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{"ng-class" => "{primary: hub.active, secondary: !hub.active}", "ofn-empties-cart" => "hub"} + %a.hub{"bo-href" => "hub.path", "ng-class" => "{primary: hub.active, secondary: !hub.active}", "ofn-empties-cart" => "hub"} %i{ng: {class: "hub.icon_font"}} %span.margin-top.hub-name-listing {{ hub.name | truncate:40}} From a068411b7d7e469ad644889143f514bdab6805b2 Mon Sep 17 00:00:00 2001 From: summerscope Date: Thu, 25 Sep 2014 16:00:03 +1000 Subject: [PATCH 35/55] Add in class to show when hub is --- app/views/home/_hubs.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/home/_hubs.html.haml b/app/views/home/_hubs.html.haml index 24e4b037ba..827bb0035f 100644 --- a/app/views/home/_hubs.html.haml +++ b/app/views/home/_hubs.html.haml @@ -18,7 +18,7 @@ .small-12.columns .active_table %hub.active_table_node.row.animate-repeat{"ng-repeat" => "hub in filteredHubs = (hubs | hubs:query | taxons:activeTaxons | shipping:shippingTypes | showProfiles:show_profiles )", - "ng-class" => "{'closed' : !open(), 'open' : open(), 'inactive' : !hub.active, 'current' : current()}", + "ng-class" => "{'is_profile' : hub.is_profile, 'closed' : !open(), 'open' : open(), 'inactive' : !hub.active, 'current' : current()}", "scroll-after-load" => true, "ng-controller" => "HubNodeCtrl", id: "{{hub.hash}}"} @@ -32,3 +32,4 @@ Sorry, no results found for %strong {{query}}. Try another search? + From 2e1b2ffe12bbfa66f7a5c5f93a895393413484fb Mon Sep 17 00:00:00 2001 From: summerscope Date: Thu, 25 Sep 2014 16:04:27 +1000 Subject: [PATCH 36/55] Add italics --- app/views/home/_skinny.html.haml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/views/home/_skinny.html.haml b/app/views/home/_skinny.html.haml index d41d3094fb..440f00c9b0 100644 --- a/app/views/home/_skinny.html.haml +++ b/app/views/home/_skinny.html.haml @@ -36,4 +36,5 @@ %span.margin-top {{ hub.address.state_name | uppercase }} .columns.small-6.medium-3.large-4.text-right - %span.margin-top{ bo: { if: "!current()" } } Profile only + %span.margin-top{ bo: { if: "!current()" } } + %em Profile only From 3812d1eebb0147cca8c207d855526dcea499025b Mon Sep 17 00:00:00 2001 From: summerscope Date: Thu, 25 Sep 2014 16:39:48 +1000 Subject: [PATCH 37/55] Add more greys --- app/assets/stylesheets/darkswarm/branding.css.sass | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/darkswarm/branding.css.sass b/app/assets/stylesheets/darkswarm/branding.css.sass index 011ef2ff68..0fa559240f 100644 --- a/app/assets/stylesheets/darkswarm/branding.css.sass +++ b/app/assets/stylesheets/darkswarm/branding.css.sass @@ -17,7 +17,9 @@ $clr-blue-bright: #14b6cc $disabled-light: #e5e5e5 $disabled-bright: #ccc +$disabled-med: #b3b3b3 $disabled-dark: #999 +$disabled-v-dark: #808080 $med-grey: #666 $dark-grey: #333 - +$black: #000 From 97ae170dd1018ce4886a2c922fa2339e03dbaf71 Mon Sep 17 00:00:00 2001 From: summerscope Date: Thu, 25 Sep 2014 16:40:06 +1000 Subject: [PATCH 38/55] Add in profile only use case to styling --- app/assets/stylesheets/darkswarm/hub_node.css.sass | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/app/assets/stylesheets/darkswarm/hub_node.css.sass b/app/assets/stylesheets/darkswarm/hub_node.css.sass index eb539cc0b5..d84d0056ae 100644 --- a/app/assets/stylesheets/darkswarm/hub_node.css.sass +++ b/app/assets/stylesheets/darkswarm/hub_node.css.sass @@ -87,6 +87,8 @@ &.inactive &.closed, &.open &, & * + color: $disabled-med + a, a * color: $disabled-dark &.closed .active_table_row, .active_table_row:first-child, .active_table_row:last-child @@ -126,3 +128,11 @@ .active_table_row:first-child .skinny-head background-color: $disabled-light + //Is Profile - profile node + &.inactive.is_profile + &.closed, &.open + .active_table_row + &:hover, &:active, &:focus + border-color: transparent + cursor: auto + From 3b7cd6d329e90911a0aec79fb6b5e139ab89562b Mon Sep 17 00:00:00 2001 From: summerscope Date: Thu, 25 Sep 2014 16:54:17 +1000 Subject: [PATCH 39/55] Making the styling work for profiles and producers --- app/assets/stylesheets/darkswarm/modal-enterprises.css.sass | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/app/assets/stylesheets/darkswarm/modal-enterprises.css.sass b/app/assets/stylesheets/darkswarm/modal-enterprises.css.sass index f469066836..2ceaa96373 100644 --- a/app/assets/stylesheets/darkswarm/modal-enterprises.css.sass +++ b/app/assets/stylesheets/darkswarm/modal-enterprises.css.sass @@ -35,11 +35,7 @@ outline: 0 @media only screen and (max-width: 640px) padding-top: 0.5rem - padding-bottom: 0.35rem - - h3 - // Because this is only producers - color: $clr-turquoise + padding-bottom: 0.35rem h3, p margin-top: 0 From cbc8a62686f75b776746cfde6173cb97fa51af78 Mon Sep 17 00:00:00 2001 From: summerscope Date: Thu, 25 Sep 2014 17:02:41 +1000 Subject: [PATCH 40/55] STyling for profile only small view --- app/assets/stylesheets/darkswarm/hub_node.css.sass | 2 ++ 1 file changed, 2 insertions(+) diff --git a/app/assets/stylesheets/darkswarm/hub_node.css.sass b/app/assets/stylesheets/darkswarm/hub_node.css.sass index d84d0056ae..d02f9b5299 100644 --- a/app/assets/stylesheets/darkswarm/hub_node.css.sass +++ b/app/assets/stylesheets/darkswarm/hub_node.css.sass @@ -135,4 +135,6 @@ &:hover, &:active, &:focus border-color: transparent cursor: auto + @media all and (max-width: 640px) + border-color: transparent From 1e31dd88ee082bfe21f495ad2fbbdcdbb6dbcb78 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 25 Sep 2014 17:02:18 +1000 Subject: [PATCH 41/55] Remove unrequired functions, add has_hub_listing --- .../darkswarm/filters/show_profiles.js.coffee | 2 +- .../javascripts/darkswarm/services/hubs.js.coffee | 2 +- app/models/enterprise.rb | 13 ++++--------- app/serializers/api/enterprise_serializer.rb | 13 +++++++------ app/views/home/_skinny.html.haml | 8 ++++---- 5 files changed, 17 insertions(+), 21 deletions(-) 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"}} From 33dff551c79d17dcaafd81f8c3957064c37b9150 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 25 Sep 2014 17:19:14 +1000 Subject: [PATCH 42/55] Removing 'show profiles' from producer and shop pages --- app/views/home/_filters.html.haml | 14 ++++++----- app/views/producers/_filters.html.haml | 10 ++++---- app/views/producers/index.html.haml | 12 +++++----- .../components/_filter_controls.html.haml | 23 +++++++------------ .../components/_show_profiles.html.haml | 6 +++++ app/views/shop/products/_filters.html.haml | 9 +++++--- 6 files changed, 40 insertions(+), 34 deletions(-) create mode 100644 app/views/shared/components/_show_profiles.html.haml diff --git a/app/views/home/_filters.html.haml b/app/views/home/_filters.html.haml index 3060681a33..ff13a0c33c 100644 --- a/app/views/home/_filters.html.haml +++ b/app/views/home/_filters.html.haml @@ -1,20 +1,22 @@ -= render partial: 'shared/components/filter_controls' +.row + = render partial: 'shared/components/filter_controls' + = render partial: 'shared/components/show_profiles' .row.animate-show{"ng-show" => "filtersActive"} - .small-12.columns + .small-12.columns .row.filter-box .small-12.large-9.columns - %h5.tdhead + %h5.tdhead .light Filter by Type %ul.small-block-grid-2.medium-block-grid-4.large-block-grid-5 - %taxon-selector{objects: "hubs | hubs:query", + %taxon-selector{objects: "hubs | hubs:query", results: "activeTaxons"} .small-12.large-3.columns - %h5.tdhead + %h5.tdhead .light Filter by Delivery %ul.small-block-grid-2.medium-block-grid-4.large-block-grid-2 - %shipping-type-selector{results: "shippingTypes"} + %shipping-type-selector{results: "shippingTypes"} = render partial: 'shared/components/filter_box' diff --git a/app/views/producers/_filters.html.haml b/app/views/producers/_filters.html.haml index 37bf55f7c7..92f0870e7e 100644 --- a/app/views/producers/_filters.html.haml +++ b/app/views/producers/_filters.html.haml @@ -1,13 +1,15 @@ -= render partial: 'shared/components/filter_controls' +.row + = render partial: 'shared/components/filter_controls' + .small-12.medium-6.columns.text-right +   .row.animate-show{"ng-show" => "filtersActive"} .small-12.columns .row.filter-box .small-12.columns - %h5.tdhead + %h5.tdhead .light Filter by Type %ul.small-block-grid-2.medium-block-grid-4.large-block-grid-6 - %taxon-selector{objects: "Producers.visible | filterProducers:query ", + %taxon-selector{objects: "Producers.visible | filterProducers:query ", results: "activeTaxons"} - diff --git a/app/views/producers/index.html.haml b/app/views/producers/index.html.haml index cba8011caf..fe487585e6 100644 --- a/app/views/producers/index.html.haml +++ b/app/views/producers/index.html.haml @@ -1,18 +1,18 @@ -= inject_enterprises += inject_enterprises .producers.pad-top{"ng-controller" => "ProducersCtrl"} .row .small-12.columns.pad-top %h1 Find local producers - / %div - / Find a + / %div + / Find a / %ofn-modal{title: "producer"} / = render partial: "modals/producers" / from the list below: #active-table-search.row .small-12.columns - %input.animate-show{type: :text, - "ng-model" => "query", + %input.animate-show{type: :text, + "ng-model" => "query", placeholder: "Search by producer or suburb...", "ng-debounce" => "150", "ofn-disable-enter" => true} @@ -24,7 +24,7 @@ .active_table %producer.active_table_node.row.animate-repeat{id: "{{producer.path}}", "scroll-after-load" => true, - "ng-repeat" => "producer in producers = (Producers.visible | showProfiles:show_profiles | filterProducers:query | taxons:activeTaxons)", + "ng-repeat" => "producer in producers = (Producers.visible | filterProducers:query | taxons:activeTaxons)", "ng-controller" => "ProducerNodeCtrl", "ng-class" => "{'closed' : !open(), 'open' : open(), 'inactive' : !producer.active}", id: "{{producer.hash}}"} diff --git a/app/views/shared/components/_filter_controls.html.haml b/app/views/shared/components/_filter_controls.html.haml index afeb37c856..e15d2de48d 100644 --- a/app/views/shared/components/_filter_controls.html.haml +++ b/app/views/shared/components/_filter_controls.html.haml @@ -1,16 +1,9 @@ -.row - .small-12.medium-6.columns - %a.button.success.tiny.filterbtn{"ng-click" => "filtersActive = !filtersActive", - "ng-show" => "FilterSelectorsService.selectors.length > 0"} - {{ filterText(filtersActive) }} - %i.ofn-i_005-caret-down{"ng-show" => "!filtersActive"} - %i.ofn-i_006-caret-up{"ng-show" => "filtersActive"} +.small-12.medium-6.columns + %a.button.success.tiny.filterbtn{"ng-click" => "filtersActive = !filtersActive", + "ng-show" => "FilterSelectorsService.selectors.length > 0"} + {{ filterText(filtersActive) }} + %i.ofn-i_005-caret-down{"ng-show" => "!filtersActive"} + %i.ofn-i_006-caret-up{"ng-show" => "filtersActive"} - %a.button.secondary.tiny.filterbtn.disabled{"ng-show" => "FilterSelectorsService.selectors.length == 0"} - No filters - .small-12.medium-6.columns.text-right - .profile-checkbox - %input{"ng-model" => "show_profiles", type: "checkbox", name: "profile"}>< - %label Show profiles - %button.button.secondary.tiny.help-btn.ng-scope{:popover => "Profiles do not have a shopfront on the Open Food Network, but do have their own physical or online shop elsewhere", "popover-placement" => "left"}>< - %i.ofn-i_013-help + %a.button.secondary.tiny.filterbtn.disabled{"ng-show" => "FilterSelectorsService.selectors.length == 0"} + No filters diff --git a/app/views/shared/components/_show_profiles.html.haml b/app/views/shared/components/_show_profiles.html.haml new file mode 100644 index 0000000000..5dc0c7c6dc --- /dev/null +++ b/app/views/shared/components/_show_profiles.html.haml @@ -0,0 +1,6 @@ +.small-12.medium-6.columns.text-right + .profile-checkbox + %input{"ng-model" => "show_profiles", type: "checkbox", name: "profile"}>< + %label Show profiles + %button.button.secondary.tiny.help-btn.ng-scope{:popover => "Profiles do not have a shopfront on the Open Food Network, but do have their own physical or online shop elsewhere", "popover-placement" => "left"}>< + %i.ofn-i_013-help diff --git a/app/views/shop/products/_filters.html.haml b/app/views/shop/products/_filters.html.haml index 37f6ae5eda..c135274fad 100644 --- a/app/views/shop/products/_filters.html.haml +++ b/app/views/shop/products/_filters.html.haml @@ -1,14 +1,17 @@ -= render partial: 'shared/components/filter_controls' +.row + = render partial: 'shared/components/filter_controls' + .small-12.medium-6.columns.text-right +   .row.animate-show{"ng-show" => "filtersActive"} .small-12.columns .row.filter-box .small-12.columns - %h5.tdhead + %h5.tdhead .light Filter by Type %ul.small-block-grid-2.medium-block-grid-3.large-block-grid-4 - %taxon-selector{objects: "Products.products | products:query | products:showProfiles", + %taxon-selector{objects: "Products.products | products:query | products:showProfiles", results: "activeTaxons"} = render partial: 'shared/components/filter_box' From 85b27f5b51dec37ede6ac76d195e3311039c9178 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 25 Sep 2014 17:25:48 +1000 Subject: [PATCH 43/55] Adding angularjs-file-upload to spec manifest --- spec/javascripts/application_spec.js | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/javascripts/application_spec.js b/spec/javascripts/application_spec.js index 8c611081a2..7d9a7350b5 100644 --- a/spec/javascripts/application_spec.js +++ b/spec/javascripts/application_spec.js @@ -5,6 +5,7 @@ //= require angular-mocks //= require angular-cookies //= require angular-backstretch.js +//= require angularjs-file-upload //= require lodash.underscore.js //= require angular-flash.min.js //= require shared/mm-foundation-tpls-0.2.2.min.js From be17d80cc48abe236eedf235e59799c6f02a162b Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Thu, 25 Sep 2014 17:28:01 +1000 Subject: [PATCH 44/55] Fixing hubs service spec --- .../darkswarm/services/hubs_spec.js.coffee | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/spec/javascripts/unit/darkswarm/services/hubs_spec.js.coffee b/spec/javascripts/unit/darkswarm/services/hubs_spec.js.coffee index f8ae8230bc..f2620da65b 100644 --- a/spec/javascripts/unit/darkswarm/services/hubs_spec.js.coffee +++ b/spec/javascripts/unit/darkswarm/services/hubs_spec.js.coffee @@ -1,46 +1,45 @@ describe "Hubs service", -> Hubs = null Enterprises = null - CurrentHubMock = {} + CurrentHubMock = {} hubs = [ { id: 2 active: false orders_close_at: new Date() is_distributor: true - has_shopfront: true + has_hub_listing: true } { id: 3 active: false orders_close_at: new Date() is_distributor: true - has_shopfront: true + has_hub_listing: true } { id: 1 active: true orders_close_at: new Date() is_distributor: true - has_shopfront: true + has_hub_listing: true } ] - + beforeEach -> module 'Darkswarm' - angular.module('Darkswarm').value('enterprises', hubs) + angular.module('Darkswarm').value('enterprises', hubs) module ($provide)-> - $provide.value "CurrentHub", CurrentHubMock + $provide.value "CurrentHub", CurrentHubMock null inject ($injector)-> - Enterprises = $injector.get("Enterprises") + Enterprises = $injector.get("Enterprises") Hubs = $injector.get("Hubs") it "filters Enterprise.hubs into a new array", -> expect(Hubs.hubs[0]).toBe Enterprises.enterprises[2] - # Because the $filter is a new sorted array + # Because the $filter is a new sorted array # We check to see the objects in both arrays are still the same - Enterprises.enterprises[2].active = false + Enterprises.enterprises[2].active = false expect(Hubs.hubs[0].active).toBe false - From a6e8d6906f701b939c7f778a70d3ee847c636f99 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 26 Sep 2014 11:20:09 +1000 Subject: [PATCH 45/55] Tweak message on profile label --- app/views/shared/components/_show_profiles.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/shared/components/_show_profiles.html.haml b/app/views/shared/components/_show_profiles.html.haml index 5dc0c7c6dc..c2232c3555 100644 --- a/app/views/shared/components/_show_profiles.html.haml +++ b/app/views/shared/components/_show_profiles.html.haml @@ -2,5 +2,5 @@ .profile-checkbox %input{"ng-model" => "show_profiles", type: "checkbox", name: "profile"}>< %label Show profiles - %button.button.secondary.tiny.help-btn.ng-scope{:popover => "Profiles do not have a shopfront on the Open Food Network, but do have their own physical or online shop elsewhere", "popover-placement" => "left"}>< + %button.button.secondary.tiny.help-btn.ng-scope{:popover => "Profiles do not have a shopfront on the Open Food Network, but may have their own physical or online shop elsewhere", "popover-placement" => "left"}>< %i.ofn-i_013-help From d3c8e4a5474f41461117f8744c1006cadc838875 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 26 Sep 2014 11:18:54 +1000 Subject: [PATCH 46/55] Replacing reference to is_profile --- app/views/home/_hubs.html.haml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/app/views/home/_hubs.html.haml b/app/views/home/_hubs.html.haml index 827bb0035f..67cb6abb40 100644 --- a/app/views/home/_hubs.html.haml +++ b/app/views/home/_hubs.html.haml @@ -1,4 +1,4 @@ -= inject_enterprises += inject_enterprises #hubs.hubs{"ng-controller" => "HubsCtrl"} .row .small-12.columns @@ -6,7 +6,7 @@ #active-table-search.row.pad-top .small-12.columns - %input{type: :text, + %input{type: :text, "ng-model" => "query", placeholder: "Search by name or suburb...", "ng-debounce" => "150", @@ -18,10 +18,10 @@ .small-12.columns .active_table %hub.active_table_node.row.animate-repeat{"ng-repeat" => "hub in filteredHubs = (hubs | hubs:query | taxons:activeTaxons | shipping:shippingTypes | showProfiles:show_profiles )", - "ng-class" => "{'is_profile' : hub.is_profile, 'closed' : !open(), 'open' : open(), 'inactive' : !hub.active, 'current' : current()}", + "ng-class" => "{'is_profile' : !hub.has_shopfront, 'closed' : !open(), 'open' : open(), 'inactive' : !hub.active, 'current' : current()}", "scroll-after-load" => true, "ng-controller" => "HubNodeCtrl", - id: "{{hub.hash}}"} + id: "{{hub.hash}}"} .small-12.columns = render partial: 'home/skinny' = render partial: 'home/fat' @@ -32,4 +32,3 @@ Sorry, no results found for %strong {{query}}. Try another search? - From 781fcae946c65fc39c0f3fbdae12c32e2456c210 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 26 Sep 2014 12:07:38 +1000 Subject: [PATCH 47/55] Change styling for register modals --- app/assets/stylesheets/darkswarm/modal-login.css.sass | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/app/assets/stylesheets/darkswarm/modal-login.css.sass b/app/assets/stylesheets/darkswarm/modal-login.css.sass index 38fe5dee3a..61108145bb 100644 --- a/app/assets/stylesheets/darkswarm/modal-login.css.sass +++ b/app/assets/stylesheets/darkswarm/modal-login.css.sass @@ -1,6 +1,13 @@ // Styling for login modal to style tabs +.reveal-modal.login-modal + border-bottom-color: #efefef + .login-modal background: #efefef .tabs-content - background: #fff \ No newline at end of file + background: #fff + padding-top: 10px + + + \ No newline at end of file From dee503befbd612e628738d1c60b285888d71be48 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 26 Sep 2014 12:07:58 +1000 Subject: [PATCH 48/55] Tweak language around the long description --- app/assets/javascripts/templates/registration/about.html.haml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/templates/registration/about.html.haml b/app/assets/javascripts/templates/registration/about.html.haml index 57f7c482e6..d014c96d90 100644 --- a/app/assets/javascripts/templates/registration/about.html.haml +++ b/app/assets/javascripts/templates/registration/about.html.haml @@ -28,8 +28,8 @@ .row .small-12.columns %label{ for: 'enterprise_long_desc' } Long Description: - %textarea.chunky.small-12.columns{ id: 'enterprise_long_desc', placeholder: "We recommend keeping your description to under 600 characters or 150 words. Why? Cus people are lazy, and don't like to read too much text online. ;)", ng: { model: 'enterprise.long_description' } } - %small {{ enterprise.long_description.length }} characters used + %textarea.chunky.small-12.columns{ id: 'enterprise_long_desc', rows: 6, placeholder: "This is your opportunity to tell the story of your enterprise - what makes you different and wonderful? We'd suggest keeping your description to under 600 characters or 150 words.", ng: { model: 'enterprise.long_description' } } + %small {{ enterprise.long_description.length }} characters / up to 600 recommended .small-12.large-4.columns .row .small-12.columns From e9c8547ca3ea0164b223a0d72b14b1fbfd2f667e Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Fri, 26 Sep 2014 14:48:37 +1000 Subject: [PATCH 49/55] fix enterprsie model logic --- app/models/enterprise.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index ecd948aa7a..a81655a1de 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -215,7 +215,7 @@ 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 suppliers == [self] || type == "single" + return "own" if type == "single" || suppliers == [self] "all" end From 237d129710e6317b11d5e04fe560ab73d12f4ce9 Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 26 Sep 2014 14:55:10 +1000 Subject: [PATCH 50/55] Changing the markup to give a class where is a producer --- .../javascripts/templates/partials/enterprise_header.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/templates/partials/enterprise_header.html.haml b/app/assets/javascripts/templates/partials/enterprise_header.html.haml index 8edca0280b..8612ba968e 100644 --- a/app/assets/javascripts/templates/partials/enterprise_header.html.haml +++ b/app/assets/javascripts/templates/partials/enterprise_header.html.haml @@ -5,7 +5,7 @@ %a{"bo-href" => "enterprise.path", "ofn-empties-cart" => "enterprise", bindonce: true} %i{"ng-class" => "enterprise.icon_font"} %span {{ enterprise.name }} - %h3{"ng-if" => "!enterprise.has_shopfront"} + %h3{"ng-if" => "!enterprise.has_shopfront", "ng-class" => "{'is_producer' : enterprise.is_primary_producer}"} %i{"ng-class" => "enterprise.icon_font"} %span {{ enterprise.name }} .small-12.medium-5.large-4.columns.text-right.small-only-text-left From 2ea0c89899e3981d747ff1ad42f5d86245f1f4ae Mon Sep 17 00:00:00 2001 From: summerscope Date: Fri, 26 Sep 2014 14:55:35 +1000 Subject: [PATCH 51/55] Style the modal headers --- .../stylesheets/darkswarm/modal-enterprises.css.sass | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/assets/stylesheets/darkswarm/modal-enterprises.css.sass b/app/assets/stylesheets/darkswarm/modal-enterprises.css.sass index 2ceaa96373..305566ad58 100644 --- a/app/assets/stylesheets/darkswarm/modal-enterprises.css.sass +++ b/app/assets/stylesheets/darkswarm/modal-enterprises.css.sass @@ -42,6 +42,10 @@ margin-bottom: 0 padding-bottom: 0 line-height: 1 + + h3 > i + color: $clr-brick + p line-height: 2.4 @media all and (max-width: 640px) @@ -50,6 +54,10 @@ h3 a:hover span border-bottom: 1px solid $clr-brick-bright + .is_producer + &, & * + color: $clr-turquoise + // ABOUT Enterprise From 299b0fe5be6bef1c314b3b736ae0c50fbba34da5 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 26 Sep 2014 14:52:45 +1000 Subject: [PATCH 52/55] Allowing all enterprise users to access products --- app/models/spree/ability_decorator.rb | 3 ++- spec/models/spree/ability_spec.rb | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/spree/ability_decorator.rb b/app/models/spree/ability_decorator.rb index 08fc4407ce..3ce7066867 100644 --- a/app/models/spree/ability_decorator.rb +++ b/app/models/spree/ability_decorator.rb @@ -19,7 +19,8 @@ class AbilityDecorator def can_manage_products?(user) - ( user.enterprises.map(&:type) & %w(single full) ).any? + # ( user.enterprises.map(&:type) & %w(single full) ).any? + can_manage_enterprises? user end diff --git a/spec/models/spree/ability_spec.rb b/spec/models/spree/ability_spec.rb index 78ca1db909..7402c1b527 100644 --- a/spec/models/spree/ability_spec.rb +++ b/spec/models/spree/ability_spec.rb @@ -44,7 +44,7 @@ module Spree it "can't when a user manages a 'profile' type enterprise" do user.enterprise_roles.create! enterprise: enterprise_profile - subject.can_manage_products?(user).should be_false + subject.can_manage_products?(user).should be_true end it "can't when the user manages no enterprises" do From 4b2f1cefa0773800a648f9c5cb672fce5d9815f0 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Fri, 26 Sep 2014 17:11:11 +1000 Subject: [PATCH 53/55] Spliting order management abilities out of product management abilities --- app/models/spree/ability_decorator.rb | 9 ++- spec/features/admin/enterprise_user_spec.rb | 12 ++-- spec/models/spree/ability_spec.rb | 68 +++++++++++---------- 3 files changed, 47 insertions(+), 42 deletions(-) diff --git a/app/models/spree/ability_decorator.rb b/app/models/spree/ability_decorator.rb index 3ce7066867..5fdb4c2342 100644 --- a/app/models/spree/ability_decorator.rb +++ b/app/models/spree/ability_decorator.rb @@ -5,6 +5,7 @@ class AbilityDecorator add_base_abilities user if is_new_user? user add_enterprise_management_abilities user if can_manage_enterprises? user add_product_management_abilities user if can_manage_products? user + add_order_management_abilities user if can_manage_orders? user add_relationship_management_abilities user if can_manage_relationships? user end @@ -17,12 +18,13 @@ class AbilityDecorator user.enterprises.present? end - def can_manage_products?(user) - # ( user.enterprises.map(&:type) & %w(single full) ).any? can_manage_enterprises? user end + def can_manage_orders?(user) + ( user.enterprises.map(&:type) & %w(single full) ).any? + end def can_manage_relationships?(user) can_manage_enterprises? user @@ -47,7 +49,6 @@ class AbilityDecorator end end - def add_product_management_abilities(user) # Enterprise User can only access products that they are a supplier for can [:create], Spree::Product @@ -65,7 +66,9 @@ class AbilityDecorator can [:admin, :index, :read, :search], Spree::Taxon can [:admin, :index, :read, :create, :edit], Spree::Classification + end + def add_order_management_abilities(user) # Enterprise User can only access orders that they are a distributor for can [:index, :create], Spree::Order can [:read, :update, :fire, :resend], Spree::Order do |order| diff --git a/spec/features/admin/enterprise_user_spec.rb b/spec/features/admin/enterprise_user_spec.rb index 77378f6cbd..70e6a9b265 100644 --- a/spec/features/admin/enterprise_user_spec.rb +++ b/spec/features/admin/enterprise_user_spec.rb @@ -64,7 +64,7 @@ feature %q{ page.should have_admin_menu_item 'Dashboard' page.should have_admin_menu_item 'Enterprises' - ['Orders', 'Products', 'Reports', 'Configuration', 'Promotions', 'Users', 'Order Cycles'].each do |menu_item_name| + ['Orders', 'Reports', 'Configuration', 'Promotions', 'Users', 'Order Cycles'].each do |menu_item_name| page.should_not have_admin_menu_item menu_item_name end end @@ -79,15 +79,15 @@ feature %q{ end end - it "does not show me product management controls" do - page.should_not have_selector '#products' + it "shows me product management controls, but not order_cycle controls" do + page.should have_selector '#products' page.should_not have_selector '#order_cycles' end - it "does not show me enterprise product info, payment methods, shipping methods or enterprise fees" do + it "shows me enterprise product info but not payment methods, shipping methods or enterprise fees" do # Producer product info - page.should_not have_selector '.producers_tab span', text: 'Total Products' - page.should_not have_selector '.producers_tab span', text: 'Active Products' + page.should have_selector '.producers_tab span', text: 'Total Products' + page.should have_selector '.producers_tab span', text: 'Active Products' page.should_not have_selector '.producers_tab span', text: 'Products in OCs' # Payment methods, shipping methods, enterprise fees diff --git a/spec/models/spree/ability_spec.rb b/spec/models/spree/ability_spec.rb index 7402c1b527..2d2d1cfb01 100644 --- a/spec/models/spree/ability_spec.rb +++ b/spec/models/spree/ability_spec.rb @@ -13,44 +13,46 @@ module Spree let(:enterprise_single) { create(:enterprise, type: 'single') } let(:enterprise_profile) { create(:enterprise, type: 'profile') } - describe "creating enterprises" do + context "as manager of a 'full' type enterprise" do + before do + user.enterprise_roles.create! enterprise: enterprise_full + end + + it { subject.can_manage_products?(user).should be_true } + it { subject.can_manage_enterprises?(user).should be_true } + it { subject.can_manage_orders?(user).should be_true } + end + + context "as manager of a 'single' type enterprise" do + before do + user.enterprise_roles.create! enterprise: enterprise_single + end + + it { subject.can_manage_products?(user).should be_true } + it { subject.can_manage_enterprises?(user).should be_true } + it { subject.can_manage_orders?(user).should be_true } + end + + context "as manager of a 'profile' type enterprise" do + before do + user.enterprise_roles.create! enterprise: enterprise_profile + end + + it { subject.can_manage_products?(user).should be_true } + it { subject.can_manage_enterprises?(user).should be_true } + it { subject.can_manage_orders?(user).should be_false } + end + + context "as a new user with no enterprises" do + it { subject.can_manage_products?(user).should be_false } + it { subject.can_manage_enterprises?(user).should be_false } + it { subject.can_manage_orders?(user).should be_false } + it "can create enterprises straight off the bat" do subject.is_new_user?(user).should be_true expect(user).to have_ability :create, for: Enterprise end end - - describe "managing enterprises" do - it "can manage enterprises when the user has at least one enterprise assigned" do - user.enterprise_roles.create! enterprise: enterprise_full - subject.can_manage_enterprises?(user).should be_true - end - - it "can't otherwise" do - subject.can_manage_enterprises?(user).should be_false - end - end - - describe "managing products" do - it "can when a user manages a 'full' type enterprise" do - user.enterprise_roles.create! enterprise: enterprise_full - subject.can_manage_products?(user).should be_true - end - - it "can when a user manages a 'single' type enterprise" do - user.enterprise_roles.create! enterprise: enterprise_single - subject.can_manage_products?(user).should be_true - end - - it "can't when a user manages a 'profile' type enterprise" do - user.enterprise_roles.create! enterprise: enterprise_profile - subject.can_manage_products?(user).should be_true - end - - it "can't when the user manages no enterprises" do - subject.can_manage_products?(user).should be_false - end - end end describe 'Roles' do From 92a40fc8420ebf0653294b6acc9ed8d501661f2a Mon Sep 17 00:00:00 2001 From: Rafael Schouten Date: Fri, 26 Sep 2014 17:15:21 +1000 Subject: [PATCH 54/55] order mailer edits --- .../spree/order_mailer/confirm_email.text.haml | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/app/views/spree/order_mailer/confirm_email.text.haml b/app/views/spree/order_mailer/confirm_email.text.haml index 1ebc1a89af..9822653969 100644 --- a/app/views/spree/order_mailer/confirm_email.text.haml +++ b/app/views/spree/order_mailer/confirm_email.text.haml @@ -13,7 +13,7 @@ Subtotal: #{number_to_currency checkout_cart_total_with_adjustments(@order)} - checkout_adjustments_for_summary(@order, exclude: [:distribution]).each do |adjustment| #{raw(adjustment.label)} #{adjustment.display_amount} Order Total: #{@order.display_total} -- if @order.payments.first.andand.payment_method.andand.type == "Spree::PaymentMethod::Check" +- if @order.payments.first.andand.payment_method.andand.type == "Spree::PaymentMethod::Check" and @order.payments.first.andand.payment_method.andand.description \ ============================================================ Payment Details @@ -28,11 +28,14 @@ Order Total: #{@order.display_total} Your order will be delivered to: #{@order.ship_address.to_s} -- if @order.order_cycle.andand.pickup_time_for(@order.distributor) - Delivery on: #{@order.order_cycle.pickup_time_for(@order.distributor)} + - if @order.shipping_method.andand.description + #{@order.shipping_method.description.html_safe} -- if @order.order_cycle.andand.pickup_instructions_for(@order.distributor) - Other delivery information: #{@order.order_cycle.pickup_instructions_for(@order.distributor)} + - if @order.order_cycle.andand.pickup_time_for(@order.distributor) + Delivery on: #{@order.order_cycle.pickup_time_for(@order.distributor)} + + - if @order.order_cycle.andand.pickup_instructions_for(@order.distributor) + Other delivery information: #{@order.order_cycle.pickup_instructions_for(@order.distributor)} - else \ From 5497f229e16067084beb6ac87865f2203506b784 Mon Sep 17 00:00:00 2001 From: Rob Harrington Date: Wed, 1 Oct 2014 11:49:46 +1000 Subject: [PATCH 55/55] Ignoring enterprise ownership before_validations when no owner set --- app/models/enterprise.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/enterprise.rb b/app/models/enterprise.rb index a81655a1de..a88e1c766e 100644 --- a/app/models/enterprise.rb +++ b/app/models/enterprise.rb @@ -50,9 +50,9 @@ class Enterprise < ActiveRecord::Base validates :type, presence: true, inclusion: {in: TYPES} validates :address, presence: true, associated: true validates_presence_of :owner - validate :enforce_ownership_limit, if: lambda { owner_id_changed? } + validate :enforce_ownership_limit, if: lambda { owner_id_changed? && !owner_id.nil? } - before_validation :ensure_owner_is_manager, if: lambda { owner_id_changed? } + before_validation :ensure_owner_is_manager, if: lambda { owner_id_changed? && !owner_id.nil? } before_validation :set_unused_address_fields after_validation :geocode_address