Skip to content

Commit

Permalink
Add livestock search support.
Browse files Browse the repository at this point in the history
  • Loading branch information
makmanalp committed Apr 13, 2018
1 parent 90d0c04 commit ace2237
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
5 changes: 5 additions & 0 deletions app/controllers/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
5 changes: 3 additions & 2 deletions app/routes/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -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' });
Expand All @@ -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)
Expand Down
13 changes: 13 additions & 0 deletions app/templates/search.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,19 @@
{{/each}}
</ul>
{{/if}}
{{#if livestockResults.length}}
<h3 class="section__head results__subhead">{{t 'search.results_livestock'}}</h3>
<ul class="results__list">
{{#each result in livestockResults}}
{{search-result
result=result
tagName="li"
class="results__item"
levelOnly=true
}}
{{/each}}
</ul>
{{/if}}
{{#if industryResults.length}}
<h3 class="section__head results__subhead">{{t 'search.results_industries'}}</h3>
<ul class="results__list">
Expand Down

0 comments on commit ace2237

Please sign in to comment.