Enable dragging a bucket on task title

This commit is contained in:
kolaente 2021-07-28 20:33:19 +02:00
parent 6dc7d8f241
commit 66b6effe87
Signed by: konrad
GPG Key ID: F40E70337AB24C9B
1 changed files with 9 additions and 1 deletions

View File

@ -44,8 +44,9 @@
:ref="`bucket${bucket.id}title`"
@focusout="() => saveBucketTitle(bucket.id)"
@keydown.enter.prevent.stop="() => saveBucketTitle(bucket.id)"
@click="focusBucketTitle"
class="title input"
:contenteditable="canWrite && !collapsedBuckets[bucket.id]"
:contenteditable="bucketTitleEditable && canWrite && !collapsedBuckets[bucket.id]"
spellcheck="false">{{ bucket.title }}</h2>
<span
:class="{'is-max': bucket.tasks.length >= bucket.limit}"
@ -259,6 +260,7 @@ export default {
showBucketDeleteModal: false,
bucketToDelete: 0,
bucketTitleEditable: false,
newTaskText: '',
showNewTaskInput: {},
@ -454,7 +456,13 @@ export default {
this.showBucketDeleteModal = false
})
},
focusBucketTitle(e) {
// This little helper allows us to drag a bucket around at the title without focusing on it right away.
this.bucketTitleEditable = true
this.$nextTick(() => e.target.focus())
},
saveBucketTitle(bucketId) {
this.bucketTitleEditable = false
const bucketTitleElement = this.$refs[`bucket${bucketId}title`][0]
const bucketTitle = bucketTitleElement.textContent
const bucket = new BucketModel({