meilisearch-admin/app/components/simple-table/column.js
2022-10-24 13:16:55 +03:00

36 lines
781 B
JavaScript

import Component from '@glimmer/component';
import { action } from '@ember/object';
export default class SimpleTableColumnComponent extends Component {
get isHead() {
return this.args.place === 'head';
}
get isBody() {
return this.args.place === 'body';
}
get isSorted() {
return this.args.sortingProp && (this.isAscSorted || this.isDescSorted);
}
get isAscSorted() {
return this.args.sortingProp.includes(`${this.args.prop}:asc`);
}
get isDescSorted() {
return this.args.sortingProp.includes(`${this.args.prop}:desc`);
}
@action
handleClickHead(e) {
this.args.onClickHead?.(this.args.prop, this, e);
}
@action
handleSort(e) {
if (this.args.sortable) {
this.args.onSort?.(this.args.prop, this, e);
}
}
}