FEATURE: Tags display on knowledge explorer

This commit is contained in:
Justin DiRose 2019-07-03 10:26:28 -05:00
parent 64555d5362
commit d62e856fc5
5 changed files with 59 additions and 0 deletions

View File

@ -0,0 +1,13 @@
import computed from "ember-addons/ember-computed-decorators";
import DiscourseURL from "discourse/lib/url";
export default Ember.Component.extend({
@computed("category", "tag")
href(category, tag) {
return "/knowledge-explorer";
},
click() {
DiscourseURL.routeTo(this.href, { replaceURL: true });
}
});

View File

@ -0,0 +1,23 @@
import computed from "ember-addons/ember-computed-decorators";
import { on, observes } from "ember-addons/ember-computed-decorators";
import { ajax } from "discourse/lib/ajax";
function sortAlpha(a, b) {
let aName = a.id.toLowerCase();
let bName = b.id.toLowerCase();
return aName < bName ? -1 : aName > bName ? 1 : 0;
}
function sortCount(a, b) {
let aCount = a.count;
let bCount = b.count;
return bCount - aCount || a.id.localeCompare(b.id);
}
let cachedResults = null;
let lastFetchDate = null;
export default Ember.Component.extend({
classNames: "knowledge-explorer-tags"
});

View File

@ -0,0 +1,9 @@
<div class="knowledge-explorer-tag {{if tag.active 'selected'}} {{if subtag 'subtag'}}">
{{#unless tag.active}}
{{d-icon "plus"}}
{{/unless}}
{{tag.id}} <span class="tag-count">({{tag.count}})</span>
{{#if tag.active}}
{{d-icon "times-circle"}}
{{/if}}
</div>

View File

@ -0,0 +1,11 @@
{{#each model.tags as |tag|}}
{{knowledge-explorer-tag tag=tag}}
{{/each}}
{{#if subtags}}
{{#each subtags as |tag|}}
{{knowledge-explorer-tag
tag=tag
subtag=true}}
{{/each}}
{{/if}}

View File

@ -1,3 +1,6 @@
<div class="knowledge-explorer">
{{knowledge-explorer-tags
model=model
searchResults=searchResults}}
{{knowledge-explorer-topic-list model=model}}
</div>