DEV: Explicitly allow NavItem customization (#17061)
Allow overriding NavItem's title and displayName. Fixes multiple instances of `computed-property.override` warnings in plugins.
This commit is contained in:
parent
8d0c2cd4f8
commit
77632d2d36
|
@ -17,27 +17,47 @@ import { reads } from "@ember/object/computed";
|
||||||
|
|
||||||
const NavItem = EmberObject.extend({
|
const NavItem = EmberObject.extend({
|
||||||
@discourseComputed("name")
|
@discourseComputed("name")
|
||||||
title(name) {
|
title: {
|
||||||
return I18n.t("filters." + name.replace("/", ".") + ".help", {});
|
get(name) {
|
||||||
|
if (this._title) {
|
||||||
|
return this._title;
|
||||||
|
}
|
||||||
|
|
||||||
|
return I18n.t("filters." + name.replace("/", ".") + ".help", {});
|
||||||
|
},
|
||||||
|
|
||||||
|
set(value) {
|
||||||
|
this.set("_title", value);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("name", "count")
|
@discourseComputed("name", "count")
|
||||||
displayName(name, count) {
|
displayName: {
|
||||||
count = count || 0;
|
get(name, count) {
|
||||||
|
if (this._displayName) {
|
||||||
|
return this._displayName;
|
||||||
|
}
|
||||||
|
|
||||||
if (
|
count = count || 0;
|
||||||
name === "latest" &&
|
|
||||||
(!Site.currentProp("mobileView") || this.tagId !== undefined)
|
|
||||||
) {
|
|
||||||
count = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
let extra = { count };
|
if (
|
||||||
const titleKey = count === 0 ? ".title" : ".title_with_count";
|
name === "latest" &&
|
||||||
|
(!Site.currentProp("mobileView") || this.tagId !== undefined)
|
||||||
|
) {
|
||||||
|
count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
return emojiUnescape(
|
let extra = { count };
|
||||||
I18n.t(`filters.${name.replace("/", ".") + titleKey}`, extra)
|
const titleKey = count === 0 ? ".title" : ".title_with_count";
|
||||||
);
|
|
||||||
|
return emojiUnescape(
|
||||||
|
I18n.t(`filters.${name.replace("/", ".") + titleKey}`, extra)
|
||||||
|
);
|
||||||
|
},
|
||||||
|
|
||||||
|
set(value) {
|
||||||
|
this.set("_displayName", value);
|
||||||
|
},
|
||||||
},
|
},
|
||||||
|
|
||||||
@discourseComputed("filterType", "category", "noSubcategories", "tagId")
|
@discourseComputed("filterType", "category", "noSubcategories", "tagId")
|
||||||
|
|
Loading…
Reference in New Issue