FIX: Missing count method for search results

This commit is contained in:
Justin DiRose 2019-09-10 10:45:25 -05:00
parent adc07ae8ad
commit e7359a118b
3 changed files with 14 additions and 6 deletions

View File

@ -98,15 +98,19 @@ module KnowledgeExplorer
def knowledge_explorer_categories def knowledge_explorer_categories
selected_categories = SiteSetting.knowledge_explorer_categories.split("|") selected_categories = SiteSetting.knowledge_explorer_categories.split("|")
categories = Category.where('id IN (?)', selected_categories) if selected_categories
categories = Category.where('id IN (?)', selected_categories)
categories.select { |c| @guardian.can_see_category?(c) } return categories.select { |c| @guardian.can_see_category?(c) }
end
end end
def knowledge_explorer_tags def knowledge_explorer_tags
selected_tags = SiteSetting.knowledge_explorer_tags.split("|") selected_tags = SiteSetting.knowledge_explorer_tags.split("|")
Tag.where('name IN (?)', selected_tags) if selected_tags
return Tag.where('name IN (?)', selected_tags)
end
end end
def category_by_filter(category_filter) def category_by_filter(category_filter)

View File

@ -36,6 +36,11 @@ export default Ember.Controller.extend({
return results.length === 0; return results.length === 0;
}, },
@computed("searchResults")
searchCount(results) {
return results.length;
},
@observes("filterTags") @observes("filterTags")
filterByTags() { filterByTags() {
const filterTags = this.get("filterTags"); const filterTags = this.get("filterTags");
@ -49,7 +54,6 @@ export default Ember.Controller.extend({
arrayContainsArray(topic.tags, filter) arrayContainsArray(topic.tags, filter)
); );
debugger;
const filteredTags = []; const filteredTags = [];
// add active tags // add active tags

View File

@ -22,9 +22,9 @@
{{/if}} {{/if}}
{{else if hasSearchResults}} {{else if hasSearchResults}}
{{#if emptySearchResults}} {{#if emptySearchResults}}
{<div class="no-result">{i18n 'search.no_results'}}</div> <div class="no-result">{{i18n 'search.no_results'}}</div>
{{else}} {{else}}
<div>{{i18n "knowledge_explorer.search.results" count=count}}</div> <div>{{i18n 'knowledge_explorer.search.results' count=searchCount}}</div>
{{knowledge-explorer-topic-list topics=searchResults}} {{knowledge-explorer-topic-list topics=searchResults}}
{{/if}} {{/if}}
{{else}} {{else}}