From 91370b3e49a1f67c94dc42a5cad622a7b0fd1632 Mon Sep 17 00:00:00 2001 From: Nathan Arthur Date: Sun, 17 Nov 2024 14:00:52 -0500 Subject: [PATCH] work on copy functionality --- src/components/TaskAdd.svelte | 13 ++- src/components/list.svelte | 147 ++++++++++++++++++---------------- src/components/task.svelte | 26 ++++++ 3 files changed, 113 insertions(+), 73 deletions(-) diff --git a/src/components/TaskAdd.svelte b/src/components/TaskAdd.svelte index e226a93..f79177d 100644 --- a/src/components/TaskAdd.svelte +++ b/src/components/TaskAdd.svelte @@ -6,9 +6,16 @@ const dispatch = createEventDispatcher(); import { formatDue } from '../lib/formatDue'; export let isOpen = false; - - let task = ''; - let cents = 500; + export let task = ''; + export let cents = 500; + + $: if (isOpen) { + // Only reset values if not copying a task + if (!task) { + task = ''; + cents = 500; + } + } let due = getDefaultDue(); let error = ''; let success = ''; diff --git a/src/components/list.svelte b/src/components/list.svelte index e90c26f..cdaad50 100644 --- a/src/components/list.svelte +++ b/src/components/list.svelte @@ -1,100 +1,107 @@
-

{page === 'next' ? 'Next' : 'Archived'} Tasks

+

{page === 'next' ? 'Next' : 'Archived'} Tasks

{#if loading}
Loading tasks...
{/if} - +
- + - { const allTasks = (await getTasks()) as TaskType[]; const now = new Date(); const cutoff = new Date(now.getTime() - 24 * 60 * 60 * 1000); tasks = allTasks - .filter((task) => - page === 'next' - ? new Date(task.due) > cutoff - : new Date(task.due) <= cutoff + .filter((task) => + page === 'next' + ? new Date(task.due) > cutoff + : new Date(task.due) <= cutoff, ) .sort((a, b) => new Date(a.due).getTime() - new Date(b.due).getTime()); }} />