DEV: Don't pass multiple categories to tag-drop
The tag-drop component uses the passed in categories to calculate paths, but only the last category is relevant, since, from a category we can calculate its ancestors.
This commit is contained in:
parent
016732cced
commit
712e171b34
|
@ -14,8 +14,7 @@
|
||||||
|
|
||||||
{{#if siteSettings.tagging_enabled}}
|
{{#if siteSettings.tagging_enabled}}
|
||||||
{{tag-drop
|
{{tag-drop
|
||||||
firstCategory=firstCategory
|
currentCategory=category
|
||||||
secondCategory=secondCategory
|
|
||||||
tagId=tagId}}
|
tagId=tagId}}
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
import { alias, or } from "@ember/object/computed";
|
import { computed } from "@ember/object";
|
||||||
|
import { alias } from "@ember/object/computed";
|
||||||
import { makeArray } from "discourse-common/lib/helpers";
|
import { makeArray } from "discourse-common/lib/helpers";
|
||||||
import ComboBoxComponent from "select-kit/components/combo-box";
|
import ComboBoxComponent from "select-kit/components/combo-box";
|
||||||
import DiscourseURL from "discourse/lib/url";
|
import DiscourseURL from "discourse/lib/url";
|
||||||
|
@ -6,6 +7,7 @@ import TagsMixin from "select-kit/mixins/tags";
|
||||||
import { default as discourseComputed } from "discourse-common/utils/decorators";
|
import { default as discourseComputed } from "discourse-common/utils/decorators";
|
||||||
const { isEmpty, run } = Ember;
|
const { isEmpty, run } = Ember;
|
||||||
import Category from "discourse/models/category";
|
import Category from "discourse/models/category";
|
||||||
|
import deprecated from "discourse-common/lib/deprecated";
|
||||||
|
|
||||||
export default ComboBoxComponent.extend(TagsMixin, {
|
export default ComboBoxComponent.extend(TagsMixin, {
|
||||||
pluginApiIdentifiers: ["tag-drop"],
|
pluginApiIdentifiers: ["tag-drop"],
|
||||||
|
@ -17,7 +19,6 @@ export default ComboBoxComponent.extend(TagsMixin, {
|
||||||
allowAutoSelectFirst: false,
|
allowAutoSelectFirst: false,
|
||||||
tagName: "li",
|
tagName: "li",
|
||||||
showFilterByTag: alias("siteSettings.show_filter_by_tag"),
|
showFilterByTag: alias("siteSettings.show_filter_by_tag"),
|
||||||
currentCategory: or("secondCategory", "firstCategory"),
|
|
||||||
tagId: null,
|
tagId: null,
|
||||||
categoryStyle: alias("siteSettings.category_style"),
|
categoryStyle: alias("siteSettings.category_style"),
|
||||||
mutateAttributes() {},
|
mutateAttributes() {},
|
||||||
|
@ -27,6 +28,27 @@ export default ComboBoxComponent.extend(TagsMixin, {
|
||||||
allowContentReplacement: true,
|
allowContentReplacement: true,
|
||||||
isAsync: true,
|
isAsync: true,
|
||||||
|
|
||||||
|
currentCategory: computed("secondCategory", "firstCategory", {
|
||||||
|
set(key, value) {
|
||||||
|
this.currentCategoryRaw = value;
|
||||||
|
return value;
|
||||||
|
},
|
||||||
|
|
||||||
|
get() {
|
||||||
|
if (this.currentCategoryRaw) {
|
||||||
|
return this.currentCategoryRaw;
|
||||||
|
}
|
||||||
|
|
||||||
|
const result = this.secondCategory || this.firstCategory;
|
||||||
|
if (result) {
|
||||||
|
deprecated(
|
||||||
|
"Setting firstCategory and secondCategory on tag-drop directly is deprecated. Please use currentCategory instead."
|
||||||
|
);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
|
||||||
@discourseComputed("tagId")
|
@discourseComputed("tagId")
|
||||||
noTagsSelected() {
|
noTagsSelected() {
|
||||||
return this.tagId === "none";
|
return this.tagId === "none";
|
||||||
|
@ -70,7 +92,7 @@ export default ComboBoxComponent.extend(TagsMixin, {
|
||||||
return tagId ? `tag-${tagId}` : "tag_all";
|
return tagId ? `tag-${tagId}` : "tag_all";
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("firstCategory", "secondCategory")
|
@discourseComputed("currentCategory")
|
||||||
allTagsUrl() {
|
allTagsUrl() {
|
||||||
if (this.currentCategory) {
|
if (this.currentCategory) {
|
||||||
return Discourse.getURL(this.get("currentCategory.url") + "?allTags=1");
|
return Discourse.getURL(this.get("currentCategory.url") + "?allTags=1");
|
||||||
|
|
Loading…
Reference in New Issue