feat(sidebar): drop a task on "I dag"
"Do it today" is the most-made rescheduling there is, and the sidebar is where the pointer already is when you have picked a task up. Only that one of the two date views. "Kommende" is a range rather than a day — it starts today and runs a week — so a drop on it would have to invent a date its own label does not name. The month grid inside it takes a drop per cell, which is where a specific day is actually on offer. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 5
parent
35d9e3bdac
commit
7094e05ddd
@@ -438,6 +438,14 @@ test('en opgave kan trækkes til en anden dag og videre til et projekt', async (
|
|||||||
await expect(day('I morgen').getByText('hent pakken')).toBeVisible();
|
await expect(day('I morgen').getByText('hent pakken')).toBeVisible();
|
||||||
await expect(day('I dag').getByText('hent pakken')).toBeHidden();
|
await expect(day('I dag').getByText('hent pakken')).toBeHidden();
|
||||||
|
|
||||||
|
// Onto "I dag" in the sidebar: the most-made rescheduling there is, and the
|
||||||
|
// sidebar is where the pointer already is. "Kommende" deliberately does not
|
||||||
|
// take one — it is a range, not a day, so a drop would have to invent a date
|
||||||
|
// its label does not name.
|
||||||
|
await row.dragTo(sidebar.getByRole('link', { name: 'I dag' }));
|
||||||
|
await expect(day('I dag').getByText('hent pakken')).toBeVisible();
|
||||||
|
await row.dragTo(day('I morgen'));
|
||||||
|
|
||||||
// And onto a project, which is a move rather than a field: the task has to
|
// And onto a project, which is a move rather than a field: the task has to
|
||||||
// find a place among that project's tasks, and leave its old section behind.
|
// find a place among that project's tasks, and leave its old section behind.
|
||||||
await row.dragTo(sidebar.getByRole('link', { name: 'Ærinder' }));
|
await row.dragTo(sidebar.getByRole('link', { name: 'Ærinder' }));
|
||||||
|
|||||||
@@ -224,6 +224,34 @@
|
|||||||
await app.reorderProjects(ordered.map((p) => p.id));
|
await app.reorderProjects(ordered.map((p) => p.id));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// --- a task dropped on "I dag" ---------------------------------------------------
|
||||||
|
|
||||||
|
/**
|
||||||
|
* "Gør det i dag" is the most-made rescheduling there is, and the sidebar is
|
||||||
|
* where the pointer already goes.
|
||||||
|
*
|
||||||
|
* Only this one of the two date views. "Kommende" is a range rather than a
|
||||||
|
* day — it starts today and runs a week — so a drop on it would have to invent
|
||||||
|
* a date the label does not name. The month grid inside it takes drops per
|
||||||
|
* cell, which is where a specific day is actually offered.
|
||||||
|
*/
|
||||||
|
let overToday = $state(false);
|
||||||
|
|
||||||
|
function todayISO() {
|
||||||
|
const now = new Date();
|
||||||
|
return `${now.getFullYear()}-${String(now.getMonth() + 1).padStart(2, '0')}-${String(
|
||||||
|
now.getDate()
|
||||||
|
).padStart(2, '0')}`;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function onDropOnToday(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
const id = dragged(event, TASK);
|
||||||
|
overToday = false;
|
||||||
|
if (!id) return;
|
||||||
|
await app.reschedule(id, todayISO());
|
||||||
|
}
|
||||||
|
|
||||||
// --- a task dropped on a project ------------------------------------------------
|
// --- a task dropped on a project ------------------------------------------------
|
||||||
|
|
||||||
/** The project row lit up because a task is hovering over it. */
|
/** The project row lit up because a task is hovering over it. */
|
||||||
@@ -306,7 +334,20 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="views">
|
<div class="views">
|
||||||
<a href="/" class:active={current === '/'} onclick={onnavigate}>
|
<!-- svelte-ignore a11y_no_static_element_interactions -->
|
||||||
|
<a
|
||||||
|
href="/"
|
||||||
|
class:active={current === '/'}
|
||||||
|
class:receiving={overToday}
|
||||||
|
onclick={onnavigate}
|
||||||
|
ondragover={(e) => {
|
||||||
|
if (!carries(e, TASK)) return;
|
||||||
|
accept(e);
|
||||||
|
overToday = true;
|
||||||
|
}}
|
||||||
|
ondragleave={() => (overToday = false)}
|
||||||
|
ondrop={onDropOnToday}
|
||||||
|
>
|
||||||
<span class="dot today" aria-hidden="true"></span>
|
<span class="dot today" aria-hidden="true"></span>
|
||||||
I dag
|
I dag
|
||||||
</a>
|
</a>
|
||||||
|
|||||||
Reference in New Issue
Block a user