diff --git a/app/assets/javascripts/darkswarm/filters/filter_products.js.coffee b/app/assets/javascripts/darkswarm/filters/filter_products.js.coffee new file mode 100644 index 0000000000..c01a941659 --- /dev/null +++ b/app/assets/javascripts/darkswarm/filters/filter_products.js.coffee @@ -0,0 +1,7 @@ +Darkswarm.filter 'products', (Matcher)-> + (products, text)-> + products ||= [] + text ?= "" + products.filter (product)=> + propertiesToMatch = [product.name, product.supplier.name, product.primary_taxon.name] + Matcher.match propertiesToMatch, text diff --git a/app/views/shop/products/_form.html.haml b/app/views/shop/products/_form.html.haml index e18c197594..b7681e2764 100644 --- a/app/views/shop/products/_form.html.haml +++ b/app/views/shop/products/_form.html.haml @@ -13,7 +13,7 @@ %div{bindonce: true} %product{"ng-controller" => "ProductNodeCtrl", - "ng-repeat" => "product in Product.products | filter:query | orderBy:ordering.order | limitTo: limit track by product.id"} + "ng-repeat" => "product in Product.products | products:query | orderBy:ordering.order | limitTo: limit track by product.id"} %div = render partial: "shop/products/summary" %div{"bo-if" => "hasVariants"}