diff --git a/src/lib/api/appwrite/tasks.api.ts b/src/lib/api/appwrite/tasks.api.ts index 031d30c..8a2bae2 100644 --- a/src/lib/api/appwrite/tasks.api.ts +++ b/src/lib/api/appwrite/tasks.api.ts @@ -111,11 +111,13 @@ export const updateTaskTitle = async ( taskId: string, taskTitle: string, boardId: string, + prevStatusId: string, ): Promise => { try { await checkForBoardAccess(boardId); await db.updateDocument(KRELLO_DB_ID, TASK_COLLECTION_ID, taskId, { title: taskTitle, + prevStatusId, }); } catch (e: any) { console.error(e); @@ -127,11 +129,13 @@ export const updateTaskPriority = async ( taskId: string, priority: string, boardId: string, + prevStatusId: string, ): Promise => { try { await checkForBoardAccess(boardId); await db.updateDocument(KRELLO_DB_ID, TASK_COLLECTION_ID, taskId, { priority, + prevStatusId, }); } catch (e: any) { console.error(e); @@ -143,11 +147,13 @@ export const updateTaskDescription = async ( taskId: string, description: string, boardId: string, + prevStatusId: string, ): Promise => { try { await checkForBoardAccess(boardId); await db.updateDocument(KRELLO_DB_ID, TASK_COLLECTION_ID, taskId, { description, + prevStatusId, }); toast.success('Task description updated successfully'); } catch (e) { @@ -161,11 +167,13 @@ export const addLabelInTask = async ( newLabelId: string, labels: CardLabel[], boardId: string, + prevStatusId: string, ): Promise => { try { await checkForBoardAccess(boardId); await db.updateDocument(KRELLO_DB_ID, TASK_COLLECTION_ID, taskId, { labels: [...labels.map((label) => label.id), newLabelId], + prevStatusId, }); toast.success('Task updated successfully'); } catch (e) { @@ -179,11 +187,13 @@ export const removeLabelInTask = async ( removedLabelId: string, labels: CardLabel[], boardId: string, + prevStatusId: string, ): Promise => { try { await checkForBoardAccess(boardId); await db.updateDocument(KRELLO_DB_ID, TASK_COLLECTION_ID, taskId, { labels: labels.filter((oldLabel) => oldLabel.id !== removedLabelId).map((label) => label.id), + prevStatusId, }); toast.success('Task updated successfully'); } catch (e) { @@ -196,6 +206,7 @@ export const updateTaskCoverUrl = async ( taskDocId: string, cover: string | File, boardId: string, + prevStatusId: string, ): Promise => { await checkForBoardAccess(boardId); let coverUrl; @@ -207,6 +218,7 @@ export const updateTaskCoverUrl = async ( await db.updateDocument(KRELLO_DB_ID, TASK_COLLECTION_ID, taskDocId, { coverUrl, + prevStatusId, }); return coverUrl; }; diff --git a/src/lib/components/TaskDetails/TaskDetails.component.svelte b/src/lib/components/TaskDetails/TaskDetails.component.svelte index 2bef2e7..2f55055 100644 --- a/src/lib/components/TaskDetails/TaskDetails.component.svelte +++ b/src/lib/components/TaskDetails/TaskDetails.component.svelte @@ -1,10 +1,10 @@ @@ -98,7 +111,7 @@ {:else} -
- +
+
{/if} diff --git a/src/lib/components/TaskDetails/TaskPriority.component.svelte b/src/lib/components/TaskDetails/components/TaskPriority.component.svelte similarity index 82% rename from src/lib/components/TaskDetails/TaskPriority.component.svelte rename to src/lib/components/TaskDetails/components/TaskPriority.component.svelte index da58e4e..0a13ba7 100644 --- a/src/lib/components/TaskDetails/TaskPriority.component.svelte +++ b/src/lib/components/TaskDetails/components/TaskPriority.component.svelte @@ -3,12 +3,13 @@ import { updateTaskPriority } from '$lib/api/appwrite/tasks.api'; import boardStore from '$lib/store/boards.store'; import type { Board } from '$lib/types/board'; - import type { TaskPriority } from '$types/kanban'; + import type { Task } from '$types/kanban'; import { Select } from 'flowbite-svelte'; import { onDestroy } from 'svelte'; - export let taskId: string; - export let priority: TaskPriority | null; + export let taskDetails: Task; + + let priority = taskDetails.priority; let currentBoard: Board; const unsub = boardStore.subscribe((store) => { @@ -26,7 +27,7 @@ const hanldeChange = async (e: Event): Promise => { const target = e.target as HTMLSelectElement; - await updateTaskPriority(taskId, target.value, currentBoard.id); + await updateTaskPriority(taskDetails.id, target.value, currentBoard.id, taskDetails.status.id); }; diff --git a/src/lib/components/TaskDetails/TaskStatus.component.svelte b/src/lib/components/TaskDetails/components/TaskStatus.component.svelte similarity index 86% rename from src/lib/components/TaskDetails/TaskStatus.component.svelte rename to src/lib/components/TaskDetails/components/TaskStatus.component.svelte index 7cb6197..d2c4e93 100644 --- a/src/lib/components/TaskDetails/TaskStatus.component.svelte +++ b/src/lib/components/TaskDetails/components/TaskStatus.component.svelte @@ -3,11 +3,13 @@ import { kanbanStore } from '$lib/store'; import boardStore from '$lib/store/boards.store'; import type { Board } from '$lib/types/board'; - import type { TaskStatus } from '$types/kanban'; + import type { Task, TaskStatus } from '$types/kanban'; import { Select } from 'flowbite-svelte'; import { onDestroy } from 'svelte'; - export let taskId: string; - export let status: TaskStatus; + + export let taskDetails: Task; + let taskId: string = taskDetails.id; + let status: TaskStatus = taskDetails.status; let currentBoard: Board; diff --git a/src/lib/components/TaskDetails/TaskTitle.component.svelte b/src/lib/components/TaskDetails/components/TaskTitle.component.svelte similarity index 86% rename from src/lib/components/TaskDetails/TaskTitle.component.svelte rename to src/lib/components/TaskDetails/components/TaskTitle.component.svelte index e130a35..6e9de18 100644 --- a/src/lib/components/TaskDetails/TaskTitle.component.svelte +++ b/src/lib/components/TaskDetails/components/TaskTitle.component.svelte @@ -4,13 +4,18 @@ import { updateTaskTitle } from '$lib/api/appwrite/tasks.api'; import type { Board } from '$lib/types/board'; import boardStore from '$lib/store/boards.store'; + import type { Task } from '$lib/types/kanban'; - export let taskId: string, title: string; + export let taskDetails: Task; + + const taskId = taskDetails.id, + title = taskDetails.title; let currentBoard: Board; const unsub = boardStore.subscribe((store) => { currentBoard = store.currentBoard as Board; }); + onDestroy(unsub); let isEditing = false; @@ -47,7 +52,13 @@ const hanldeTaskTitleChange = (e: Event): void => { const target = e.target as HTMLInputElement; - const update = updateTaskTitle.bind(null, taskId, target.value, currentBoard.id); + const update = updateTaskTitle.bind( + null, + taskId, + target.value, + currentBoard.id, + taskDetails.status.id, + ); lodash.debounce(update, 100)(); }; diff --git a/src/lib/sass/markdown.module.scss b/src/lib/sass/markdown.module.scss index 5ea1837..751e615 100644 --- a/src/lib/sass/markdown.module.scss +++ b/src/lib/sass/markdown.module.scss @@ -12,7 +12,7 @@ /* Paragraph */ p { - margin: 1em 0; + line-height: 16px; } /* Links */ diff --git a/src/lib/store/kanbanBoard.store.ts b/src/lib/store/kanbanBoard.store.ts index 747ee02..4b0ec85 100644 --- a/src/lib/store/kanbanBoard.store.ts +++ b/src/lib/store/kanbanBoard.store.ts @@ -39,6 +39,7 @@ export const addNewTaskInStore = (newTask: Task): void => { }; export const updateTask = (updatedTask: Task): void => { + console.log('updateTask', updatedTask); kanbanStore.update((prevStore) => { const canUpdate = Object.hasOwn(prevStore.kanbanBoard, updatedTask.prevStatusId) &&