2019-10-23 12:30:52 -04:00
|
|
|
import Component from "@ember/component";
|
2018-06-15 11:03:24 -04:00
|
|
|
import { iconHTML } from "discourse-common/lib/icon-library";
|
2017-02-20 08:42:33 -05:00
|
|
|
|
2019-11-25 20:02:55 -05:00
|
|
|
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);
|
2017-02-20 08:42:33 -05:00
|
|
|
}
|
2019-11-25 20:02:55 -05:00
|
|
|
},
|
|
|
|
click() {
|
|
|
|
this.toggleProperties();
|
|
|
|
},
|
|
|
|
didReceiveAttrs() {
|
|
|
|
this._super(...arguments);
|
|
|
|
this.toggleChevron();
|
|
|
|
}
|
|
|
|
});
|