diff --git a/app/assets/javascripts/darkswarm/controllers/hubs_controller.js.coffee b/app/assets/javascripts/darkswarm/controllers/hubs_controller.js.coffee index ca7d86f5cf..acc71b1172 100644 --- a/app/assets/javascripts/darkswarm/controllers/hubs_controller.js.coffee +++ b/app/assets/javascripts/darkswarm/controllers/hubs_controller.js.coffee @@ -1,6 +1,6 @@ Darkswarm.controller "HubsCtrl", ($scope, Hubs, $document, $rootScope, HashNavigation) -> $scope.Hubs = Hubs - $scope.hubs = Hubs.hubs + $scope.hubs = Hubs.visible $rootScope.$on "$locationChangeSuccess", (newRoute, oldRoute) -> if HashNavigation.active "hubs" diff --git a/app/assets/javascripts/darkswarm/darkswarm.js.coffee b/app/assets/javascripts/darkswarm/darkswarm.js.coffee index 1e58fe7294..fc6f9dfed4 100644 --- a/app/assets/javascripts/darkswarm/darkswarm.js.coffee +++ b/app/assets/javascripts/darkswarm/darkswarm.js.coffee @@ -6,7 +6,6 @@ window.Darkswarm = angular.module("Darkswarm", ["ngResource", 'angular-flash.service', 'templates', 'ngSanitize', - 'ngAnimate', 'google-maps', 'duScroll', ]).config ($httpProvider, $tooltipProvider, $locationProvider, $anchorScrollProvider) -> diff --git a/app/assets/javascripts/darkswarm/services/hubs.js.coffee b/app/assets/javascripts/darkswarm/services/hubs.js.coffee index 5d55fa7de9..92a5d45464 100644 --- a/app/assets/javascripts/darkswarm/services/hubs.js.coffee +++ b/app/assets/javascripts/darkswarm/services/hubs.js.coffee @@ -3,6 +3,8 @@ Darkswarm.factory 'Hubs', ($filter, Enterprises) -> constructor: -> @hubs = @order Enterprises.enterprises.filter (hub)-> hub.is_distributor + @visible = @hubs.filter (hub)-> + hub.visible order: (hubs)-> $filter('orderBy')(hubs, ['-active', '+orders_close_at']) diff --git a/app/helpers/shared_helper.rb b/app/helpers/shared_helper.rb index 41312f704a..2133ea9c8f 100644 --- a/app/helpers/shared_helper.rb +++ b/app/helpers/shared_helper.rb @@ -1,6 +1,6 @@ module SharedHelper def inject_enterprises - inject_json_ams "enterprises", Enterprise.visible, Api::EnterpriseSerializer, active_distributors: @active_distributors + inject_json_ams "enterprises", Enterprise.all, Api::EnterpriseSerializer, active_distributors: @active_distributors end def inject_json(name, partial, opts = {}) diff --git a/app/serializers/api/address_serializer.rb b/app/serializers/api/address_serializer.rb index fee2a32b19..a4dfcb0f5f 100644 --- a/app/serializers/api/address_serializer.rb +++ b/app/serializers/api/address_serializer.rb @@ -1,3 +1,7 @@ class Api::AddressSerializer < ActiveModel::Serializer - attributes :id + attributes :id, :zipcode, :city, :state + + def state + object.state.abbr + end end diff --git a/app/serializers/api/enterprise_serializer.rb b/app/serializers/api/enterprise_serializer.rb index 75d26ca137..a74606dd79 100644 --- a/app/serializers/api/enterprise_serializer.rb +++ b/app/serializers/api/enterprise_serializer.rb @@ -1,7 +1,7 @@ class Api::EnterpriseSerializer < ActiveModel::Serializer attributes :name, :id, :description, :latitude, :longitude, :long_description, :website, :instagram, :linkedin, :twitter, - :facebook, :is_primary_producer, :is_distributor, :phone, + :facebook, :is_primary_producer, :is_distributor, :phone, :visible, :email, :hash, :logo, :promo_image, :icon, :path, :pickup, :delivery, :active, :orders_close_at diff --git a/app/views/producers/index.haml b/app/views/producers/index.haml index b71013c425..46845f9474 100644 --- a/app/views/producers/index.haml +++ b/app/views/producers/index.haml @@ -21,7 +21,7 @@ .row{bindonce: true} .small-12.columns .active_table - %producer.active_table_node.row{id: "{{producer.path}}", + %producer.active_table_node.row.animate-repeat{id: "{{producer.path}}", "scroll-after-load" => true, "ng-repeat" => "producer in filteredProducers = (Producers.producers | filterProducers:query)", "ng-controller" => "ProducerNodeCtrl", diff --git a/spec/features/consumer/home_spec.rb b/spec/features/consumer/home_spec.rb index c6ac4af2ba..520923d251 100644 --- a/spec/features/consumer/home_spec.rb +++ b/spec/features/consumer/home_spec.rb @@ -5,6 +5,7 @@ feature 'Home', js: true do include UIComponentHelper let!(:distributor) { create(:distributor_enterprise) } + let!(:invisible_distributor) { create(:distributor_enterprise, visible: false) } let(:d1) { create(:distributor_enterprise) } let(:d2) { create(:distributor_enterprise) } let!(:order_cycle) { create(:order_cycle, distributors: [distributor], coordinator: create(:distributor_enterprise)) } @@ -15,12 +16,16 @@ feature 'Home', js: true do visit "/" end - it "shows all hubs" do + it "shows hubs" do page.should have_content distributor.name expand_active_table_node distributor.name page.should have_content "Shop at #{distributor.name}" end + it "does not show invisible hubs" do + page.should_not have_content invisible_distributor.name + end + it "should grey out hubs that are not in an order cycle" do create(:simple_product, distributors: [d1, d2]) visit root_path