Select all checkbox icon class for status
This commit is contained in:
parent
d6d9569e8d
commit
98fe4f1afc
3 changed files with 25 additions and 1 deletions
|
@ -1,5 +1,5 @@
|
|||
import Component from '@ember/component';
|
||||
import { set } from '@ember/object';
|
||||
import { set, computed } from '@ember/object';
|
||||
|
||||
const defaultFiles = [];
|
||||
const defaultSelectedFilePaths = [];
|
||||
|
@ -7,6 +7,11 @@ const defaultSelectedFilePaths = [];
|
|||
export default Component.extend({
|
||||
files: defaultFiles,
|
||||
selectedFilePaths: defaultSelectedFilePaths,
|
||||
selectAllStatus: computed('selectedFilePaths.[]', 'files.[]', function() {
|
||||
if (this.selectedFilePaths.length === this.files.length) {
|
||||
return 'all';
|
||||
} else return this.selectedFilePaths.length === 0 ? 'none' : 'some';
|
||||
}),
|
||||
|
||||
actions: {
|
||||
toggleSelectAll() {
|
||||
|
|
|
@ -3,6 +3,12 @@
|
|||
data-test-action="file-table-select-all"
|
||||
{{action "toggleSelectAll"}}
|
||||
>
|
||||
<i
|
||||
class="file-table-select-status-{{selectAllStatus}}"
|
||||
data-test-id="file-table-select-status-icon"
|
||||
>
|
||||
|
||||
</i>
|
||||
Selected {{selectedFilePaths.length}}
|
||||
</button>
|
||||
<button data-test-action="file-table-download-selected">Download Selected</button>
|
||||
|
|
|
@ -74,4 +74,17 @@ module('Integration | Component | file-table', function(hooks) {
|
|||
await click('[data-test-action=file-table-select-all]');
|
||||
assert.equal(find('[data-test-action=file-table-select-all]').textContent.trim(), 'Selected ' + this.files.length);
|
||||
});
|
||||
|
||||
test('select all checkbox changes appearance between some, all and none', async function(assert) {
|
||||
this.set('files', [genericFile(), genericFile()]);
|
||||
this.set('selectedFilePaths', [this.files[0].path]);
|
||||
await render(hbs`{{file-table files=files selectedFilePaths=selectedFilePaths}}`);
|
||||
assert.equal(find('[data-test-id=file-table-select-status-icon]').classList.contains('file-table-select-status-some'), true, 'Shows SOME checkbox status icon');
|
||||
|
||||
await click('[data-test-action=file-table-select-all]');
|
||||
assert.equal(find('[data-test-id=file-table-select-status-icon]').classList.contains('file-table-select-status-all'), true, 'Shows ALL checkbox status icon');
|
||||
|
||||
await click('[data-test-action=file-table-select-all]');
|
||||
assert.equal(find('[data-test-id=file-table-select-status-icon]').classList.contains('file-table-select-status-none'), true, 'Shows NONE checkbox status icon');
|
||||
});
|
||||
});
|
Loading…
Add table
Reference in a new issue