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

37 lines
904 B
Plaintext
Raw Normal View History

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