mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Add property filters for shops
This commit is contained in:
@@ -3,7 +3,7 @@
|
||||
-# .small-12.medium-6.columns
|
||||
= render 'shared/components/show_profiles'
|
||||
|
||||
.row.animate-show{"ng-show" => "filtersActive"}
|
||||
.row.animate-show.filter-row{"ng-show" => "filtersActive"}
|
||||
.small-12.columns
|
||||
.row.filter-box
|
||||
.small-12.large-9.columns
|
||||
@@ -19,4 +19,12 @@
|
||||
= t :hubs_filter_delivery
|
||||
%shipping-type-selector
|
||||
|
||||
.small-12.large-12.columns
|
||||
%h5.tdhead
|
||||
.light
|
||||
= 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", "active-selectors" => "activeProperties"}
|
||||
|
||||
= render 'shared/components/filter_box'
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
.active_table
|
||||
%hub.active_table_node.row{"ng-repeat" => "hub in #{enterprises}Filtered = (#{enterprises} | filter:filterExpression | taxons:activeTaxons | shipping:shippingTypes | showHubProfiles:show_profiles | orderBy:['-active', '+distance', '+orders_close_at'])",
|
||||
%hub.active_table_node.row{"ng-repeat" => "hub in #{enterprises}Filtered = (#{enterprises} | filter:filterExpression | taxons:activeTaxons | properties:activeProperties | shipping:shippingTypes | showHubProfiles:show_profiles | orderBy:['-active', '+distance', '+orders_close_at'])",
|
||||
"ng-class" => "{'is_profile' : hub.category == 'hub_profile', 'closed' : !open(), 'open' : open(), 'inactive' : !hub.active, 'current' : current()}",
|
||||
"ng-controller" => "HubNodeCtrl",
|
||||
id: "{{hub.hash}}"}
|
||||
|
||||
@@ -505,6 +505,7 @@ See the %{link} to find out more about %{sitename}'s features and to start using
|
||||
hubs_filter_by: "Filter by"
|
||||
hubs_filter_type: "Type"
|
||||
hubs_filter_delivery: "Delivery"
|
||||
hubs_filter_property: "Property"
|
||||
hubs_matches: "Did you mean?"
|
||||
hubs_intro: Shop in your local area
|
||||
hubs_distance: Closest to
|
||||
|
||||
@@ -56,6 +56,36 @@ feature 'Shops', js: true do
|
||||
expect(page).to have_current_path enterprise_shop_path(distributor)
|
||||
end
|
||||
|
||||
describe "filtering by product property" do
|
||||
let!(:order_cycle) { create(:simple_order_cycle, distributors: [d1, d2], coordinator: 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
|
||||
p2.set_property 'Local', 'XYZ 123'
|
||||
|
||||
ex_d1.variants << p1.variants.first
|
||||
ex_d2.variants << p2.variants.first
|
||||
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
|
||||
|
||||
describe "property badges" do
|
||||
let!(:order_cycle) { create(:simple_order_cycle, distributors: [distributor], coordinator: create(:distributor_enterprise), variants: [product.variants.first]) }
|
||||
let(:product) { create(:simple_product, supplier: producer) }
|
||||
|
||||
Reference in New Issue
Block a user