Adding all the Angular filters required to make this work

This commit is contained in:
Will Marshall
2014-07-02 12:08:21 +10:00
parent 79f42ccc61
commit f19a02264e
6 changed files with 122 additions and 0 deletions

View 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

View 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

View 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