mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-02 02:11:33 +00:00
Adding taxon filtering
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
Darkswarm.controller "ProductsCtrl", ($scope, $rootScope, Product, OrderCycle) ->
|
||||
Darkswarm.controller "ProductsCtrl", ($scope, $rootScope, Product, OrderCycle, FilterSelectorsService) ->
|
||||
$scope.Product = Product
|
||||
$scope.totalActive = FilterSelectorsService.totalActive
|
||||
$scope.clearAll = FilterSelectorsService.clearAll
|
||||
$scope.filterText = FilterSelectorsService.filterText
|
||||
$scope.limit = 3
|
||||
$scope.ordering = {order: "name"}
|
||||
$scope.order_cycle = OrderCycle.order_cycle
|
||||
|
||||
@@ -19,8 +19,11 @@ Darkswarm.directive "taxonSelector", (FilterSelectorsService)->
|
||||
taxons = {}
|
||||
selectors = []
|
||||
for object in scope.objects()
|
||||
for taxon in (object.taxons.concat object?.supplied_taxons)
|
||||
for taxon in object.taxons
|
||||
taxons[taxon.id] = taxon
|
||||
if object.supplied_taxons
|
||||
for taxon in object.supplied_taxons
|
||||
taxons[taxon.id] = taxon
|
||||
for id, taxon of taxons
|
||||
if selector = selectors_by_id[id]
|
||||
selectors.push selector
|
||||
|
||||
17
app/views/shop/products/_filters.html.haml
Normal file
17
app/views/shop/products/_filters.html.haml
Normal file
@@ -0,0 +1,17 @@
|
||||
= render partial: 'shared/components/filter_controls'
|
||||
|
||||
.row.animate-show{"ng-show" => "filtersActive"}
|
||||
.small-12.columns
|
||||
.row.filter-box
|
||||
.small-12.columns
|
||||
%h5.tdhead
|
||||
.light Filter by
|
||||
Type
|
||||
%taxon-selector{objects: "Product.products | products: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
|
||||
@@ -1,6 +1,7 @@
|
||||
%products.small-12.columns{"ng-controller" => "ProductsCtrl", "ng-show" => "order_cycle.order_cycle_id != null",
|
||||
"infinite-scroll" => "incrementLimit()", "infinite-scroll-distance" => "1"}
|
||||
|
||||
|
||||
= form_for :order, :url => populate_orders_path, html: {:class => "custom"} do
|
||||
.row
|
||||
.small-6.columns
|
||||
@@ -8,12 +9,14 @@
|
||||
placeholder: "Search products",
|
||||
"ng-debounce" => "150",
|
||||
"ofn-disable-enter" => true}
|
||||
|
||||
.small-6.columns
|
||||
%input.button.primary.right{type: :submit, value: "Add to Cart"}
|
||||
|
||||
= render partial: "shop/products/filters"
|
||||
|
||||
%div{bindonce: true}
|
||||
%product.animate-repeat{"ng-controller" => "ProductNodeCtrl",
|
||||
"ng-repeat" => "product in Product.products | products:query | orderBy:ordering.order"}
|
||||
"ng-repeat" => "product in Product.products | products:query | taxons:activeTaxons | orderBy:ordering.order"}
|
||||
%div
|
||||
= render partial: "shop/products/summary"
|
||||
%div{"bo-if" => "hasVariants"}
|
||||
|
||||
Reference in New Issue
Block a user