From 7ecacaeb056d8aab3ff6be1894c7e412b32d789c Mon Sep 17 00:00:00 2001 From: MaysWind Date: Sat, 17 Jan 2026 18:48:45 +0800 Subject: [PATCH] support moving tags on mobile version --- src/stores/transactionTag.ts | 18 +++++-- src/views/mobile/tags/ListPage.vue | 79 ++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 4 deletions(-) diff --git a/src/stores/transactionTag.ts b/src/stores/transactionTag.ts index 0808dbea..2f958906 100644 --- a/src/stores/transactionTag.ts +++ b/src/stores/transactionTag.ts @@ -512,7 +512,7 @@ export const useTransactionTagsStore = defineStore('transactionTags', () => { }); } - function saveTag({ tag }: { tag: TransactionTag }): Promise { + function saveTag({ tag, beforeResolve }: { tag: TransactionTag, beforeResolve?: BeforeResolveFunction }): Promise { const oldTagGroupId = allTransactionTagsMap.value[tag.id]?.groupId; return new Promise((resolve, reject) => { @@ -538,10 +538,20 @@ export const useTransactionTagsStore = defineStore('transactionTags', () => { const transactionTag = TransactionTag.of(data.result); - if (!tag.id) { - addTagToTransactionTagList(transactionTag); + if (beforeResolve) { + beforeResolve(() => { + if (!tag.id) { + addTagToTransactionTagList(transactionTag); + } else { + updateTagInTransactionTagList(transactionTag, oldTagGroupId); + } + }); } else { - updateTagInTransactionTagList(transactionTag, oldTagGroupId); + if (!tag.id) { + addTagToTransactionTagList(transactionTag); + } else { + updateTagInTransactionTagList(transactionTag, oldTagGroupId); + } } resolve(transactionTag); diff --git a/src/views/mobile/tags/ListPage.vue b/src/views/mobile/tags/ListPage.vue index d5350415..22e5ef22 100644 --- a/src/views/mobile/tags/ListPage.vue +++ b/src/views/mobile/tags/ListPage.vue @@ -110,6 +110,7 @@ + @@ -148,6 +149,34 @@ + + + + + + + + + + + + + + + + + {{ tt('Sort') }} @@ -216,7 +245,10 @@ const transactionTagsStore = useTransactionTagsStore(); const loadingError = ref(null); const sortable = ref(false); +const moveToTagGroupId = ref(undefined); +const tagToMove = ref(null); const tagToDelete = ref(null); +const showMoveTagPopup = ref(false); const showMoreActionSheet = ref(false); const showDeleteActionSheet = ref(false); const displayOrderSaving = ref(false); @@ -333,6 +365,53 @@ function hide(tag: TransactionTag, hidden: boolean): void { }); } +function moveTagToGroup(tag: TransactionTag | null, targetTagGroupId?: string): void { + if (!tag) { + showAlert('An error occurred'); + return; + } + + if (!targetTagGroupId) { + moveToTagGroupId.value = undefined; + tagToMove.value = tag; + showMoveTagPopup.value = true; + return; + } + + showMoveTagPopup.value = false; + tagToMove.value = null; + moveToTagGroupId.value = undefined; + showLoading(); + + const newTag = tag.clone(); + newTag.groupId = targetTagGroupId; + + transactionTagsStore.saveTag({ + tag: newTag, + beforeResolve: (done) => { + onSwipeoutDeleted(getTagDomId(tag), done); + } + }).then(() => { + hideLoading(); + }).catch(error => { + hideLoading(); + + if (!error.processed) { + showToast(error.message || error); + } + }); +} + +function updateTagGroupSelected(e: Event): void { + const target = e.target as HTMLInputElement; + + if (target.checked) { + moveToTagGroupId.value = target.value; + } else { + moveToTagGroupId.value = undefined; + } +} + function remove(tag: TransactionTag | null, confirm: boolean): void { if (!tag) { showAlert('An error occurred');