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 @@
- + + { + if (!carries(e, TASK)) return; + accept(e); + overToday = true; + }} + ondragleave={() => (overToday = false)} + ondrop={onDropOnToday} + > I dag