discourse/app/assets/javascripts/admin/components/admin-directory-toggle.js.es6

38 lines
944 B
Plaintext
Raw Normal View History

2018-06-15 11:03:24 -04:00
import { iconHTML } from "discourse-common/lib/icon-library";
import { bufferedRender } from "discourse-common/lib/buffered-render";
2018-06-15 11:03:24 -04:00
export default Ember.Component.extend(
bufferedRender({
tagName: "th",
classNames: ["sortable"],
rerenderTriggers: ["order", "ascending"],
2018-06-15 11:03:24 -04:00
buildBuffer(buffer) {
const icon = this.get("icon");
2018-06-15 11:03:24 -04:00
if (icon) {
buffer.push(iconHTML(icon));
}
2018-06-15 11:03:24 -04:00
buffer.push(I18n.t(this.get("i18nKey")));
2018-06-15 11:03:24 -04:00
if (this.get("field") === this.get("order")) {
buffer.push(
iconHTML(this.get("ascending") ? "chevron-up" : "chevron-down")
);
}
},
2018-06-15 11:03:24 -04:00
click() {
const currentOrder = this.get("order");
const field = this.get("field");
2018-06-15 11:03:24 -04:00
if (currentOrder === field) {
this.set("ascending", this.get("ascending") ? null : true);
} else {
this.setProperties({ order: field, ascending: null });
}
}
2018-06-15 11:03:24 -04:00
})
);