From 7094e05ddd44cd96d4683d9f9c9aff935fad79e9 Mon Sep 17 00:00:00 2001 From: Kristian Wind Date: Mon, 17 Aug 2026 22:35:40 +0200 Subject: [PATCH] feat(sidebar): drop a task on "I dag" MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit "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 --- web/e2e/smoke.spec.js | 8 +++++ web/src/lib/components/Sidebar.svelte | 43 ++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/web/e2e/smoke.spec.js b/web/e2e/smoke.spec.js index 8bad45c..cbfa9dd 100644 --- a/web/e2e/smoke.spec.js +++ b/web/e2e/smoke.spec.js @@ -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 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 // find a place among that project's tasks, and leave its old section behind. await row.dragTo(sidebar.getByRole('link', { name: 'Ærinder' })); diff --git a/web/src/lib/components/Sidebar.svelte b/web/src/lib/components/Sidebar.svelte index 4db0cba..0b0e54f 100644 --- a/web/src/lib/components/Sidebar.svelte +++ b/web/src/lib/components/Sidebar.svelte @@ -224,6 +224,34 @@ 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 ------------------------------------------------ /** The project row lit up because a task is hovering over it. */ @@ -306,7 +334,20 @@