Commit 786133d3 authored by Nick Kipling's avatar Nick Kipling Committed by Nathan Friend

Updated select all to be more explicit

parent 237f434c
...@@ -126,15 +126,21 @@ export default { ...@@ -126,15 +126,21 @@ export default {
showError(message) { showError(message) {
createFlash(errorMessages[message]); createFlash(errorMessages[message]);
}, },
selectAll() { onSelectAllChange() {
if (!this.selectAllChecked) { if (this.selectAllChecked) {
this.itemsToBeDeleted = this.repo.list.map((x, idx) => idx); this.deselectAll();
this.selectAllChecked = true;
} else { } else {
this.itemsToBeDeleted = []; this.selectAll();
this.selectAllChecked = false;
} }
}, },
selectAll() {
this.itemsToBeDeleted = this.repo.list.map((x, idx) => idx);
this.selectAllChecked = true;
},
deselectAll() {
this.itemsToBeDeleted = [];
this.selectAllChecked = false;
},
updateItemsToBeDeleted(idx) { updateItemsToBeDeleted(idx) {
const delIdx = this.itemsToBeDeleted.findIndex(x => x === idx); const delIdx = this.itemsToBeDeleted.findIndex(x => x === idx);
...@@ -162,7 +168,7 @@ export default { ...@@ -162,7 +168,7 @@ export default {
v-if="repo.canDelete" v-if="repo.canDelete"
class="js-select-all-checkbox" class="js-select-all-checkbox"
:checked="selectAllChecked" :checked="selectAllChecked"
@change="selectAll" @change="onSelectAllChange"
/> />
</th> </th>
<th>{{ s__('ContainerRegistry|Tag') }}</th> <th>{{ s__('ContainerRegistry|Tag') }}</th>
......
...@@ -27,7 +27,8 @@ describe('table registry', () => { ...@@ -27,7 +27,8 @@ describe('table registry', () => {
}); });
}; };
const toggleSelectAll = () => vm.selectAll(); const selectAllCheckboxes = () => vm.selectAll();
const deselectAllCheckboxes = () => vm.deselectAll();
beforeEach(() => { beforeEach(() => {
createComponent(); createComponent();
...@@ -58,7 +59,7 @@ describe('table registry', () => { ...@@ -58,7 +59,7 @@ describe('table registry', () => {
describe('multi select', () => { describe('multi select', () => {
it('should support multiselect and selecting a row should enable delete button', done => { it('should support multiselect and selecting a row should enable delete button', done => {
findSelectAllCheckbox().click(); findSelectAllCheckbox().click();
toggleSelectAll(); selectAllCheckboxes();
expect(findSelectAllCheckbox().checked).toBe(true); expect(findSelectAllCheckbox().checked).toBe(true);
...@@ -69,8 +70,7 @@ describe('table registry', () => { ...@@ -69,8 +70,7 @@ describe('table registry', () => {
}); });
it('selecting all checkbox should select all rows and enable delete button', done => { it('selecting all checkbox should select all rows and enable delete button', done => {
findSelectAllCheckbox().click(); selectAllCheckboxes();
toggleSelectAll();
Vue.nextTick(() => { Vue.nextTick(() => {
const checkedValues = findAllRowCheckboxes().filter(x => x.checked); const checkedValues = findAllRowCheckboxes().filter(x => x.checked);
...@@ -81,9 +81,8 @@ describe('table registry', () => { ...@@ -81,9 +81,8 @@ describe('table registry', () => {
}); });
it('deselecting select all checkbox should deselect all rows and disable delete button', done => { it('deselecting select all checkbox should deselect all rows and disable delete button', done => {
findSelectAllCheckbox().click(); selectAllCheckboxes();
toggleSelectAll(); // Select them all on deselectAllCheckboxes();
toggleSelectAll(); // Select them all off
Vue.nextTick(() => { Vue.nextTick(() => {
const checkedValues = findAllRowCheckboxes().filter(x => x.checked); const checkedValues = findAllRowCheckboxes().filter(x => x.checked);
...@@ -94,8 +93,7 @@ describe('table registry', () => { ...@@ -94,8 +93,7 @@ describe('table registry', () => {
}); });
it('should delete multiple items when multiple items are selected', done => { it('should delete multiple items when multiple items are selected', done => {
findSelectAllCheckbox().click(); selectAllCheckboxes();
toggleSelectAll();
Vue.nextTick(() => { Vue.nextTick(() => {
expect(vm.itemsToBeDeleted).toEqual([0, 1]); expect(vm.itemsToBeDeleted).toEqual([0, 1]);
...@@ -177,8 +175,7 @@ describe('table registry', () => { ...@@ -177,8 +175,7 @@ describe('table registry', () => {
}); });
it('should show the plural title and image count when deleting more than one image', done => { it('should show the plural title and image count when deleting more than one image', done => {
findSelectAllCheckbox().click(); selectAllCheckboxes();
toggleSelectAll();
Vue.nextTick(() => { Vue.nextTick(() => {
expect(vm.modalTitle).toBe('Remove images'); expect(vm.modalTitle).toBe('Remove images');
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment