Added clickable category label.

This commit is contained in:
andrewlalis 2025-08-29 20:38:35 -04:00
parent 683d11a9a4
commit 50884c37c0
3 changed files with 59 additions and 31 deletions

View File

@ -148,8 +148,8 @@ CREATE TABLE account_value_record (
); );
CREATE TABLE account_value_record_attachment ( CREATE TABLE account_value_record_attachment (
value_record_id BIGINT NOT NULL, value_record_id INTEGER NOT NULL,
attachment_id BIGINT NOT NULL, attachment_id INTEGER NOT NULL,
PRIMARY KEY (value_record_id, attachment_id), PRIMARY KEY (value_record_id, attachment_id),
CONSTRAINT fk_account_value_record_attachment_value_record CONSTRAINT fk_account_value_record_attachment_value_record
FOREIGN KEY (value_record_id) REFERENCES account_value_record(id) FOREIGN KEY (value_record_id) REFERENCES account_value_record(id)
@ -161,20 +161,24 @@ CREATE TABLE account_value_record_attachment (
-- History Entities -- History Entities
CREATE TABLE history (
id INTEGER PRIMARY KEY
);
CREATE TABLE history_item ( CREATE TABLE history_item (
id INTEGER PRIMARY KEY, id INTEGER PRIMARY KEY,
history_id INTEGER NOT NULL, timestamp TEXT NOT NULL
timestamp TEXT NOT NULL, );
type TEXT NOT NULL,
CONSTRAINT fk_history_item_history CREATE TABLE account_history_item (
FOREIGN KEY (history_id) REFERENCES history(id) account_id INTEGER NOT NULL,
history_item_id INTEGER NOT NULL,
PRIMARY KEY (account_id, history_item_id),
CONSTRAINT fk_account_history_item_account
FOREIGN KEY (account_id) REFERENCES account(id)
ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT fk_account_history_item_history_item
FOREIGN KEY (history_item_id) REFERENCES history_item(id)
ON UPDATE CASCADE ON DELETE CASCADE ON UPDATE CASCADE ON DELETE CASCADE
); );
-- Zero or more plain text messages may be logged for any history item.
CREATE TABLE history_item_text ( CREATE TABLE history_item_text (
item_id INTEGER PRIMARY KEY, item_id INTEGER PRIMARY KEY,
content TEXT NOT NULL, content TEXT NOT NULL,
@ -183,26 +187,40 @@ CREATE TABLE history_item_text (
ON UPDATE CASCADE ON DELETE CASCADE ON UPDATE CASCADE ON DELETE CASCADE
); );
CREATE TABLE account_history ( -- Zero or more property changes may be logged for any history item.
account_id INTEGER NOT NULL UNIQUE, CREATE TABLE history_item_property_change (
history_id INTEGER NOT NULL, item_id INTEGER NOT NULL,
PRIMARY KEY (account_id, history_id), property_name TEXT NOT NULL,
CONSTRAINT fk_account_history_account old_value TEXT,
FOREIGN KEY (account_id) REFERENCES account(id) new_value TEXT,
ON UPDATE CASCADE ON DELETE CASCADE, PRIMARY KEY (item_id, property_name),
CONSTRAINT fk_account_history_history CONSTRAINT fk_history_item_property_change_item
FOREIGN KEY (history_id) REFERENCES history(id) FOREIGN KEY (item_id) REFERENCES history_item(id)
ON UPDATE CASCADE ON DELETE CASCADE ON UPDATE CASCADE ON DELETE CASCADE
); );
CREATE TABLE transaction_history ( -- Links a value record to a history item, used to include value records in an account's history.
transaction_id INTEGER NOT NULL UNIQUE, CREATE TABLE history_item_linked_value_record (
history_id INTEGER NOT NULL, item_id INTEGER NOT NULL,
PRIMARY KEY (transaction_id, history_id), value_record_id INTEGER NOT NULL,
CONSTRAINT fk_history_transaction_transaction PRIMARY KEY (item_id, value_record_id),
FOREIGN KEY (transaction_id) REFERENCES "transaction"(id) CONSTRAINT fk_history_item_linked_value_record_item
FOREIGN KEY (item_id) REFERENCES history_item(id)
ON UPDATE CASCADE ON DELETE CASCADE, ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT fk_history_transaction_history CONSTRAINT fk_history_item_linked_value_record_value_record
FOREIGN KEY (history_id) REFERENCES history(id) FOREIGN KEY (value_record_id) REFERENCES account_value_record(id)
ON UPDATE CASCADE ON DELETE CASCADE
);
-- Links a journal entry to a history item, used to include journal entries in an account's history.
CREATE TABLE history_item_linked_journal_entry (
item_id INTEGER NOT NULL,
journal_entry_id INTEGER NOT NULL,
PRIMARY KEY (item_id, journal_entry_id),
CONSTRAINT fk_history_item_linked_journal_entry_item
FOREIGN KEY (item_id) REFERENCES history_item(id)
ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT fk_history_item_linked_journal_entry_journal_entry
FOREIGN KEY (journal_entry_id) REFERENCES account_journal_entry(id)
ON UPDATE CASCADE ON DELETE CASCADE ON UPDATE CASCADE ON DELETE CASCADE
); );

View File

@ -1,10 +1,20 @@
<script setup lang="ts"> <script setup lang="ts">
import type { TransactionCategory } from '@/api/transaction'; import type { TransactionCategory } from '@/api/transaction';
import { useProfileStore } from '@/stores/profile-store';
import { useRouter } from 'vue-router';
defineProps<{ category: TransactionCategory }>() const router = useRouter()
const props = defineProps<{ category: TransactionCategory, clickable?: boolean }>()
function onClicked() {
if (props.clickable) {
const profileStore = useProfileStore()
router.push(`/profiles/${profileStore.state?.name}/categories`)
}
}
</script> </script>
<template> <template>
<span class="category-label"> <span class="category-label" @click="onClicked()" :style="{ 'cursor': clickable ? 'pointer' : 'default' }">
<div class="category-label-color" :style="{ 'background-color': '#' + category.color }"></div> <div class="category-label-color" :style="{ 'background-color': '#' + category.color }"></div>
{{ category.name }} {{ category.name }}
</span> </span>

View File

@ -72,7 +72,7 @@ async function deleteTransaction() {
<tr v-if="transaction.category"> <tr v-if="transaction.category">
<th>Category</th> <th>Category</th>
<td> <td>
<CategoryLabel :category="transaction.category" /> <CategoryLabel :category="transaction.category" :clickable="true" />
</td> </td>
</tr> </tr>
<tr v-if="transaction.creditedAccount"> <tr v-if="transaction.creditedAccount">