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:
Justin DiRose 2020-08-04 14:49:24 -05:00
parent 6f78ea2bb2
commit 006a2eb418
No known key found for this signature in database
GPG Key ID: 4B811FB264021800
5 changed files with 21 additions and 5 deletions

View File

@ -3,6 +3,7 @@ import Category from "discourse/models/category";
import Topic from "discourse/models/topic";
import { on } from "discourse-common/utils/decorators";
import KnowledgeExplorer from "discourse/plugins/discourse-knowledge-explorer/discourse/models/knowledge-explorer";
import { getOwner } from "@ember/application";
function mergeCategories(results) {
const categories = Category.list();
@ -243,6 +244,14 @@ export default Ember.Controller.extend({
} else {
this.set("expandedFilters", false);
}
},
returnToList() {
this.set("selectedTopic", null);
getOwner(this)
.lookup("router:main")
.transitionTo("knowledgeExplorer");
this.send("refreshModel");
}
}
});

View File

@ -2,7 +2,7 @@ import { ajax } from "discourse/lib/ajax";
import Topic from "discourse/models/topic";
function getTopic(id) {
return ajax(`/t/${id}.json`);
return ajax(`/t/${id}.json?ke=true`);
}
export default {

View File

@ -1,6 +1,8 @@
{{#link-to 'knowledgeExplorer' (query-params topic=null) class='knowledge-explorer-nav-link return'}}
{{i18n 'knowledge_explorer.topic.back'}}
{{/link-to}}
{{d-button
label="knowledge_explorer.topic.back"
class="knowledge-explorer-nav-link return"
action=return
}}
<div class="topic-content">
<h1>{{topic.title}}</h1>

View File

@ -55,7 +55,7 @@
</div>
{{#if selectedTopic}}
{{#conditional-loading-spinner condition=isTopicLoading}}
{{knowledge-explorer-topic topic=topic}}
{{knowledge-explorer-topic topic=topic return=(action "returnToList")}}
{{/conditional-loading-spinner}}
{{else}}
<div class="knowledge-explorer-results">

View File

@ -147,7 +147,12 @@
.knowledge-explorer-nav-link {
font-weight: 700;
&.return {
align-items: center;
background: none;
color: $tertiary;
display: inline-flex;
font-size: $font-down-1;
padding: 0;
&::before {
content: "«";
margin-right: 5px;