mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-17 00:12:11 +08:00
support deleting all transactions (#202)
This commit is contained in:
@@ -114,39 +114,46 @@
|
||||
<span class="text-error">{{ tt('Danger Zone') }}</span>
|
||||
</template>
|
||||
|
||||
<v-form>
|
||||
<v-card-text class="py-0">
|
||||
<v-card-text class="py-0">
|
||||
<span class="text-body-1 text-error">
|
||||
<v-icon :icon="mdiAlert"/>
|
||||
{{ tt('You CANNOT undo this action. This will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.') }}
|
||||
<v-icon class="mt-n1" :icon="mdiAlert"/>
|
||||
{{ tt('You CANNOT undo this action. "Clear All Transactions" will clear all your transactions data, and "Clear All Data" will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.') }}
|
||||
</span>
|
||||
</v-card-text>
|
||||
</v-card-text>
|
||||
|
||||
<v-card-text class="pb-0">
|
||||
<v-row class="mb-3">
|
||||
<v-col cols="12" md="6">
|
||||
<v-text-field
|
||||
autocomplete="current-password"
|
||||
ref="currentPasswordInput"
|
||||
type="password"
|
||||
variant="underlined"
|
||||
color="error"
|
||||
:disabled="loadingDataStatistics || clearingData"
|
||||
:placeholder="tt('Current Password')"
|
||||
v-model="currentPasswordForClearData"
|
||||
@keyup.enter="clearData"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card-text>
|
||||
<v-card-text class="pb-0">
|
||||
<v-row class="mb-3">
|
||||
<v-col cols="12" md="6">
|
||||
<v-text-field
|
||||
autocomplete="current-password"
|
||||
ref="currentPasswordInput"
|
||||
type="password"
|
||||
variant="underlined"
|
||||
color="error"
|
||||
:disabled="loadingDataStatistics || clearingData"
|
||||
:placeholder="tt('Current Password')"
|
||||
v-model="currentPasswordForClearData"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card-text>
|
||||
|
||||
<v-card-text class="d-flex flex-wrap gap-4">
|
||||
<v-btn color="error" :disabled="loadingDataStatistics || !currentPasswordForClearData || clearingData" @click="clearData">
|
||||
{{ tt('Clear User Data') }}
|
||||
<v-progress-circular indeterminate size="22" class="ms-2" v-if="clearingData"></v-progress-circular>
|
||||
</v-btn>
|
||||
</v-card-text>
|
||||
</v-form>
|
||||
<v-card-text class="d-flex flex-wrap gap-4">
|
||||
<v-btn color="error" :disabled="loadingDataStatistics || !currentPasswordForClearData || clearingData">
|
||||
{{ tt('Clear User Data') }}
|
||||
<v-progress-circular indeterminate size="22" class="ms-2" v-if="clearingData"></v-progress-circular>
|
||||
<v-menu activator="parent">
|
||||
<v-list :disabled="loadingDataStatistics || !currentPasswordForClearData || clearingData">
|
||||
<v-list-item @click="clearAllTransactions">
|
||||
<v-list-item-title>{{ tt('Clear All Transactions') }}</v-list-item-title>
|
||||
</v-list-item>
|
||||
<v-list-item @click="clearAllData">
|
||||
<v-list-item-title>{{ tt('Clear All Data') }}</v-list-item-title>
|
||||
</v-list-item>
|
||||
</v-list>
|
||||
</v-menu>
|
||||
</v-btn>
|
||||
</v-card-text>
|
||||
</v-card>
|
||||
</v-col>
|
||||
</v-row>
|
||||
@@ -242,7 +249,38 @@ function exportData(fileType: string): void {
|
||||
});
|
||||
}
|
||||
|
||||
function clearData(): void {
|
||||
function clearAllTransactions(): void {
|
||||
if (!currentPasswordForClearData.value) {
|
||||
snackbar.value?.showMessage('Current password cannot be blank');
|
||||
return;
|
||||
}
|
||||
|
||||
if (clearingData.value) {
|
||||
return;
|
||||
}
|
||||
|
||||
confirmDialog.value?.open('Are you sure you want to clear all transactions?', { color: 'error' }).then(() => {
|
||||
clearingData.value = true;
|
||||
|
||||
rootStore.clearAllUserTransactions({
|
||||
password: currentPasswordForClearData.value
|
||||
}).then(() => {
|
||||
clearingData.value = false;
|
||||
currentPasswordForClearData.value = '';
|
||||
|
||||
snackbar.value?.showMessage('All transactions has been cleared');
|
||||
reloadUserDataStatistics(false);
|
||||
}).catch(error => {
|
||||
clearingData.value = false;
|
||||
|
||||
if (!error.processed) {
|
||||
snackbar.value?.showError(error);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
function clearAllData(): void {
|
||||
if (!currentPasswordForClearData.value) {
|
||||
snackbar.value?.showMessage('Current password cannot be blank');
|
||||
return;
|
||||
@@ -255,7 +293,7 @@ function clearData(): void {
|
||||
confirmDialog.value?.open('Are you sure you want to clear all data?', { color: 'error' }).then(() => {
|
||||
clearingData.value = true;
|
||||
|
||||
rootStore.clearUserData({
|
||||
rootStore.clearAllUserData({
|
||||
password: currentPasswordForClearData.value
|
||||
}).then(() => {
|
||||
clearingData.value = false;
|
||||
|
||||
@@ -26,7 +26,11 @@
|
||||
<f7-list-button :class="{ 'disabled': !dataStatistics || !dataStatistics.totalTransactionCount || dataStatistics.totalTransactionCount === '0' }"
|
||||
v-if="isDataExportingEnabled()"
|
||||
@click="exportedData = null; showExportDataSheet = true">{{ tt('Export Data') }}</f7-list-button>
|
||||
<f7-list-button color="red" @click="clearData(null)">{{ tt('Clear User Data') }}</f7-list-button>
|
||||
</f7-list>
|
||||
|
||||
<f7-list strong inset dividers class="margin-vertical" :class="{ 'disabled': loading }">
|
||||
<f7-list-button color="red" @click="clearAllTransactions(null)">{{ tt('Clear All Transactions') }}</f7-list-button>
|
||||
<f7-list-button color="red" @click="clearAllData(null)">{{ tt('Clear All Data') }}</f7-list-button>
|
||||
</f7-list>
|
||||
|
||||
<f7-sheet swipe-handler=".swipe-handler" style="height:auto"
|
||||
@@ -61,14 +65,24 @@
|
||||
</f7-page-content>
|
||||
</f7-sheet>
|
||||
|
||||
<password-input-sheet :title="tt('Are you sure you want to clear all transactions?')"
|
||||
:hint="tt('You CANNOT undo this action. This will clear your transactions data. Please enter your current password to confirm.')"
|
||||
:confirm-disabled="clearingData"
|
||||
:cancel-disabled="clearingData"
|
||||
color="red"
|
||||
v-model:show="showInputPasswordSheetForClearAllTransactions"
|
||||
v-model="currentPasswordForClearData"
|
||||
@password:confirm="clearAllTransactions">
|
||||
</password-input-sheet>
|
||||
|
||||
<password-input-sheet :title="tt('Are you sure you want to clear all data?')"
|
||||
:hint="tt('You CANNOT undo this action. This will clear your accounts, categories, tags and transactions data. Please enter your current password to confirm.')"
|
||||
:confirm-disabled="clearingData"
|
||||
:cancel-disabled="clearingData"
|
||||
color="red"
|
||||
v-model:show="showInputPasswordSheetForClearData"
|
||||
v-model:show="showInputPasswordSheetForClearAllData"
|
||||
v-model="currentPasswordForClearData"
|
||||
@password:confirm="clearData">
|
||||
@password:confirm="clearAllData">
|
||||
</password-input-sheet>
|
||||
</f7-page>
|
||||
</template>
|
||||
@@ -105,7 +119,8 @@ const exportedData = ref<string | null>(null);
|
||||
const currentPasswordForClearData = ref<string>('');
|
||||
const clearingData = ref<boolean>(false);
|
||||
const showExportDataSheet = ref<boolean>(false);
|
||||
const showInputPasswordSheetForClearData = ref<boolean>(false);
|
||||
const showInputPasswordSheetForClearAllTransactions = ref<boolean>(false);
|
||||
const showInputPasswordSheetForClearAllData = ref<boolean>(false);
|
||||
|
||||
const exportFileName = computed<string>(() => getExportFileName(exportFileType.value));
|
||||
|
||||
@@ -144,24 +159,55 @@ function exportData(): void {
|
||||
});
|
||||
}
|
||||
|
||||
function clearData(password: string | null): void {
|
||||
function clearAllTransactions(password: string | null): void {
|
||||
if (!password) {
|
||||
currentPasswordForClearData.value = '';
|
||||
showInputPasswordSheetForClearData.value = true;
|
||||
showInputPasswordSheetForClearAllTransactions.value = true;
|
||||
return;
|
||||
}
|
||||
|
||||
clearingData.value = true;
|
||||
showLoading(() => clearingData.value);
|
||||
|
||||
rootStore.clearUserData({
|
||||
rootStore.clearAllUserTransactions({
|
||||
password: password
|
||||
}).then(() => {
|
||||
clearingData.value = false;
|
||||
currentPasswordForClearData.value = '';
|
||||
hideLoading();
|
||||
|
||||
showInputPasswordSheetForClearData.value = false;
|
||||
showInputPasswordSheetForClearAllTransactions.value = false;
|
||||
showToast('All transactions has been cleared');
|
||||
|
||||
reloadUserDataStatistics();
|
||||
}).catch(error => {
|
||||
clearingData.value = false;
|
||||
hideLoading();
|
||||
|
||||
if (!error.processed) {
|
||||
showToast(error.message || error);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function clearAllData(password: string | null): void {
|
||||
if (!password) {
|
||||
currentPasswordForClearData.value = '';
|
||||
showInputPasswordSheetForClearAllData.value = true;
|
||||
return;
|
||||
}
|
||||
|
||||
clearingData.value = true;
|
||||
showLoading(() => clearingData.value);
|
||||
|
||||
rootStore.clearAllUserData({
|
||||
password: password
|
||||
}).then(() => {
|
||||
clearingData.value = false;
|
||||
currentPasswordForClearData.value = '';
|
||||
hideLoading();
|
||||
|
||||
showInputPasswordSheetForClearAllData.value = false;
|
||||
showToast('All user data has been cleared');
|
||||
|
||||
reloadUserDataStatistics();
|
||||
|
||||
Reference in New Issue
Block a user