feat: mark undone if task moved from isDoneBucket #3291
|
@ -415,6 +415,7 @@ async function updateTaskPosition(e) {
|
|||
: e.newIndex
|
||||
|
||||
const task = newBucket.tasks[newTaskIndex]
|
||||
const oldBucket = buckets.value.find(b => b.id === task.bucketId)
|
||||
const taskBefore = newBucket.tasks[newTaskIndex - 1] ?? null
|
||||
const taskAfter = newBucket.tasks[newTaskIndex + 1] ?? null
|
||||
taskUpdating.value[task.id] = true
|
||||
|
@ -425,6 +426,13 @@ async function updateTaskPosition(e) {
|
|||
taskBefore !== null ? taskBefore.kanbanPosition : null,
|
||||
taskAfter !== null ? taskAfter.kanbanPosition : null,
|
||||
)
|
||||
if (
|
||||
oldBucket != undefined && // This shouldn't actually be `undefined`, but let's play it safe.
|
||||
|
||||
newBucket.id !== oldBucket.id &&
|
||||
newBucket.isDoneBucket !== oldBucket.isDoneBucket
|
||||
) {
|
||||
newTask.done = newBucket.isDoneBucket
|
||||
}
|
||||
|
||||
try {
|
||||
await taskStore.update(newTask)
|
||||
|
|
Reference in New Issue
If I'm not wrong the
bucketId
could be0
. If that's the case we really should check forundefined
instead.Unless we can specify the reason for it being
0
I'm for keeping the comment. Makes it clear that we don't actually know it.Its the id of the default bucket. The comment is fine
By "default bucket" you mean a newly created
Bucket
instance, right? I don't think it's currently possible to move tasks from a bucket that hasn't been sent to the backend yet, is it?The default bucket is the leftmost bucket, where tasks are created (or moved to) when no bucket is specified.
IMU code is run when you drag a task between buckets or within a bucket, so the said task should always have
bucketId
set.Yeah in the frontend there should always be a bucket id set. What is was describing is the api behaviour.
By 'set' you mean 'some other value than
0
?My original intend here mostly was: I see it as bad style ff a possible value of a variable is
0
(which is true here, even if it might get replaced with something different shortly after). Because of that I thought:Might make sense here.
yes, exactly.
Yes, since the back-end can't have an actual bucket with an
id
of 0.Wait, are you saying that the value of
oldBucket
could be0
? No, it's either a bucket object, or undefined (the latter shouldn't happen). But ok, I'll update it to!= undefined
to covernull
andundefined
, but not 0.Even if you set it to
0
the api will set it to the default bucket.The initial set value in the frontend of
bucketId
is0
.So even if that might be replaced in the moment the API answers it currently is true for short period of time. If this is not wished, we should adjust the initial value in the model (e.g. as you said @WofWca to
undefined
).Note I talk here about the
bucketId
and not theoldBucket
. But since the latter is based on the former I thought not relying on implicit type conversion would be clearer.The
oldBucket
variable is the return value of thefind
function that is called on the array of bucket objects. Are you taking aboutoldBucket
ortask.bucketId
?Edit: saw the edit.
Either way, I don't care anymore :D This is way too much effort for way to few impact. Change as you wish ;)