diff --git a/app/views/groups/_hub_filters.html.haml b/app/views/groups/_hub_filters.html.haml
deleted file mode 100644
index 71924d5e85..0000000000
--- a/app/views/groups/_hub_filters.html.haml
+++ /dev/null
@@ -1,21 +0,0 @@
-.row
- = render partial: 'shared/components/filter_controls'
- = render partial: 'shared/components/show_profiles'
-
-.row.animate-show{"ng-show" => "filtersActive"}
- .small-12.columns
- .row.filter-box
- .small-12.large-9.columns
- %h5.tdhead
- .light
- = t :hubs_filter_by
- = t :hubs_filter_type
- %filter-selector.small-block-grid-2.medium-block-grid-4.large-block-grid-5{"selector-set" => "filterSelectors", objects: "group_hubs | searchEnterprises:query | shipping:shippingTypes | showHubProfiles:show_profiles | taxonsOf", "active-selectors" => "activeTaxons"}
- .small-12.large-3.columns
- %h5.tdhead
- .light
- = t :hubs_filter_by
- = t :hubs_filter_delivery
- %shipping-type-selector
-
-= render partial: 'shared/components/filter_box'
diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml
index 2f2f0e7a62..90b74c0b42 100644
--- a/app/views/groups/show.html.haml
+++ b/app/views/groups/show.html.haml
@@ -88,13 +88,13 @@
= t :groups_hubs
= render "shared/components/enterprise_search"
- = render "hub_filters"
+ = render "shops/filters", resource: "group_hubs", property_filters: "| searchEnterprises:query | taxons:activeTaxons | shipping:shippingTypes | showHubProfiles:show_profiles"
.row
.small-12.columns
.active_table
%hub.active_table_node.row.animate-repeat{id: "{{hub.hash}}",
- "ng-repeat" => "hub in filteredEnterprises = (group_hubs | searchEnterprises:query | taxons:activeTaxons | shipping:shippingTypes | showHubProfiles:show_profiles | properties:activeProperties:'distributed_properties' | orderBy:['-active', '+orders_close_at'])",
+ "ng-repeat" => "hub in filteredEnterprises = (group_hubs | searchEnterprises:query | taxons:activeTaxons | shipping:shippingTypes | showHubProfiles:show_profiles | properties:activeProperties:'distributed_properties' | orderBy:['-active', '+orders_close_at'])",
"ng-class" => "{'is_profile' : hub.category == 'hub_profile', 'closed' : !open(), 'open' : open(), 'inactive' : !hub.active, 'current' : current()}",
"ng-controller" => "GroupEnterpriseNodeCtrl"}
.small-12.columns
diff --git a/app/views/shops/_filters.html.haml b/app/views/shops/_filters.html.haml
index 93d4e5b19f..1094d81b2f 100644
--- a/app/views/shops/_filters.html.haml
+++ b/app/views/shops/_filters.html.haml
@@ -1,3 +1,6 @@
+- resource ||= "visibleMatches"
+- property_filters ||= "| filter:filterExpression | taxons:activeTaxons | shipping:shippingTypes | showHubProfiles:show_profiles"
+
.row
= render 'shared/components/filter_controls'
-# .small-12.medium-6.columns
@@ -11,7 +14,8 @@
.light
= t :hubs_filter_by
= t :hubs_filter_type
- %filter-selector.small-block-grid-2.medium-block-grid-4.large-block-grid-5{ "selector-set" => "filterSelectors", objects: "visibleMatches | visible | taxonsOf", "active-selectors" => "activeTaxons" }
+
+ %filter-selector.small-block-grid-2.medium-block-grid-4.large-block-grid-5{ "selector-set" => "filterSelectors", objects: "#{resource} | visible | taxonsOf", "active-selectors" => "activeTaxons" }
.small-12.large-3.columns
%h5.tdhead
.light
@@ -25,6 +29,6 @@
= t :hubs_filter_by
= t :hubs_filter_property
.filter-shopfront.property-selectors
- %single-line-selectors{ selectors: "filterSelectors", objects: "visibleMatches | filter:filterExpression | taxons:activeTaxons | shipping:shippingTypes | showHubProfiles:show_profiles | propertiesOf:'distributed_properties'", "active-selectors" => "activeProperties"}
+ %single-line-selectors{ selectors: "filterSelectors", objects: "#{resource} #{property_filters} | propertiesOf:'distributed_properties'", "active-selectors" => "activeProperties"}
= render 'shared/components/filter_box'
diff --git a/spec/features/consumer/groups_spec.rb b/spec/features/consumer/groups_spec.rb
index 039322b379..4a5f166d7d 100644
--- a/spec/features/consumer/groups_spec.rb
+++ b/spec/features/consumer/groups_spec.rb
@@ -54,4 +54,43 @@ feature 'Groups', js: true do
end
end
end
+
+ describe "shops" do
+ describe "filtering by product property" do
+ let!(:group) { create(:enterprise_group, enterprises: [d1, d2], on_front_page: true) }
+ let!(:order_cycle) { create(:simple_order_cycle, distributors: [d1, d2], coordinator: create(:distributor_enterprise)) }
+ let(:producer) { create(:supplier_enterprise) }
+ let(:d1) { create(:distributor_enterprise) }
+ let(:d2) { create(:distributor_enterprise) }
+ let(:p1) { create(:simple_product, supplier: producer) }
+ let(:p2) { create(:simple_product, supplier: create(:supplier_enterprise)) }
+ let(:ex_d1) { order_cycle.exchanges.outgoing.where(receiver_id: d1).first }
+ let(:ex_d2) { order_cycle.exchanges.outgoing.where(receiver_id: d2).first }
+
+ before do
+ producer.set_producer_property 'Organic', 'NASAA 12345'
+ p2.set_property 'Local', 'XYZ 123'
+
+ ex_d1.variants << p1.variants.first
+ ex_d2.variants << p2.variants.first
+
+ visit group_path(group, anchor: "/hubs")
+ end
+
+ it "filters" do
+ toggle_filters
+
+ toggle_filter 'Organic'
+
+ expect(page).to have_content d1.name
+ expect(page).not_to have_content d2.name
+
+ toggle_filter 'Organic'
+ toggle_filter 'Local'
+
+ expect(page).not_to have_content d1.name
+ expect(page).to have_content d2.name
+ end
+ end
+ end
end