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

37 lines
781 B
JavaScript
Raw Permalink 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() {
2022-10-24 10:16:55 +00:00
return this.args.sortingProp.includes(`${this.args.prop}:asc`);
2022-04-26 09:41:33 +00:00
}
get isDescSorted() {
2022-10-24 10:16:55 +00:00
return this.args.sortingProp.includes(`${this.args.prop}:desc`);
2022-04-26 09:41:33 +00:00
}
@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
}
}
}