Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
fivaz committed May 30, 2024
1 parent 8552d62 commit 7c2091d
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/routes/dashboard/tasks/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
<ul class="flex flex-col gap-3">
{#each sortedTasks as date (date)}
<TaskList
{date}
label={date}
on:edit={(e) => {
showForm = true;
editingTask = e.detail;
Expand Down
21 changes: 16 additions & 5 deletions src/routes/dashboard/tasks/task-list/TaskList.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,21 @@
import TaskRow from './task-row/TaskRow.svelte';
import { TASK_LIST_CLASS } from './task-row/service';
export let date: string;
export let label: string;
export let tasks: AnyTask[];
export let userId: string;
$: isDroppable = date !== GROUPS.Recurring && date !== GROUPS.Overdue;
$: isDroppable = label !== GROUPS.Recurring && label !== GROUPS.Overdue;
function getNumberOfTasks() {
if (tasks.length === 0) {
return '';
}
if (tasks.length === 1) {
return '(1 task)';
}
return `(${tasks.length} tasks)`;
}
</script>

<!--recurring and overdue list shouldn't be droppable-->
Expand All @@ -26,14 +36,15 @@
{:else}
<Icon class="h-5 w-5" src={Clipboard} />
{/if}
<div>{date}</div>
<div>{label}</div>
<div>{getNumberOfTasks()}</div>
</div>
<div>{getTotalDuration(tasks)}</div>
</div>
<ul class={clsx('flex flex-col gap-1', { [TASK_LIST_CLASS]: isDroppable })} data-date={date}>
<ul class={clsx('flex flex-col gap-1', { [TASK_LIST_CLASS]: isDroppable })} data-date={label}>
{#each tasks as task (task.id)}
<!--recurring tasks shouldn't be draggable-->
<TaskRow isDraggable={date !== GROUPS.Recurring} on:edit {task} {userId} />
<TaskRow isDraggable={label !== GROUPS.Recurring} on:edit {task} {userId} />
{/each}
{#if isDroppable}
<li
Expand Down

0 comments on commit 7c2091d

Please sign in to comment.