Shops on groups page filter by property

This commit is contained in:
Rohan Mitchell
2016-08-26 16:22:05 +10:00
parent ed2522f6d2
commit 8339d247f8
4 changed files with 47 additions and 25 deletions

View File

@@ -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'

View File

@@ -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

View File

@@ -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'

View File

@@ -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