Skip to content
Permalink
Browse files

FEATURE: Add category to knowledge explorer topic list

  • Loading branch information...
justindirose committed Nov 4, 2019
1 parent 1c845cd commit 42ac7bb984e57dc88980894523031cb357291296
@@ -1,8 +1,18 @@
import {
default as computed
} from "ember-addons/ember-computed-decorators";
import { default as computed } from "ember-addons/ember-computed-decorators";
import KnowledgeExplorer from "discourse/plugins/discourse-knowledge-explorer/discourse/models/knowledge-explorer";

function mergeCategories(results) {
const categories = Discourse.Category.list();
const topics = results.topics.topic_list.topics.map(t => {
t.category = categories.findBy("id", t.category_id);
return t;
});

results.topics.topic_list.topics = topics;

return results;
}

export default Ember.Controller.extend({
application: Ember.inject.controller(),
queryParams: {
@@ -108,6 +118,7 @@ export default Ember.Controller.extend({
this.set("isLoadingMore", true);

KnowledgeExplorer.loadMore(this.loadMoreUrl).then(result => {
result = mergeCategories(result);
const topics = this.topics.concat(result.topics.topic_list.topics);

this.setProperties({
@@ -129,6 +140,7 @@ export default Ember.Controller.extend({
);

KnowledgeExplorer.list(params).then(result => {
result = mergeCategories(result);
this.setProperties({
model: result,
isLoading: false
@@ -9,5 +9,20 @@ export default Ember.Route.extend({

model(params) {
return KnowledgeExplorer.list(params);
},

setupController(controller, model) {
const categories = Discourse.Category.list();

let topics = model.topics.topic_list.topics;

topics = topics.map(t => {
t.category = categories.findBy("id", t.category_id);
return t;
});

model.topics.topic_list.topics = topics;

controller.set("model", model);
}
});
@@ -15,6 +15,7 @@
}}
</span>
<span class="link-bottom-line">
{{category-link topic.category}}
{{#each topic.tags as |tag|}}
<span class="discourse-tag">{{tag}}</span>
{{/each}}

0 comments on commit 42ac7bb

Please sign in to comment.
You can’t perform that action at this time.