open-consul/ui-v2/app/components/sort-control.js
John Cowen a1bebaba4a ui: Adds a sort-control component for asc/desc sorting of columns etc (#6034)
This adds the component but doesn't yet use it anywhere. No tests
are added here as there isn't an awful lot to test.
2019-09-04 08:35:16 +00:00

16 lines
464 B
JavaScript

import Component from '@ember/component';
import { get, set } from '@ember/object';
export default Component.extend({
classNames: ['sort-control'],
direction: 'asc',
onchange: function() {},
actions: {
change: function(e) {
if (e.target.type === 'checkbox') {
set(this, 'direction', e.target.checked ? 'desc' : 'asc');
}
this.onchange({ target: { value: `${get(this, 'value')}:${get(this, 'direction')}` } });
},
},
});