FIX: Ensure list model is loaded
This fixes an edge case, such as when browsing directly into a topic in the Knowledge Explorer view, where when you click the back button and the list model is not generated.
This commit is contained in:
parent
6f78ea2bb2
commit
006a2eb418
|
@ -3,6 +3,7 @@ import Category from "discourse/models/category";
|
||||||
import Topic from "discourse/models/topic";
|
import Topic from "discourse/models/topic";
|
||||||
import { on } from "discourse-common/utils/decorators";
|
import { on } from "discourse-common/utils/decorators";
|
||||||
import KnowledgeExplorer from "discourse/plugins/discourse-knowledge-explorer/discourse/models/knowledge-explorer";
|
import KnowledgeExplorer from "discourse/plugins/discourse-knowledge-explorer/discourse/models/knowledge-explorer";
|
||||||
|
import { getOwner } from "@ember/application";
|
||||||
|
|
||||||
function mergeCategories(results) {
|
function mergeCategories(results) {
|
||||||
const categories = Category.list();
|
const categories = Category.list();
|
||||||
|
@ -243,6 +244,14 @@ export default Ember.Controller.extend({
|
||||||
} else {
|
} else {
|
||||||
this.set("expandedFilters", false);
|
this.set("expandedFilters", false);
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
returnToList() {
|
||||||
|
this.set("selectedTopic", null);
|
||||||
|
getOwner(this)
|
||||||
|
.lookup("router:main")
|
||||||
|
.transitionTo("knowledgeExplorer");
|
||||||
|
this.send("refreshModel");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { ajax } from "discourse/lib/ajax";
|
||||||
import Topic from "discourse/models/topic";
|
import Topic from "discourse/models/topic";
|
||||||
|
|
||||||
function getTopic(id) {
|
function getTopic(id) {
|
||||||
return ajax(`/t/${id}.json`);
|
return ajax(`/t/${id}.json?ke=true`);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
|
|
|
@ -1,6 +1,8 @@
|
||||||
{{#link-to 'knowledgeExplorer' (query-params topic=null) class='knowledge-explorer-nav-link return'}}
|
{{d-button
|
||||||
{{i18n 'knowledge_explorer.topic.back'}}
|
label="knowledge_explorer.topic.back"
|
||||||
{{/link-to}}
|
class="knowledge-explorer-nav-link return"
|
||||||
|
action=return
|
||||||
|
}}
|
||||||
|
|
||||||
<div class="topic-content">
|
<div class="topic-content">
|
||||||
<h1>{{topic.title}}</h1>
|
<h1>{{topic.title}}</h1>
|
||||||
|
|
|
@ -55,7 +55,7 @@
|
||||||
</div>
|
</div>
|
||||||
{{#if selectedTopic}}
|
{{#if selectedTopic}}
|
||||||
{{#conditional-loading-spinner condition=isTopicLoading}}
|
{{#conditional-loading-spinner condition=isTopicLoading}}
|
||||||
{{knowledge-explorer-topic topic=topic}}
|
{{knowledge-explorer-topic topic=topic return=(action "returnToList")}}
|
||||||
{{/conditional-loading-spinner}}
|
{{/conditional-loading-spinner}}
|
||||||
{{else}}
|
{{else}}
|
||||||
<div class="knowledge-explorer-results">
|
<div class="knowledge-explorer-results">
|
||||||
|
|
|
@ -147,7 +147,12 @@
|
||||||
.knowledge-explorer-nav-link {
|
.knowledge-explorer-nav-link {
|
||||||
font-weight: 700;
|
font-weight: 700;
|
||||||
&.return {
|
&.return {
|
||||||
|
align-items: center;
|
||||||
|
background: none;
|
||||||
|
color: $tertiary;
|
||||||
|
display: inline-flex;
|
||||||
font-size: $font-down-1;
|
font-size: $font-down-1;
|
||||||
|
padding: 0;
|
||||||
&::before {
|
&::before {
|
||||||
content: "«";
|
content: "«";
|
||||||
margin-right: 5px;
|
margin-right: 5px;
|
||||||
|
|
Loading…
Reference in New Issue