diff --git a/web-app/src/components/CategorySelect.vue b/web-app/src/components/CategorySelect.vue index 5417a1f..909aabf 100644 --- a/web-app/src/components/CategorySelect.vue +++ b/web-app/src/components/CategorySelect.vue @@ -1,18 +1,32 @@ - - - {{ ' '.repeat(4 * category.depth) + category.name }} - - - None - - + + + {{ ' '.repeat(option.value.depth * 4) }} {{ option.label }} + + diff --git a/web-app/src/pages/forms/EditTransactionPage.vue b/web-app/src/pages/forms/EditTransactionPage.vue index d9594b0..88dd7c7 100644 --- a/web-app/src/pages/forms/EditTransactionPage.vue +++ b/web-app/src/pages/forms/EditTransactionPage.vue @@ -45,7 +45,6 @@ const editing = computed(() => { return existingTransaction.value !== null || route.meta.title === 'Edit Transaction' }) const formValid = computed(() => { - console.log('Computing if for is valid...') return ( timestamp.value.length > 0 && amount.value > 0 && @@ -56,17 +55,18 @@ const formValid = computed(() => { ) }) const unsavedEdits = computed(() => { - console.log('Computing if there are unsaved edits...') + console.log("Checking if there are unsaved edits...") if (!existingTransaction.value) return true + const tx = existingTransaction.value const tagsEqual = - tags.value.every((t) => existingTransaction.value?.tags.includes(t)) && - existingTransaction.value.tags.every((t) => tags.value.includes(t)) + tags.value.every((t) => tx.tags.includes(t)) && + tx.tags.every((t) => tags.value.includes(t)) let lineItemsEqual = false - if (lineItems.value.length === existingTransaction.value.lineItems.length) { + if (lineItems.value.length === tx.lineItems.length) { lineItemsEqual = true for (let i = 0; i < lineItems.value.length; i++) { const i1 = lineItems.value[i] - const i2 = existingTransaction.value.lineItems[i] + const i2 = tx.lineItems[i] if ( i1.idx !== i2.idx || i1.quantity !== i2.quantity || @@ -81,17 +81,37 @@ const unsavedEdits = computed(() => { } const attachmentsChanged = attachmentsToUpload.value.length > 0 || removedAttachmentIds.value.length > 0 + const timestampChanged = new Date(timestamp.value).toISOString() !== tx.timestamp + const amountChanged = amount.value * Math.pow(10, currency.value?.fractionalDigits ?? 0) !== tx.amount + const currencyChanged = currency.value?.code !== tx.currency.code + const descriptionChanged = description.value !== tx.description + const vendorChanged = vendor.value?.id !== tx.vendor?.id + const categoryChanged = categoryId.value !== (tx.category?.id ?? null) + const creditedAccountChanged = creditedAccountId.value !== (tx.creditedAccount?.id ?? null) + const debitedAccountChanged = debitedAccountId.value !== (tx.debitedAccount?.id ?? null) + console.log(` + Timestamp changed: ${timestampChanged} + Amount changed: ${amountChanged} + Currency changed: ${currencyChanged} + Description changed: ${descriptionChanged} + Vendor changed: ${vendorChanged} + Category changed: ${categoryChanged} + Credited account changed: ${creditedAccountChanged} + Debited account changed: ${debitedAccountChanged} + Tags changed: ${!tagsEqual} + Line items changed: ${!lineItemsEqual} + Attachments changed: ${attachmentsChanged} + `) return ( - new Date(timestamp.value).toISOString() !== existingTransaction.value.timestamp || - amount.value * Math.pow(10, currency.value?.fractionalDigits ?? 0) !== - existingTransaction.value.amount || - currency.value !== existingTransaction.value.currency || - description.value !== existingTransaction.value.description || - (vendor.value?.id ?? null) !== (existingTransaction.value.vendor?.id ?? null) || - categoryId.value !== (existingTransaction.value.category?.id ?? null) || - creditedAccountId.value !== (existingTransaction.value.creditedAccount?.id ?? null) || - debitedAccountId.value !== (existingTransaction.value.debitedAccount?.id ?? null) || + timestampChanged || + amountChanged || + currencyChanged || + descriptionChanged || + vendorChanged || + categoryChanged || + creditedAccountChanged || + debitedAccountChanged || !tagsEqual || !lineItemsEqual || attachmentsChanged @@ -279,46 +299,20 @@ function getLocalDateTimeStringFromUTCTimestamp(timestamp: string) { - + - + - - + + {{ currency.code }} - - + + @@ -335,30 +329,16 @@ function getLocalDateTimeStringFromUTCTimestamp(timestamp: string) { - - + + {{ account.name }} ({{ account.numberSuffix }}) None - - + + {{ account.name }} ({{ account.numberSuffix }}) None @@ -366,44 +346,23 @@ function getLocalDateTimeStringFromUTCTimestamp(timestamp: string) { - + - tg !== t)" - /> + tg !== t)" /> - + {{ tag }} - - + + Add Tag @@ -412,18 +371,12 @@ function getLocalDateTimeStringFromUTCTimestamp(timestamp: string) { Attachments - + - +