From e2e87ce9eca655b51c68a0efcc8356ed7347ff11 Mon Sep 17 00:00:00 2001 From: Bhasher Date: Wed, 3 Jan 2024 20:02:36 +0100 Subject: [PATCH] Bugfixes --- frontend/src/api/cards.ts | 44 ++++++++++++++++++- .../components/project/card/modal_card.svelte | 36 +++++++-------- frontend/src/components/project/column.svelte | 14 +++--- frontend/src/routes/+page.svelte | 19 +++++--- frontend/src/stores/config.ts | 2 +- frontend/src/stores/smallStore.ts | 9 +++- 6 files changed, 87 insertions(+), 37 deletions(-) diff --git a/frontend/src/api/cards.ts b/frontend/src/api/cards.ts index fc8819e..105969e 100644 --- a/frontend/src/api/cards.ts +++ b/frontend/src/api/cards.ts @@ -16,17 +16,38 @@ export async function newCardApi(projectId: number, tags: TagValue[]): Promise (tag.card_id = id)); + const consistant_tags = []; + + for (const tag of tags) { + if ((tag.option_id === -1 && tag.value == '') || tag.tag_id === -1) continue; + await createCardTagApi(id, tag.tag_id, tag.option_id, tag.value); + consistant_tags.push({ ...tag, card_id: id }); + } return { id: id, project_id: projectId, title: 'Untitled', content: '', - tags: tags + tags: consistant_tags }; } +export async function updateCardApi(card: Card): Promise { + const response = await api.put(`/v1/cards/${card.id}`, { + project_id: card.project_id, + title: card.title, + content: card.content + }); + + if (response.status !== status.NoContent) { + processError(response, 'Failed to update card'); + return false; + } + + return true; +} + export async function deleteCardApi(cardID: number): Promise { const response = await api.delete(`/v1/cards/${cardID}`); @@ -36,6 +57,25 @@ export async function deleteCardApi(cardID: number): Promise { } } +export async function createCardTagApi( + cardId: number, + tagId: number, + optionId: number, + value: string +): Promise { + const response = await api.post(`/v1/cards/${cardId}/tags/${tagId}`, { + option_id: optionId, + value: value + }); + + if (response.status !== status.Created) { + processError(response, 'Failed to create card tag'); + return false; + } + + return true; +} + export async function updateCardTagApi( cardID: number, tagID: number, diff --git a/frontend/src/components/project/card/modal_card.svelte b/frontend/src/components/project/card/modal_card.svelte index 8c2ffc6..99fa0b4 100644 --- a/frontend/src/components/project/card/modal_card.svelte +++ b/frontend/src/components/project/card/modal_card.svelte @@ -1,34 +1,28 @@