meilisearch-admin/app/components/simple-table/column.js
Stanislav Romanov 43fc701c5d Clear code
2022-09-23 19:30:32 +03:00

36 lines
769 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 === `${this.args.prop}:asc`;
}
get isDescSorted() {
return this.args.sortingProp === `${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);
}
}
}