Support null category descriptions.
Build and Deploy Web App / build-and-deploy (push) Successful in 17s
Details
Build and Deploy Web App / build-and-deploy (push) Successful in 17s
Details
This commit is contained in:
parent
daec8fd050
commit
34be883b70
|
|
@ -17,7 +17,7 @@ export interface TransactionCategory {
|
||||||
id: number
|
id: number
|
||||||
parentId: number | null
|
parentId: number | null
|
||||||
name: string
|
name: string
|
||||||
description: string
|
description: string | null
|
||||||
color: string
|
color: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -135,7 +135,7 @@ export interface AddTransactionPayloadLineItem {
|
||||||
|
|
||||||
export interface CreateCategoryPayload {
|
export interface CreateCategoryPayload {
|
||||||
name: string
|
name: string
|
||||||
description: string
|
description: string | null
|
||||||
color: string
|
color: string
|
||||||
parentId: number | null
|
parentId: number | null
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -29,7 +29,7 @@ function show(): Promise<string | undefined> {
|
||||||
description.value = props.category?.description ?? ''
|
description.value = props.category?.description ?? ''
|
||||||
if (props.category) {
|
if (props.category) {
|
||||||
name.value = props.category.name
|
name.value = props.category.name
|
||||||
description.value = props.category.description
|
description.value = props.category.description ?? ""
|
||||||
color.value = '#' + props.category.color
|
color.value = '#' + props.category.color
|
||||||
parentId.value = props.category.parentId
|
parentId.value = props.category.parentId
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -46,8 +46,11 @@ function canSave() {
|
||||||
color.value.match('^#(([0-9a-fA-F]{2}){3}|([0-9a-fA-F]){3})$')
|
color.value.match('^#(([0-9a-fA-F]{2}){3}|([0-9a-fA-F]){3})$')
|
||||||
if (!inputValid) return false
|
if (!inputValid) return false
|
||||||
if (props.category) {
|
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() ||
|
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.color.trim().toLowerCase() !== color.value.trim().toLowerCase() ||
|
||||||
props.category.parentId !== parentId.value
|
props.category.parentId !== parentId.value
|
||||||
}
|
}
|
||||||
|
|
@ -56,9 +59,13 @@ function canSave() {
|
||||||
|
|
||||||
async function doSave() {
|
async function doSave() {
|
||||||
const api = new TransactionApiClient(getSelectedProfile(route))
|
const api = new TransactionApiClient(getSelectedProfile(route))
|
||||||
|
let desc: string | null = description.value.trim()
|
||||||
|
if (desc.length === 0) {
|
||||||
|
desc = null
|
||||||
|
}
|
||||||
const payload = {
|
const payload = {
|
||||||
name: name.value.trim(),
|
name: name.value.trim(),
|
||||||
description: description.value.trim(),
|
description: desc,
|
||||||
color: color.value.trim().substring(1),
|
color: color.value.trim().substring(1),
|
||||||
parentId: parentId.value
|
parentId: parentId.value
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue