ui: remove sort-control component (#8077)

This was never actually used
This commit is contained in:
John Cowen 2020-06-10 14:27:21 +01:00 committed by GitHub
parent 328874ad4f
commit db1ed14acf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 0 additions and 69 deletions

View File

@ -1,7 +0,0 @@
<input id={{concat 'sort-control-value-' elementId}} type="radio" value="Name" name={{concat 'sort-control-' name}} onchange={{action 'change'}} />
{{#if checked}}
<input id={{concat 'sort-control-direction-' elementId}} type="checkbox" onchange={{action 'change'}} />
{{/if}}
<label for={{if checked (concat 'sort-control-direction-' elementId) (concat 'sort-control-value-' elementId)}}>
{{yield}}
</label>

View File

@ -1,15 +0,0 @@
import Component from '@ember/component';
import { 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: `${this.value}:${this.direction}` } });
},
},
});

View File

@ -1,47 +0,0 @@
import { module, test } from 'qunit';
import { setupRenderingTest } from 'ember-qunit';
import { render } from '@ember/test-helpers';
import hbs from 'htmlbars-inline-precompile';
module('Integration | Component | sort control', function(hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function() {
this.actions = {};
this.send = (actionName, ...args) => this.actions[actionName].apply(this, args);
});
test('it renders', async function(assert) {
// Set any properties with this.set('myProperty', 'value');
// Handle any actions with this.on('myAction', function(val) { ... });
await render(hbs`{{sort-control}}`);
assert.dom('*').hasText('');
// Template block usage:
await render(hbs`
{{#sort-control}}
template block text
{{/sort-control}}
`);
assert.dom('*').hasText('template block text');
});
test('it changes direction and calls onchange when clicked/activated', async function(assert) {
assert.expect(2);
let count = 0;
this.actions.change = e => {
if (count === 0) {
assert.equal(e.target.value, 'sort:desc');
} else {
assert.equal(e.target.value, 'sort:asc');
}
count++;
};
await render(hbs`{{sort-control checked=true value='sort' onchange=(action 'change')}}`);
const $label = this.$('label');
$label.trigger('click');
$label.trigger('click');
});
});