From ace22374172400352d5028be513a3322b4d9c477 Mon Sep 17 00:00:00 2001 From: Mali Akmanalp Date: Fri, 13 Apr 2018 12:02:46 -0400 Subject: [PATCH] Add livestock search support. --- app/controllers/search.js | 5 +++++ app/routes/search.js | 5 +++-- app/templates/search.hbs | 13 +++++++++++++ 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/app/controllers/search.js b/app/controllers/search.js index cc2238fd..a348ab8f 100644 --- a/app/controllers/search.js +++ b/app/controllers/search.js @@ -63,6 +63,11 @@ export default Ember.Controller.extend({ return get(d,'constructor.modelName') === 'nonag'; }); }), + livestockResults: computed('results.[]', function() { + return this.get('results').filter(function(d){ + return get(d,'constructor.modelName') === 'livestock'; + }); + }), landuseResults: computed('results.[]', function() { return this.get('results').filter(function(d){ return get(d,'constructor.modelName') === 'land-use'; diff --git a/app/routes/search.js b/app/routes/search.js index ddb0dc4e..0cf2c0f3 100644 --- a/app/routes/search.js +++ b/app/routes/search.js @@ -15,6 +15,7 @@ export default Ember.Route.extend({ var agproducts = this.store.find('agproduct', { level: 'level3' }); var nonags = this.store.find('nonag', { level: 'level3' }); + var livestock = this.store.find('livestock', { level: 'level1' }); var landuses = this.store.find('land-use', { level: 'level2' }); var industriesDivision = this.store.find('industry', { level: 'division' }); @@ -29,9 +30,9 @@ export default Ember.Route.extend({ } else if(transition.filter === 'product') { request = [products]; } else if(transition.filter === 'rural') { - request = [agproducts, landuses, nonags]; + request = [agproducts, landuses, nonags, livestock]; } else { - request = [country, department, msa, municipality, industriesDivision, industriesClass, products, agproducts, landuses, nonags]; + request = [country, department, msa, municipality, industriesDivision, industriesClass, products, agproducts, landuses, nonags, livestock]; } return Ember.RSVP.all(request) diff --git a/app/templates/search.hbs b/app/templates/search.hbs index 8251b2f9..252e002d 100755 --- a/app/templates/search.hbs +++ b/app/templates/search.hbs @@ -88,6 +88,19 @@ {{/each}} {{/if}} +{{#if livestockResults.length}} +

{{t 'search.results_livestock'}}

+ +{{/if}} {{#if industryResults.length}}

{{t 'search.results_industries'}}