DEV: Remove buffered rendering from group-index-toggle (#8399)

* DEV: Remove buffered rendering from group-index-toggle

This is the first step in a refactor to remove all uses of our Buffered
Renderer:

01e2d5a670/app/assets/javascripts/discourse-common/lib/buffered-render.js.es6 (L3)

This commit affects the header sorting on the group member and the group
requests pages. It is a refactor only with no change in functionality.
This commit is contained in:
Blake Erickson 2019-11-25 13:36:00 -07:00 committed by GitHub
parent a3157f0e38
commit d0ad5ecc6d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 25 deletions

View File

@ -1,29 +1,30 @@
import Component from "@ember/component";
import { iconHTML } from "discourse-common/lib/icon-library";
import { bufferedRender } from "discourse-common/lib/buffered-render";
export default Component.extend(
bufferedRender({
tagName: "th",
classNames: ["sortable"],
rerenderTriggers: ["order", "desc"],
buildBuffer(buffer) {
buffer.push("<span class='header-contents'>");
buffer.push(I18n.t(this.i18nKey));
if (this.field === this.order) {
buffer.push(iconHTML(this.desc ? "chevron-down" : "chevron-up"));
}
buffer.push("</span>");
},
click() {
if (this.order === this.field) {
this.set("desc", this.desc ? null : true);
} else {
this.setProperties({ order: this.field, desc: null });
}
export default Component.extend({
tagName: "th",
classNames: ["sortable"],
chevronIcon: null,
toggleProperties() {
if (this.order === this.field) {
this.set("desc", this.desc ? null : true);
} else {
this.setProperties({ order: this.field, desc: null });
}
})
);
},
toggleChevron() {
if (this.order === this.field) {
let chevron = iconHTML(this.desc ? "chevron-down" : "chevron-up");
this.set("chevronIcon", `${chevron}`.htmlSafe());
} else {
this.set("chevronIcon", null);
}
},
click() {
this.toggleProperties();
},
didReceiveAttrs() {
this._super(...arguments);
this.toggleChevron();
}
});

View File

@ -0,0 +1 @@
<span class="header-contents">{{i18n this.i18nKey}}{{chevronIcon}}</span>