meilisearch-admin/app/components/simple-table/column.js

37 lines
769 B
JavaScript
Raw Normal View History

2022-04-26 09:41:33 +00:00
import Component from '@glimmer/component';
import { action } from '@ember/object';
2022-09-16 07:37:33 +00:00
export default class SimpleTableColumnComponent extends Component {
2022-04-26 09:41:33 +00:00
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 === `${this.args.prop}:asc`;
}
get isDescSorted() {
return this.args.sortingProp === `${this.args.prop}:desc`;
}
@action
handleClickHead(e) {
2022-09-16 07:37:33 +00:00
this.args.onClickHead?.(this.args.prop, this, e);
2022-04-26 09:41:33 +00:00
}
@action
handleSort(e) {
2022-09-16 07:37:33 +00:00
if (this.args.sortable) {
this.args.onSort?.(this.args.prop, this, e);
2022-04-26 09:41:33 +00:00
}
}
}