DEV: Remove buffered rendering from navigation-item
This is another refactoring in the multi-step process to remove all uses
of our custom Render Buffer.
Previous commit: ea6326c860
in this
series.
This commit affects the top menu buttons. It is just a refactor and
should not change any functionality.
This commit is contained in:
parent
b6a2875749
commit
006e5904be
|
@ -1,11 +1,8 @@
|
|||
import discourseComputed from "discourse-common/utils/decorators";
|
||||
import Component from "@ember/component";
|
||||
import { bufferedRender } from "discourse-common/lib/buffered-render";
|
||||
import FilterModeMixin from "discourse/mixins/filter-mode";
|
||||
|
||||
export default Component.extend(
|
||||
FilterModeMixin,
|
||||
bufferedRender({
|
||||
export default Component.extend(FilterModeMixin, {
|
||||
tagName: "li",
|
||||
classNameBindings: [
|
||||
"active",
|
||||
|
@ -16,6 +13,8 @@ export default Component.extend(
|
|||
attributeBindings: ["content.title:title"],
|
||||
hidden: false,
|
||||
rerenderTriggers: ["content.count"],
|
||||
activeClass: "",
|
||||
hrefLink: null,
|
||||
|
||||
@discourseComputed("content.filterType", "filterType", "content.active")
|
||||
active(contentFilterType, filterType, active) {
|
||||
|
@ -25,7 +24,8 @@ export default Component.extend(
|
|||
return contentFilterType === filterType;
|
||||
},
|
||||
|
||||
buildBuffer(buffer) {
|
||||
didReceiveAttrs() {
|
||||
this._super(...arguments);
|
||||
const content = this.content;
|
||||
|
||||
let href = content.get("href");
|
||||
|
@ -50,6 +50,9 @@ export default Component.extend(
|
|||
if (queryParams.length) {
|
||||
href += `?${queryParams.join("&")}`;
|
||||
}
|
||||
this.set("hrefLink", href);
|
||||
|
||||
this.set("activeClass", this.active ? "active" : "");
|
||||
|
||||
if (
|
||||
!this.active &&
|
||||
|
@ -62,16 +65,5 @@ export default Component.extend(
|
|||
} else {
|
||||
this.set("hidden", false);
|
||||
}
|
||||
|
||||
buffer.push(
|
||||
`<a href='${href}'` + (this.active ? 'class="active"' : "") + `>`
|
||||
);
|
||||
|
||||
if (content.get("hasIcon")) {
|
||||
buffer.push("<span class='" + content.get("name") + "'></span>");
|
||||
}
|
||||
buffer.push(this.get("content.displayName"));
|
||||
buffer.push("</a>");
|
||||
}
|
||||
})
|
||||
);
|
||||
});
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
<a href={{hrefLink}} class={{activeClass}}>
|
||||
{{#if hasIcon}}
|
||||
<span class={{content.name}}></span>
|
||||
{{/if}}
|
||||
{{content.displayName}}
|
||||
</a>
|
Loading…
Reference in New Issue