add new tag in transaction edit page / dialog

This commit is contained in:
MaysWind
2024-12-08 21:04:42 +08:00
parent db94282207
commit 5a9141e10c
6 changed files with 146 additions and 20 deletions
@@ -266,8 +266,8 @@
:label="$t('Tags')"
:placeholder="$t('None')"
:items="allTags"
:no-data-text="$t('No available tag')"
v-model="transaction.tagIds"
v-model:search="tagSearchContent"
>
<template #chip="{ props, item }">
<v-chip :prepend-icon="icons.tag" :text="item.title" v-bind="props"/>
@@ -285,6 +285,13 @@
</template>
</v-list-item>
</template>
<template #no-data>
<v-list class="py-0">
<v-list-item v-if="tagSearchContent" @click="saveNewTag(tagSearchContent)">{{ $t('format.misc.addNewTag', { tag: tagSearchContent }) }}</v-list-item>
<v-list-item v-else-if="!tagSearchContent">{{ $t('No available tag') }}</v-list-item>
</v-list>
</template>
</v-autocomplete>
</v-col>
<v-col cols="12" md="12">
@@ -458,6 +465,7 @@ export default {
transaction: newTransaction,
geoLocationStatus: null,
geoMenuState: false,
tagSearchContent: '',
submitting: false,
uploadingPicture: false,
removingPictureId: '',
@@ -1166,6 +1174,29 @@ export default {
this.geoLocationStatus = null;
this.transaction.geoLocation = null;
},
saveNewTag(tagName) {
const self = this;
self.submitting = true;
self.transactionTagsStore.saveTag({
tag: {
name: tagName
}
}).then(tag => {
self.submitting = false;
if (tag && tag.id) {
self.transaction.tagIds.push(tag.id);
}
}).catch(error => {
self.submitting = false;
if (!error.processed) {
self.$refs.snackbar.showError(error);
}
});
},
swapTransactionData(swapAccount, swapAmount) {
if (swapAccount) {
const oldSourceAccountId = this.transaction.sourceAccountId;
+1 -1
View File
@@ -313,7 +313,7 @@
:header="$t('Tags')"
@click="showTransactionTagSheet = true"
>
<transaction-tag-selection-sheet :items="allTags"
<transaction-tag-selection-sheet :allow-add-new-tag="true"
v-model:show="showTransactionTagSheet"
v-model="transaction.tagIds">
</transaction-tag-selection-sheet>