github.com/anth0d/nomad@v0.0.0-20221214183521-ae3a0a2cad06/ui/app/components/list-table/sort-by.js (about) 1 import Component from '@ember/component'; 2 import { computed } from '@ember/object'; 3 import { 4 classNames, 5 attributeBindings, 6 classNameBindings, 7 tagName, 8 } from '@ember-decorators/component'; 9 import classic from 'ember-classic-decorator'; 10 11 @classic 12 @tagName('th') 13 @attributeBindings('title') 14 @classNames('is-selectable') 15 @classNameBindings('isActive:is-active', 'sortDescending:desc:asc') 16 export default class SortBy extends Component { 17 // The prop that the table is currently sorted by 18 currentProp = ''; 19 20 // The prop this sorter controls 21 prop = ''; 22 23 @computed('currentProp', 'prop') 24 get isActive() { 25 return this.currentProp === this.prop; 26 } 27 28 @computed('sortDescending', 'isActive') 29 get shouldSortDescending() { 30 return !this.isActive || !this.sortDescending; 31 } 32 }