mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-08 22:56:06 +00:00
fix producer taxon filtering bug
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
Darkswarm.filter 'taxons', (Matcher)->
|
||||
# Filter anything that responds to object.taxons, and/or object.primary_taxon
|
||||
Darkswarm.filter 'taxons', ()->
|
||||
# Filter anything that responds to object.taxons, object.supplied_taxon or object.primary_taxon.
|
||||
(objects, ids) ->
|
||||
objects ||= []
|
||||
ids ?= []
|
||||
if ids.length == 0
|
||||
# No taxons selected, pass all objects through.
|
||||
objects
|
||||
else
|
||||
objects.filter (obj)->
|
||||
taxons = obj.taxons
|
||||
taxons.concat obj.supplied_taxons if obj.supplied_taxons
|
||||
# Combine object taxons with supplied taxons, if they exist.
|
||||
taxons = taxons.concat obj.supplied_taxons if obj.supplied_taxons
|
||||
# Match primary taxon if it exists, then taxon array.
|
||||
obj.primary_taxon?.id in ids || taxons.some (taxon)->
|
||||
taxon.id in ids
|
||||
|
||||
Reference in New Issue
Block a user