transaction edit dialog supports transaction tags

This commit is contained in:
MaysWind
2023-08-18 00:44:05 +08:00
parent db12b64b3a
commit 3095613a76
2 changed files with 50 additions and 6 deletions
+15
View File
@@ -59,6 +59,21 @@ export const useTransactionTagsStore = defineStore('transactionTags', {
allTransactionTagsMap: {}, allTransactionTagsMap: {},
transactionTagListStateInvalid: true, transactionTagListStateInvalid: true,
}), }),
getters: {
allVisibleTags(state) {
const allVisibleTags = [];
for (let i = 0; i < state.allTransactionTags.length; i++) {
const tag = state.allTransactionTags[i];
if (!tag.hidden) {
allVisibleTags.push(tag);
}
}
return allVisibleTags;
}
},
actions: { actions: {
generateNewTransactionTagModel() { generateNewTransactionTagModel() {
return { return {
@@ -208,11 +208,38 @@
</v-select> </v-select>
</v-col> </v-col>
<v-col cols="12" md="12"> <v-col cols="12" md="12">
<v-text-field <v-autocomplete
disabled item-title="name"
item-value="id"
auto-select-first
persistent-placeholder persistent-placeholder
multiple
chips
:closable-chips="mode !== 'view'"
:readonly="mode === 'view'"
:label="$t('Tags')" :label="$t('Tags')"
:placeholder="$t('Tags')" /> :placeholder="$t('None')"
:items="allTags"
:no-data-text="$t('No available tag')"
v-model="transaction.tagIds"
>
<template #chip="{ props, item }">
<v-chip :prepend-icon="icons.tag" :text="item.title" v-bind="props"/>
</template>
<template #item="{ props, item }">
<v-list-item :value="item.value" v-bind="props">
<template #title>
<v-list-item-title>
<div class="d-flex align-center">
<v-icon size="20" start :icon="icons.tag"/>
<span>{{ item.title }}</span>
</div>
</v-list-item-title>
</template>
</v-list-item>
</template>
</v-autocomplete>
</v-col> </v-col>
<v-col cols="12" md="12"> <v-col cols="12" md="12">
<v-textarea <v-textarea
@@ -290,7 +317,8 @@ import { getMapProvider } from '@/lib/server_settings.js';
import { import {
mdiDotsVertical, mdiDotsVertical,
mdiEyeOffOutline, mdiEyeOffOutline,
mdiEyeOutline mdiEyeOutline,
mdiPound
} from '@mdi/js'; } from '@mdi/js';
export default { export default {
@@ -320,7 +348,8 @@ export default {
icons: { icons: {
more: mdiDotsVertical, more: mdiDotsVertical,
show: mdiEyeOutline, show: mdiEyeOutline,
hide: mdiEyeOffOutline hide: mdiEyeOffOutline,
tag: mdiPound
} }
}; };
}, },
@@ -400,7 +429,7 @@ export default {
return this.transactionCategoriesStore.allTransactionCategoriesMap; return this.transactionCategoriesStore.allTransactionCategoriesMap;
}, },
allTags() { allTags() {
return this.transactionTagsStore.allTransactionTags; return this.transactionTagsStore.allVisibleTags;
}, },
hasAvailableExpenseCategories() { hasAvailableExpenseCategories() {
if (!this.allCategories || !this.allCategories[this.allCategoryTypes.Expense] || !this.allCategories[this.allCategoryTypes.Expense].length) { if (!this.allCategories || !this.allCategories[this.allCategoryTypes.Expense] || !this.allCategories[this.allCategoryTypes.Expense].length) {