This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/components/group-index-toggle.js
2020-03-12 13:29:55 -04:00

31 lines
779 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("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();
}
});