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