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'