mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-07 03:01:33 +00:00
Adding all the Angular filters required to make this work
This commit is contained in:
14
app/assets/javascripts/darkswarm/filters/active.js.coffee
Normal file
14
app/assets/javascripts/darkswarm/filters/active.js.coffee
Normal file
@@ -0,0 +1,14 @@
|
||||
Darkswarm.filter 'active', ()->
|
||||
(objects, options)->
|
||||
objects ||= []
|
||||
options ?= null
|
||||
|
||||
if options.open and !options.closed
|
||||
objects.filter (obj)->
|
||||
obj.active
|
||||
else if options.closed and !options.open
|
||||
objects.filter (obj)->
|
||||
!obj.active
|
||||
else
|
||||
objects
|
||||
|
||||
13
app/assets/javascripts/darkswarm/filters/shipping.js.coffee
Normal file
13
app/assets/javascripts/darkswarm/filters/shipping.js.coffee
Normal file
@@ -0,0 +1,13 @@
|
||||
Darkswarm.filter 'shipping', ()->
|
||||
(objects, options)->
|
||||
objects ||= []
|
||||
options ?= null
|
||||
|
||||
if options.pickup and !options.delivery
|
||||
objects.filter (obj)->
|
||||
obj.pickup
|
||||
else if options.delivery and !options.pickup
|
||||
objects.filter (obj)->
|
||||
obj.delivery
|
||||
else
|
||||
objects
|
||||
10
app/assets/javascripts/darkswarm/filters/taxons.js.coffee
Normal file
10
app/assets/javascripts/darkswarm/filters/taxons.js.coffee
Normal file
@@ -0,0 +1,10 @@
|
||||
Darkswarm.filter 'taxons', (Matcher)->
|
||||
# Filter anything that responds to object.taxons, and/or object.primary_taxon
|
||||
(objects, text) ->
|
||||
objects ||= []
|
||||
text ?= ""
|
||||
objects.filter (obj)->
|
||||
Matcher.match([obj.primary_taxon?.name || ""], text) || obj.taxons.some (taxon)->
|
||||
Matcher.match [taxon.name], text
|
||||
|
||||
|
||||
Reference in New Issue
Block a user