From 34be883b704045c0b72e9306f37e80d762b08323 Mon Sep 17 00:00:00 2001 From: andrewlalis Date: Sun, 31 Aug 2025 20:59:09 -0400 Subject: [PATCH] Support null category descriptions. --- web-app/src/api/transaction.ts | 4 ++-- web-app/src/components/EditCategoryModal.vue | 13 ++++++++++--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/web-app/src/api/transaction.ts b/web-app/src/api/transaction.ts index 9c45165..363826b 100644 --- a/web-app/src/api/transaction.ts +++ b/web-app/src/api/transaction.ts @@ -17,7 +17,7 @@ export interface TransactionCategory { id: number parentId: number | null name: string - description: string + description: string | null color: string } @@ -135,7 +135,7 @@ export interface AddTransactionPayloadLineItem { export interface CreateCategoryPayload { name: string - description: string + description: string | null color: string parentId: number | null } diff --git a/web-app/src/components/EditCategoryModal.vue b/web-app/src/components/EditCategoryModal.vue index 32e0fac..4198e5d 100644 --- a/web-app/src/components/EditCategoryModal.vue +++ b/web-app/src/components/EditCategoryModal.vue @@ -29,7 +29,7 @@ function show(): Promise { description.value = props.category?.description ?? '' if (props.category) { name.value = props.category.name - description.value = props.category.description + description.value = props.category.description ?? "" color.value = '#' + props.category.color parentId.value = props.category.parentId } else { @@ -46,8 +46,11 @@ function canSave() { color.value.match('^#(([0-9a-fA-F]{2}){3}|([0-9a-fA-F]){3})$') if (!inputValid) return false if (props.category) { + const prevDescription = props.category.description?.trim() ?? "" + const currentDescription = description.value.trim() + const descriptionChanged = prevDescription !== currentDescription return props.category.name.trim() !== name.value.trim() || - props.category.description.trim() !== description.value.trim() || + descriptionChanged || props.category.color.trim().toLowerCase() !== color.value.trim().toLowerCase() || props.category.parentId !== parentId.value } @@ -56,9 +59,13 @@ function canSave() { async function doSave() { const api = new TransactionApiClient(getSelectedProfile(route)) + let desc: string | null = description.value.trim() + if (desc.length === 0) { + desc = null + } const payload = { name: name.value.trim(), - description: description.value.trim(), + description: desc, color: color.value.trim().substring(1), parentId: parentId.value }