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.es6
2019-05-27 10:15:39 +02:00

29 lines
767 B
JavaScript

import { iconHTML } from "discourse-common/lib/icon-library";
import { bufferedRender } from "discourse-common/lib/buffered-render";
export default Ember.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 });
}
}
})
);