DEV: Convert to native class syntax (#187)
This commit is contained in:
parent
f69050b8c3
commit
12dfb332bf
|
@ -1,11 +1,11 @@
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
|
import { tagName } from "@ember-decorators/component";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
export default Component.extend({
|
@tagName("")
|
||||||
tagName: "",
|
export default class DocsCategory extends Component {
|
||||||
|
|
||||||
@discourseComputed("category")
|
@discourseComputed("category")
|
||||||
categoryName(category) {
|
categoryName(category) {
|
||||||
return this.site.categories.findBy("id", category.id).name;
|
return this.site.categories.findBy("id", category.id).name;
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
|
|
@ -1,20 +1,20 @@
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { action } from "@ember/object";
|
import { action } from "@ember/object";
|
||||||
|
import { classNames } from "@ember-decorators/component";
|
||||||
|
|
||||||
export default Component.extend({
|
@classNames("docs-search")
|
||||||
classNames: "docs-search",
|
export default class DocsSearch extends Component {
|
||||||
|
|
||||||
@action
|
@action
|
||||||
onKeyDown(event) {
|
onKeyDown(event) {
|
||||||
if (event.key === "Enter") {
|
if (event.key === "Enter") {
|
||||||
this.set("searchTerm", event.target.value);
|
this.set("searchTerm", event.target.value);
|
||||||
this.onSearch(event.target.value);
|
this.onSearch(event.target.value);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
clearSearch() {
|
clearSearch() {
|
||||||
this.set("searchTerm", "");
|
this.set("searchTerm", "");
|
||||||
this.onSearch("");
|
this.onSearch("");
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
|
import { tagName } from "@ember-decorators/component";
|
||||||
|
|
||||||
export default Component.extend({
|
@tagName("")
|
||||||
tagName: "",
|
export default class DocsTag extends Component {}
|
||||||
});
|
|
||||||
|
|
|
@ -1,16 +1,16 @@
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { htmlSafe } from "@ember/template";
|
import { htmlSafe } from "@ember/template";
|
||||||
|
import { classNameBindings, tagName } from "@ember-decorators/component";
|
||||||
import { RUNTIME_OPTIONS } from "discourse-common/lib/raw-handlebars-helpers";
|
import { RUNTIME_OPTIONS } from "discourse-common/lib/raw-handlebars-helpers";
|
||||||
import { findRawTemplate } from "discourse-common/lib/raw-templates";
|
import { findRawTemplate } from "discourse-common/lib/raw-templates";
|
||||||
|
|
||||||
export default Component.extend({
|
@tagName("tr")
|
||||||
tagName: "tr",
|
@classNameBindings(":topic-list-item")
|
||||||
classNameBindings: [":topic-list-item"],
|
export default class DocsTopicListItem extends Component {
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this._super(...arguments);
|
super.didInsertElement(...arguments);
|
||||||
this.renderTopicListItem();
|
this.renderTopicListItem();
|
||||||
},
|
}
|
||||||
|
|
||||||
renderTopicListItem() {
|
renderTopicListItem() {
|
||||||
const template = findRawTemplate("docs-topic-list-item");
|
const template = findRawTemplate("docs-topic-list-item");
|
||||||
|
@ -20,5 +20,5 @@ export default Component.extend({
|
||||||
htmlSafe(template(this, RUNTIME_OPTIONS))
|
htmlSafe(template(this, RUNTIME_OPTIONS))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
|
|
@ -1,31 +1,32 @@
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { action } from "@ember/object";
|
import { action } from "@ember/object";
|
||||||
|
import { classNames } from "@ember-decorators/component";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import { getDocs } from "../../lib/get-docs";
|
import { getDocs } from "../../lib/get-docs";
|
||||||
|
|
||||||
export default Component.extend({
|
@classNames("docs-topic-list")
|
||||||
classNames: "docs-topic-list",
|
export default class DocsTopicList extends Component {
|
||||||
urlPath: getDocs(),
|
urlPath = getDocs();
|
||||||
|
|
||||||
@discourseComputed("order")
|
@discourseComputed("order")
|
||||||
sortTitle(order) {
|
sortTitle(order) {
|
||||||
return order === "title";
|
return order === "title";
|
||||||
},
|
}
|
||||||
|
|
||||||
@discourseComputed("order")
|
@discourseComputed("order")
|
||||||
sortActivity(order) {
|
sortActivity(order) {
|
||||||
return order === "activity";
|
return order === "activity";
|
||||||
},
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
sortListActivity() {
|
sortListActivity() {
|
||||||
this.sortBy("activity");
|
this.sortBy("activity");
|
||||||
return false;
|
return false;
|
||||||
},
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
sortListTitle() {
|
sortListTitle() {
|
||||||
this.sortBy("title");
|
this.sortBy("title");
|
||||||
return false;
|
return false;
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
|
|
@ -1,17 +1,17 @@
|
||||||
import Component from "@ember/component";
|
import Component from "@ember/component";
|
||||||
import { reads } from "@ember/object/computed";
|
import { reads } from "@ember/object/computed";
|
||||||
|
import { classNames } from "@ember-decorators/component";
|
||||||
import discourseDebounce from "discourse-common/lib/debounce";
|
import discourseDebounce from "discourse-common/lib/debounce";
|
||||||
import computed, { bind } from "discourse-common/utils/decorators";
|
import computed, { bind } from "discourse-common/utils/decorators";
|
||||||
|
|
||||||
export default Component.extend({
|
@classNames("docs-topic")
|
||||||
classNames: "docs-topic",
|
export default class DocsTopic extends Component {
|
||||||
|
@reads("post.cooked") originalPostContent;
|
||||||
originalPostContent: reads("post.cooked"),
|
|
||||||
|
|
||||||
@computed("topic.post_stream")
|
@computed("topic.post_stream")
|
||||||
post(stream) {
|
post(stream) {
|
||||||
return this.store.createRecord("post", stream?.posts.firstObject);
|
return this.store.createRecord("post", stream?.posts.firstObject);
|
||||||
},
|
}
|
||||||
|
|
||||||
@computed("post", "topic")
|
@computed("post", "topic")
|
||||||
model() {
|
model() {
|
||||||
|
@ -22,29 +22,29 @@ export default Component.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
return post;
|
return post;
|
||||||
},
|
}
|
||||||
|
|
||||||
@bind
|
@bind
|
||||||
_emitScrollEvent() {
|
_emitScrollEvent() {
|
||||||
this.appEvents.trigger("docs-topic:current-post-scrolled");
|
this.appEvents.trigger("docs-topic:current-post-scrolled");
|
||||||
},
|
}
|
||||||
|
|
||||||
@bind
|
@bind
|
||||||
debounceScrollEvent() {
|
debounceScrollEvent() {
|
||||||
discourseDebounce(this, this._emitScrollEvent, 200);
|
discourseDebounce(this, this._emitScrollEvent, 200);
|
||||||
},
|
}
|
||||||
|
|
||||||
didInsertElement() {
|
didInsertElement() {
|
||||||
this._super(...arguments);
|
super.didInsertElement(...arguments);
|
||||||
|
|
||||||
document.body.classList.add("archetype-docs-topic");
|
document.body.classList.add("archetype-docs-topic");
|
||||||
document.addEventListener("scroll", this.debounceScrollEvent);
|
document.addEventListener("scroll", this.debounceScrollEvent);
|
||||||
},
|
}
|
||||||
|
|
||||||
willDestroyElement() {
|
willDestroyElement() {
|
||||||
this._super(...arguments);
|
super.willDestroyElement(...arguments);
|
||||||
|
|
||||||
document.body.classList.remove("archetype-docs-topic");
|
document.body.classList.remove("archetype-docs-topic");
|
||||||
document.removeEventListener("scroll", this.debounceScrollEvent);
|
document.removeEventListener("scroll", this.debounceScrollEvent);
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
|
|
@ -3,15 +3,19 @@ import Controller, { inject as controller } from "@ember/controller";
|
||||||
import { action } from "@ember/object";
|
import { action } from "@ember/object";
|
||||||
import { alias, equal, gt, readOnly } from "@ember/object/computed";
|
import { alias, equal, gt, readOnly } from "@ember/object/computed";
|
||||||
import { htmlSafe } from "@ember/template";
|
import { htmlSafe } from "@ember/template";
|
||||||
|
import { on } from "@ember-decorators/object";
|
||||||
import getURL from "discourse-common/lib/get-url";
|
import getURL from "discourse-common/lib/get-url";
|
||||||
import discourseComputed, { on } from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import Docs from "discourse/plugins/discourse-docs/discourse/models/docs";
|
import Docs from "discourse/plugins/discourse-docs/discourse/models/docs";
|
||||||
|
|
||||||
const SHOW_FILTER_AT = 10;
|
const SHOW_FILTER_AT = 10;
|
||||||
|
|
||||||
export default Controller.extend({
|
export default class DocsIndexController extends Controller {
|
||||||
queryParams: {
|
@controller application;
|
||||||
|
|
||||||
|
queryParams = [
|
||||||
|
{
|
||||||
ascending: "ascending",
|
ascending: "ascending",
|
||||||
filterCategories: "category",
|
filterCategories: "category",
|
||||||
filterTags: "tags",
|
filterTags: "tags",
|
||||||
|
@ -20,38 +24,37 @@ export default Controller.extend({
|
||||||
searchTerm: "search",
|
searchTerm: "search",
|
||||||
selectedTopic: "topic",
|
selectedTopic: "topic",
|
||||||
},
|
},
|
||||||
|
];
|
||||||
|
|
||||||
application: controller(),
|
isLoading = false;
|
||||||
|
isLoadingMore = false;
|
||||||
|
isTopicLoading = false;
|
||||||
|
filterTags = null;
|
||||||
|
filterCategories = null;
|
||||||
|
filterSolved = false;
|
||||||
|
searchTerm = null;
|
||||||
|
selectedTopic = null;
|
||||||
|
topic = null;
|
||||||
|
expandedFilters = false;
|
||||||
|
ascending = null;
|
||||||
|
orderColumn = null;
|
||||||
|
|
||||||
isLoading: false,
|
@gt("categories.length", SHOW_FILTER_AT) showCategoryFilter;
|
||||||
isLoadingMore: false,
|
categoryFilter = "";
|
||||||
isTopicLoading: false,
|
categorySort = {};
|
||||||
filterTags: null,
|
|
||||||
filterCategories: null,
|
|
||||||
filterSolved: false,
|
|
||||||
searchTerm: null,
|
|
||||||
selectedTopic: null,
|
|
||||||
topic: null,
|
|
||||||
expandedFilters: false,
|
|
||||||
ascending: null,
|
|
||||||
orderColumn: null,
|
|
||||||
|
|
||||||
showCategoryFilter: gt("categories.length", SHOW_FILTER_AT),
|
@gt("tags.length", SHOW_FILTER_AT) showTagFilter;
|
||||||
categoryFilter: "",
|
tagFilter = "";
|
||||||
categorySort: {},
|
tagSort = {};
|
||||||
|
|
||||||
showTagFilter: gt("tags.length", SHOW_FILTER_AT),
|
@alias("model.topics.load_more_url") loadMoreUrl;
|
||||||
tagFilter: "",
|
@readOnly("model.categories") categories;
|
||||||
tagSort: {},
|
@alias("model.topics.topic_list.topics") topics;
|
||||||
|
@readOnly("model.tags") tags;
|
||||||
loadMoreUrl: alias("model.topics.load_more_url"),
|
@readOnly("model.meta.show_topic_excerpts") showExcerpts;
|
||||||
categories: readOnly("model.categories"),
|
@readOnly("model.tag_groups") tagGroups;
|
||||||
topics: alias("model.topics.topic_list.topics"),
|
@alias("model.topic_count") topicCount;
|
||||||
tags: readOnly("model.tags"),
|
@equal("topicCount", 0) emptyResults;
|
||||||
showExcerpts: readOnly("model.meta.show_topic_excerpts"),
|
|
||||||
tagGroups: readOnly("model.tag_groups"),
|
|
||||||
topicCount: alias("model.topic_count"),
|
|
||||||
emptyResults: equal("topicCount", 0),
|
|
||||||
|
|
||||||
@on("init")
|
@on("init")
|
||||||
_setupFilters() {
|
_setupFilters() {
|
||||||
|
@ -68,7 +71,7 @@ export default Controller.extend({
|
||||||
direction: "desc", // or asc
|
direction: "desc", // or asc
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
@discourseComputed("categories", "categorySort", "categoryFilter")
|
@discourseComputed("categories", "categorySort", "categoryFilter")
|
||||||
sortedCategories(categories, categorySort, filter) {
|
sortedCategories(categories, categorySort, filter) {
|
||||||
|
@ -103,7 +106,7 @@ export default Controller.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
return categories;
|
return categories;
|
||||||
},
|
}
|
||||||
|
|
||||||
@discourseComputed("categorySort")
|
@discourseComputed("categorySort")
|
||||||
categorySortNumericIcon(catSort) {
|
categorySortNumericIcon(catSort) {
|
||||||
|
@ -111,7 +114,7 @@ export default Controller.extend({
|
||||||
return "sort-numeric-down";
|
return "sort-numeric-down";
|
||||||
}
|
}
|
||||||
return "sort-numeric-up";
|
return "sort-numeric-up";
|
||||||
},
|
}
|
||||||
|
|
||||||
@discourseComputed("categorySort")
|
@discourseComputed("categorySort")
|
||||||
categorySortAlphaIcon(catSort) {
|
categorySortAlphaIcon(catSort) {
|
||||||
|
@ -119,7 +122,7 @@ export default Controller.extend({
|
||||||
return "sort-alpha-down";
|
return "sort-alpha-down";
|
||||||
}
|
}
|
||||||
return "sort-alpha-up";
|
return "sort-alpha-up";
|
||||||
},
|
}
|
||||||
|
|
||||||
@discourseComputed("tags", "tagSort", "tagFilter")
|
@discourseComputed("tags", "tagSort", "tagFilter")
|
||||||
sortedTags(tags, tagSort, filter) {
|
sortedTags(tags, tagSort, filter) {
|
||||||
|
@ -143,7 +146,7 @@ export default Controller.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
return tags;
|
return tags;
|
||||||
},
|
}
|
||||||
|
|
||||||
@discourseComputed("tagGroups", "tagSort", "tagFilter")
|
@discourseComputed("tagGroups", "tagSort", "tagFilter")
|
||||||
sortedTagGroups(tagGroups, tagSort, filter) {
|
sortedTagGroups(tagGroups, tagSort, filter) {
|
||||||
|
@ -176,7 +179,7 @@ export default Controller.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
return sortedTagGroups;
|
return sortedTagGroups;
|
||||||
},
|
}
|
||||||
|
|
||||||
@discourseComputed("tagSort")
|
@discourseComputed("tagSort")
|
||||||
tagSortNumericIcon(tagSort) {
|
tagSortNumericIcon(tagSort) {
|
||||||
|
@ -184,7 +187,7 @@ export default Controller.extend({
|
||||||
return "sort-numeric-down";
|
return "sort-numeric-down";
|
||||||
}
|
}
|
||||||
return "sort-numeric-up";
|
return "sort-numeric-up";
|
||||||
},
|
}
|
||||||
|
|
||||||
@discourseComputed("tagSort")
|
@discourseComputed("tagSort")
|
||||||
tagSortAlphaIcon(tagSort) {
|
tagSortAlphaIcon(tagSort) {
|
||||||
|
@ -192,28 +195,28 @@ export default Controller.extend({
|
||||||
return "sort-alpha-down";
|
return "sort-alpha-down";
|
||||||
}
|
}
|
||||||
return "sort-alpha-up";
|
return "sort-alpha-up";
|
||||||
},
|
}
|
||||||
|
|
||||||
@discourseComputed("topics", "isSearching", "filterSolved")
|
@discourseComputed("topics", "isSearching", "filterSolved")
|
||||||
noContent(topics, isSearching, filterSolved) {
|
noContent(topics, isSearching, filterSolved) {
|
||||||
const filtered = isSearching || filterSolved;
|
const filtered = isSearching || filterSolved;
|
||||||
return this.topicCount === 0 && !filtered;
|
return this.topicCount === 0 && !filtered;
|
||||||
},
|
}
|
||||||
|
|
||||||
@discourseComputed("loadMoreUrl")
|
@discourseComputed("loadMoreUrl")
|
||||||
canLoadMore(loadMoreUrl) {
|
canLoadMore(loadMoreUrl) {
|
||||||
return loadMoreUrl === null ? false : true;
|
return loadMoreUrl === null ? false : true;
|
||||||
},
|
}
|
||||||
|
|
||||||
@discourseComputed("searchTerm")
|
@discourseComputed("searchTerm")
|
||||||
isSearching(searchTerm) {
|
isSearching(searchTerm) {
|
||||||
return !!searchTerm;
|
return !!searchTerm;
|
||||||
},
|
}
|
||||||
|
|
||||||
@discourseComputed("isSearching", "filterSolved")
|
@discourseComputed("isSearching", "filterSolved")
|
||||||
isSearchingOrFiltered(isSearching, filterSolved) {
|
isSearchingOrFiltered(isSearching, filterSolved) {
|
||||||
return isSearching || filterSolved;
|
return isSearching || filterSolved;
|
||||||
},
|
}
|
||||||
|
|
||||||
@discourseComputed
|
@discourseComputed
|
||||||
canFilterSolved() {
|
canFilterSolved() {
|
||||||
|
@ -221,17 +224,17 @@ export default Controller.extend({
|
||||||
this.siteSettings.solved_enabled &&
|
this.siteSettings.solved_enabled &&
|
||||||
this.siteSettings.docs_add_solved_filter
|
this.siteSettings.docs_add_solved_filter
|
||||||
);
|
);
|
||||||
},
|
}
|
||||||
|
|
||||||
@discourseComputed("filterTags")
|
@discourseComputed("filterTags")
|
||||||
filtered(filterTags) {
|
filtered(filterTags) {
|
||||||
return !!filterTags;
|
return !!filterTags;
|
||||||
},
|
}
|
||||||
|
|
||||||
@discourseComputed("siteSettings.tagging_enabled", "shouldShowTagsByGroup")
|
@discourseComputed("siteSettings.tagging_enabled", "shouldShowTagsByGroup")
|
||||||
shouldShowTags(tagging_enabled, shouldShowTagsByGroup) {
|
shouldShowTags(tagging_enabled, shouldShowTagsByGroup) {
|
||||||
return tagging_enabled && !shouldShowTagsByGroup;
|
return tagging_enabled && !shouldShowTagsByGroup;
|
||||||
},
|
}
|
||||||
|
|
||||||
@discourseComputed(
|
@discourseComputed(
|
||||||
"siteSettings.show_tags_by_group",
|
"siteSettings.show_tags_by_group",
|
||||||
|
@ -239,7 +242,7 @@ export default Controller.extend({
|
||||||
)
|
)
|
||||||
shouldShowTagsByGroup(show_tags_by_group, docs_tag_groups) {
|
shouldShowTagsByGroup(show_tags_by_group, docs_tag_groups) {
|
||||||
return show_tags_by_group && Boolean(docs_tag_groups);
|
return show_tags_by_group && Boolean(docs_tag_groups);
|
||||||
},
|
}
|
||||||
|
|
||||||
@discourseComputed()
|
@discourseComputed()
|
||||||
emptyState() {
|
emptyState() {
|
||||||
|
@ -260,12 +263,12 @@ export default Controller.extend({
|
||||||
title: I18n.t("docs.no_docs.title"),
|
title: I18n.t("docs.no_docs.title"),
|
||||||
body: htmlSafe(body),
|
body: htmlSafe(body),
|
||||||
};
|
};
|
||||||
},
|
}
|
||||||
|
|
||||||
@discourseComputed("docsCategories", "docsTags")
|
@discourseComputed("docsCategories", "docsTags")
|
||||||
docsCategoriesAndTags(docsCategories, docsTags) {
|
docsCategoriesAndTags(docsCategories, docsTags) {
|
||||||
return docsCategories.concat(docsTags);
|
return docsCategories.concat(docsTags);
|
||||||
},
|
}
|
||||||
|
|
||||||
@discourseComputed()
|
@discourseComputed()
|
||||||
docsCategories() {
|
docsCategories() {
|
||||||
|
@ -277,7 +280,7 @@ export default Controller.extend({
|
||||||
.split("|")
|
.split("|")
|
||||||
.map((c) => this.site.categories.findBy("id", parseInt(c, 10))?.name)
|
.map((c) => this.site.categories.findBy("id", parseInt(c, 10))?.name)
|
||||||
.filter(Boolean);
|
.filter(Boolean);
|
||||||
},
|
}
|
||||||
|
|
||||||
@discourseComputed()
|
@discourseComputed()
|
||||||
docsTags() {
|
docsTags() {
|
||||||
|
@ -286,7 +289,7 @@ export default Controller.extend({
|
||||||
}
|
}
|
||||||
|
|
||||||
return this.siteSettings.docs_tags.split("|").map((t) => `#${t}`);
|
return this.siteSettings.docs_tags.split("|").map((t) => `#${t}`);
|
||||||
},
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
toggleCategorySort(newType) {
|
toggleCategorySort(newType) {
|
||||||
|
@ -296,7 +299,7 @@ export default Controller.extend({
|
||||||
direction:
|
direction:
|
||||||
type === newType ? (direction === "asc" ? "desc" : "asc") : "asc",
|
type === newType ? (direction === "asc" ? "desc" : "asc") : "asc",
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
toggleTagSort(newType) {
|
toggleTagSort(newType) {
|
||||||
|
@ -306,12 +309,12 @@ export default Controller.extend({
|
||||||
direction:
|
direction:
|
||||||
type === newType ? (direction === "asc" ? "desc" : "asc") : "asc",
|
type === newType ? (direction === "asc" ? "desc" : "asc") : "asc",
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
onChangeFilterSolved(solvedFilter) {
|
onChangeFilterSolved(solvedFilter) {
|
||||||
this.set("filterSolved", solvedFilter);
|
this.set("filterSolved", solvedFilter);
|
||||||
},
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
updateSelectedTags(tag) {
|
updateSelectedTags(tag) {
|
||||||
|
@ -331,7 +334,7 @@ export default Controller.extend({
|
||||||
filterTags: filter,
|
filterTags: filter,
|
||||||
selectedTopic: null,
|
selectedTopic: null,
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
updateSelectedCategories(category) {
|
updateSelectedCategories(category) {
|
||||||
|
@ -343,7 +346,7 @@ export default Controller.extend({
|
||||||
});
|
});
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
},
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
performSearch(term) {
|
performSearch(term) {
|
||||||
|
@ -360,7 +363,7 @@ export default Controller.extend({
|
||||||
searchTerm: term,
|
searchTerm: term,
|
||||||
selectedTopic: null,
|
selectedTopic: null,
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
sortBy(column) {
|
sortBy(column) {
|
||||||
|
@ -377,7 +380,7 @@ export default Controller.extend({
|
||||||
} else {
|
} else {
|
||||||
this.set("ascending", "");
|
this.set("ascending", "");
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
loadMore() {
|
loadMore() {
|
||||||
|
@ -394,7 +397,7 @@ export default Controller.extend({
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
toggleFilters() {
|
toggleFilters() {
|
||||||
|
@ -403,11 +406,11 @@ export default Controller.extend({
|
||||||
} else {
|
} else {
|
||||||
this.set("expandedFilters", false);
|
this.set("expandedFilters", false);
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
returnToList() {
|
returnToList() {
|
||||||
this.set("selectedTopic", null);
|
this.set("selectedTopic", null);
|
||||||
getOwner(this).lookup("service:router").transitionTo("docs");
|
getOwner(this).lookup("service:router").transitionTo("docs");
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
|
|
@ -1,24 +1,24 @@
|
||||||
import Controller, { inject as controller } from "@ember/controller";
|
import Controller, { inject as controller } from "@ember/controller";
|
||||||
import { action } from "@ember/object";
|
import { action } from "@ember/object";
|
||||||
|
|
||||||
export default Controller.extend({
|
export default class DocsController extends Controller {
|
||||||
indexController: controller("docs.index"),
|
@controller("docs.index") indexController;
|
||||||
|
|
||||||
@action
|
@action
|
||||||
updateSelectedCategories(category) {
|
updateSelectedCategories(category) {
|
||||||
this.indexController.send("updateSelectedCategories", category);
|
this.indexController.send("updateSelectedCategories", category);
|
||||||
return false;
|
return false;
|
||||||
},
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
updateSelectedTags(tag) {
|
updateSelectedTags(tag) {
|
||||||
this.indexController.send("updateSelectedTags", tag);
|
this.indexController.send("updateSelectedTags", tag);
|
||||||
return false;
|
return false;
|
||||||
},
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
performSearch(term) {
|
performSearch(term) {
|
||||||
this.indexController.send("performSearch", term);
|
this.indexController.send("performSearch", term);
|
||||||
return false;
|
return false;
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@ import Topic from "discourse/models/topic";
|
||||||
import User from "discourse/models/user";
|
import User from "discourse/models/user";
|
||||||
import { getDocs } from "../../lib/get-docs";
|
import { getDocs } from "../../lib/get-docs";
|
||||||
|
|
||||||
const Docs = EmberObject.extend({});
|
class Docs extends EmberObject {}
|
||||||
const docsPath = getDocs();
|
const docsPath = getDocs();
|
||||||
|
|
||||||
Docs.reopenClass({
|
Docs.reopenClass({
|
||||||
|
|
|
@ -2,8 +2,8 @@ import DiscourseRoute from "discourse/routes/discourse";
|
||||||
import I18n from "I18n";
|
import I18n from "I18n";
|
||||||
import Docs from "discourse/plugins/discourse-docs/discourse/models/docs";
|
import Docs from "discourse/plugins/discourse-docs/discourse/models/docs";
|
||||||
|
|
||||||
export default DiscourseRoute.extend({
|
export default class DocsIndex extends DiscourseRoute {
|
||||||
queryParams: {
|
queryParams = {
|
||||||
ascending: { refreshModel: true },
|
ascending: { refreshModel: true },
|
||||||
filterCategories: { refreshModel: true },
|
filterCategories: { refreshModel: true },
|
||||||
filterTags: { refreshModel: true },
|
filterTags: { refreshModel: true },
|
||||||
|
@ -14,7 +14,7 @@ export default DiscourseRoute.extend({
|
||||||
replace: true,
|
replace: true,
|
||||||
refreshModel: true,
|
refreshModel: true,
|
||||||
},
|
},
|
||||||
},
|
};
|
||||||
|
|
||||||
model(params) {
|
model(params) {
|
||||||
this.controllerFor("docs.index").set("isLoading", true);
|
this.controllerFor("docs.index").set("isLoading", true);
|
||||||
|
@ -22,7 +22,7 @@ export default DiscourseRoute.extend({
|
||||||
this.controllerFor("docs.index").set("isLoading", false);
|
this.controllerFor("docs.index").set("isLoading", false);
|
||||||
return result;
|
return result;
|
||||||
});
|
});
|
||||||
},
|
}
|
||||||
|
|
||||||
titleToken() {
|
titleToken() {
|
||||||
const model = this.currentModel;
|
const model = this.currentModel;
|
||||||
|
@ -37,10 +37,10 @@ export default DiscourseRoute.extend({
|
||||||
} else {
|
} else {
|
||||||
return pageTitle;
|
return pageTitle;
|
||||||
}
|
}
|
||||||
},
|
}
|
||||||
|
|
||||||
setupController(controller, model) {
|
setupController(controller, model) {
|
||||||
controller.set("topic", model.topic);
|
controller.set("topic", model.topic);
|
||||||
controller.set("model", model);
|
controller.set("model", model);
|
||||||
},
|
}
|
||||||
});
|
}
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
import DiscourseRoute from "discourse/routes/discourse";
|
import DiscourseRoute from "discourse/routes/discourse";
|
||||||
|
|
||||||
export default DiscourseRoute.extend({});
|
export default class Docs extends DiscourseRoute {}
|
||||||
|
|
Loading…
Reference in New Issue