fix could not select category name via checkbox in the batch create category dialog

This commit is contained in:
MaysWind
2025-09-09 23:22:58 +08:00
parent 7e2e1a4ad3
commit c75a902d84
@@ -41,7 +41,8 @@
v-for="item in invalidItems">
<template #prepend="{ isActive }">
<v-list-item-action start>
<v-checkbox-btn :model-value="isActive"></v-checkbox-btn>
<v-checkbox-btn :model-value="isActive"
@update:model-value="updateSelectedNames(item.name, $event)"></v-checkbox-btn>
</v-list-item-action>
</template>
</v-list-item>
@@ -115,6 +116,22 @@ const selectedNames = ref<string[]>([]);
let resolveFunc: ((response: BatchCreateDialogResponse) => void) | null = null;
let rejectFunc: ((reason?: unknown) => void) | null = null;
function updateSelectedNames(value: string, selected: boolean | null): void {
const newSelectedNames: string[] = [];
for (const name of selectedNames.value) {
if (name !== value || selected) {
newSelectedNames.push(name);
}
}
if (selected) {
newSelectedNames.push(value);
}
selectedNames.value = newSelectedNames;
}
function buildBatchCreateCategoryResponse(createdCategories: Record<number, TransactionCategory[]>): BatchCreateDialogResponse {
const displayNameSourceItemMap: Record<string, string> = {};
const sourceTargetMap: Record<string, string> = {};