fix: kanban drag task test
This commit is contained in:
parent
d66ad12f5c
commit
4ae18ec162
3 changed files with 10 additions and 53 deletions
|
@ -446,7 +446,7 @@ describe('Lists', () => {
|
||||||
cy.get('.kanban .bucket .tasks .task')
|
cy.get('.kanban .bucket .tasks .task')
|
||||||
.contains(tasks[0].title)
|
.contains(tasks[0].title)
|
||||||
.first()
|
.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')
|
cy.get('.kanban .bucket:nth-child(2) .tasks')
|
||||||
.should('contain', tasks[0].title)
|
.should('contain', tasks[0].title)
|
||||||
|
|
|
@ -378,43 +378,6 @@ export default {
|
||||||
.finally(() => cancel())
|
.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 }) {
|
updateBucketTitle(ctx, { id, title }) {
|
||||||
const bucket = findById(ctx.state.buckets, id)
|
const bucket = findById(ctx.state.buckets, id)
|
||||||
|
|
||||||
|
|
|
@ -19,11 +19,11 @@
|
||||||
:class="{ 'is-loading': loading && !oneTaskUpdating}"
|
:class="{ 'is-loading': loading && !oneTaskUpdating}"
|
||||||
class="kanban kanban-bucket-container loader-container"
|
class="kanban kanban-bucket-container loader-container"
|
||||||
>
|
>
|
||||||
<!-- @end="updateBucketPosition" -->
|
|
||||||
<draggable
|
<draggable
|
||||||
v-bind="dragOptions"
|
v-bind="dragOptions"
|
||||||
:modelValue="buckets"
|
:modelValue="buckets"
|
||||||
@update:modelValue="updateBucketPositions"
|
@update:modelValue="updateBuckets"
|
||||||
|
@end="updateBucketPosition"
|
||||||
@start="() => dragBucket = true"
|
@start="() => dragBucket = true"
|
||||||
group="buckets"
|
group="buckets"
|
||||||
:disabled="!canWrite"
|
:disabled="!canWrite"
|
||||||
|
@ -345,15 +345,9 @@ export default {
|
||||||
],
|
],
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
buckets: {
|
buckets() {
|
||||||
get() {
|
|
||||||
return this.$store.state.kanban.buckets
|
return this.$store.state.kanban.buckets
|
||||||
},
|
},
|
||||||
set(value) {
|
|
||||||
console.log('should not set buckets', value)
|
|
||||||
this.$store.commit('kanban/setBuckets', value)
|
|
||||||
},
|
|
||||||
},
|
|
||||||
...mapState({
|
...mapState({
|
||||||
loadedListId: state => state.kanban.listId,
|
loadedListId: state => state.kanban.listId,
|
||||||
loading: state => state[LOADING] && state[LOADING_MODULE] === 'kanban',
|
loading: state => state[LOADING] && state[LOADING_MODULE] === 'kanban',
|
||||||
|
@ -424,9 +418,6 @@ export default {
|
||||||
const taskBefore = newBucket.tasks[e.newIndex - 1] ?? null
|
const taskBefore = newBucket.tasks[e.newIndex - 1] ?? null
|
||||||
const taskAfter = 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 = {
|
const newTask = {
|
||||||
...task,
|
...task,
|
||||||
bucketId: newBucket.id,
|
bucketId: newBucket.id,
|
||||||
|
@ -522,10 +513,13 @@ export default {
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
updateBucketPositions(buckets) {
|
updateBuckets(value) {
|
||||||
this.$store.dispatch('kanban/updateBuckets', buckets)
|
// (1) buckets get updated in store and tasks positions get invalidated
|
||||||
|
this.$store.commit('kanban/setBuckets', value)
|
||||||
},
|
},
|
||||||
|
|
||||||
updateBucketPosition(e) {
|
updateBucketPosition(e) {
|
||||||
|
// (2) bucket positon is changed
|
||||||
this.dragBucket = false
|
this.dragBucket = false
|
||||||
|
|
||||||
const bucket = this.buckets[e.newIndex]
|
const bucket = this.buckets[e.newIndex]
|
||||||
|
|
Loading…
Reference in a new issue