mirror of
https://github.com/discourse/discourse.git
synced 2024-12-15 11:03:41 +08:00
e0199e8094
This is another refactoring in the multi-step process to remove all uses
of our custom Render Buffer.
Previous commit: d0ad5ecc6d
in this
series.
This commit affects the table header sorting on the admin directory page.
It is just a refactor and should not change any functionality.
31 lines
799 B
JavaScript
31 lines
799 B
JavaScript
import Component from "@ember/component";
|
|
import { iconHTML } from "discourse-common/lib/icon-library";
|
|
|
|
export default Component.extend({
|
|
tagName: "th",
|
|
classNames: ["sortable"],
|
|
chevronIcon: null,
|
|
toggleProperties() {
|
|
if (this.order === this.field) {
|
|
this.set("ascending", this.ascending ? null : true);
|
|
} else {
|
|
this.setProperties({ order: this.field, ascending: null });
|
|
}
|
|
},
|
|
toggleChevron() {
|
|
if (this.order === this.field) {
|
|
let chevron = iconHTML(this.ascending ? "chevron-up" : "chevron-down");
|
|
this.set("chevronIcon", `${chevron}`.htmlSafe());
|
|
} else {
|
|
this.set("chevronIcon", null);
|
|
}
|
|
},
|
|
click() {
|
|
this.toggleProperties();
|
|
},
|
|
didReceiveAttrs() {
|
|
this._super(...arguments);
|
|
this.toggleChevron();
|
|
}
|
|
});
|