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')
|
||||
.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)
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -19,11 +19,11 @@
|
|||
:class="{ 'is-loading': loading && !oneTaskUpdating}"
|
||||
class="kanban kanban-bucket-container loader-container"
|
||||
>
|
||||
<!-- @end="updateBucketPosition" -->
|
||||
<draggable
|
||||
v-bind="dragOptions"
|
||||
:modelValue="buckets"
|
||||
@update:modelValue="updateBucketPositions"
|
||||
@update:modelValue="updateBuckets"
|
||||
@end="updateBucketPosition"
|
||||
@start="() => dragBucket = true"
|
||||
group="buckets"
|
||||
:disabled="!canWrite"
|
||||
|
@ -345,15 +345,9 @@ export default {
|
|||
],
|
||||
}
|
||||
},
|
||||
buckets: {
|
||||
get() {
|
||||
buckets() {
|
||||
return this.$store.state.kanban.buckets
|
||||
},
|
||||
set(value) {
|
||||
console.log('should not set buckets', value)
|
||||
this.$store.commit('kanban/setBuckets', value)
|
||||
},
|
||||
},
|
||||
...mapState({
|
||||
loadedListId: state => state.kanban.listId,
|
||||
loading: state => state[LOADING] && state[LOADING_MODULE] === 'kanban',
|
||||
|
@ -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]
|
||||
|
|
Loading…
Reference in a new issue