From 4ae18ec16278fd970f404d9ee357a393e336c1a2 Mon Sep 17 00:00:00 2001 From: Dominik Pschenitschni Date: Sat, 2 Oct 2021 20:10:49 +0200 Subject: [PATCH] fix: kanban drag task test --- cypress/integration/list/list.spec.js | 2 +- src/store/modules/kanban.js | 37 --------------------------- src/views/list/views/Kanban.vue | 24 +++++++---------- 3 files changed, 10 insertions(+), 53 deletions(-) diff --git a/cypress/integration/list/list.spec.js b/cypress/integration/list/list.spec.js index 8242984e6..3d597c79c 100644 --- a/cypress/integration/list/list.spec.js +++ b/cypress/integration/list/list.spec.js @@ -446,7 +446,7 @@ describe('Lists', () => { cy.get('.kanban .bucket .tasks .task') .contains(tasks[0].title) .first() - .drag('.kanban .bucket:nth-child(2) .tasks .dropper div') + .drag('.kanban .bucket:nth-child(2) .tasks .dropper') cy.get('.kanban .bucket:nth-child(2) .tasks') .should('contain', tasks[0].title) diff --git a/src/store/modules/kanban.js b/src/store/modules/kanban.js index b3de7e537..e10aeea47 100644 --- a/src/store/modules/kanban.js +++ b/src/store/modules/kanban.js @@ -378,43 +378,6 @@ export default { .finally(() => cancel()) }, - updateBuckets(ctx, updatedBucketsData) { - const cancel = setLoading(ctx, 'kanban') - - const oldBuckets = [] - const updatedBuckets = updatedBucketsData.map((updatedBucketData) => { - const bucketIndex = findIndexById(ctx.state.buckets, updatedBucketData.id) - const bucket = ctx.state.buckets[bucketIndex] - - const oldBucket = cloneDeep(bucket) - oldBuckets.push(oldBucket) - - const newBucket = { - // FIXME: maybe optional to set the original value as well - ...bucket, - id: updatedBucketData.id, - listId: updatedBucketData.listId || oldBucket.listId, - ...updatedBucketData, - } - ctx.commit('setBucketByIndex', {bucketIndex, bucket: newBucket}) - - const bucketService = new BucketService() - return bucketService.update(newBucket) - }) - - return Promise.all(updatedBuckets) - .then(r => { - Promise.resolve(r) - }) - .catch(e => { - // restore original state - Object.values(updatedBuckets).forEach((oldBucket) => ctx.commit('setBucketById', oldBucket)) - - return Promise.reject(e) - }) - .finally(() => cancel()) - }, - updateBucketTitle(ctx, { id, title }) { const bucket = findById(ctx.state.buckets, id) diff --git a/src/views/list/views/Kanban.vue b/src/views/list/views/Kanban.vue index 16abf8154..2e23758cc 100644 --- a/src/views/list/views/Kanban.vue +++ b/src/views/list/views/Kanban.vue @@ -19,11 +19,11 @@ :class="{ 'is-loading': loading && !oneTaskUpdating}" class="kanban kanban-bucket-container loader-container" > - state.kanban.listId, @@ -424,9 +418,6 @@ export default { const taskBefore = newBucket.tasks[e.newIndex - 1] ?? null const taskAfter = newBucket.tasks[e.newIndex + 1] ?? null - // task.kanbanPosition = calculateItemPosition(taskBefore !== null ? taskBefore.kanbanPosition : null, taskAfter !== null ? taskAfter.kanbanPosition : null) - // task.bucketId = newBucket.id - const newTask = { ...task, bucketId: newBucket.id, @@ -522,10 +513,13 @@ export default { }) }, - updateBucketPositions(buckets) { - this.$store.dispatch('kanban/updateBuckets', buckets) + updateBuckets(value) { + // (1) buckets get updated in store and tasks positions get invalidated + this.$store.commit('kanban/setBuckets', value) }, + updateBucketPosition(e) { + // (2) bucket positon is changed this.dragBucket = false const bucket = this.buckets[e.newIndex]