automatically save transaction draft

This commit is contained in:
MaysWind
2024-09-22 14:41:35 +08:00
parent 49df497f35
commit 4c13b7ad02
16 changed files with 384 additions and 26 deletions
@@ -145,6 +145,22 @@
<v-form>
<v-card-text>
<v-row>
<v-col cols="12" md="6">
<v-select
item-title="displayName"
item-value="value"
persistent-placeholder
:label="$t('Automatically Save Draft')"
:placeholder="$t('Automatically Save Draft')"
:items="[
{ value: 'disabled', displayName: $t('Disabled') },
{ value: 'enabled', displayName: $t('Enabled') },
{ value: 'confirmation', displayName: $t('Show Confirmation Every Time') }
]"
v-model="autoSaveTransactionDraft"
/>
</v-col>
<v-col cols="12" md="6">
<v-select
item-title="displayName"
@@ -275,6 +291,18 @@ export default {
this.settingsStore.setItemsCountInTransactionListPage(value);
}
},
autoSaveTransactionDraft: {
get: function () {
return this.settingsStore.appSettings.autoSaveTransactionDraft;
},
set: function (value) {
this.settingsStore.setAutoSaveTransactionDraft(value);
if (value === 'disabled') {
this.transactionsStore.clearTransactionDraft();
}
}
},
isAutoGetCurrentGeoLocation: {
get: function () {
return this.settingsStore.appSettings.autoGetCurrentGeoLocation;
@@ -64,6 +64,7 @@
import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/setting.js';
import { useUserStore } from '@/stores/user.js';
import { useTransactionsStore } from '@/stores/transaction.js';
import logger from '@/lib/logger.js';
import webauthn from '@/lib/webauthn.js';
@@ -77,7 +78,7 @@ export default {
};
},
computed: {
...mapStores(useSettingsStore, useUserStore),
...mapStores(useSettingsStore, useUserStore, useTransactionsStore),
isEnableApplicationLock: {
get: function () {
return this.settingsStore.appSettings.applicationLock;
@@ -168,6 +169,7 @@ export default {
this.$user.encryptToken(user.username, this.pinCode);
this.settingsStore.setEnableApplicationLock(true);
this.transactionsStore.saveTransactionDraft();
this.settingsStore.setEnableApplicationLockWebAuthn(false);
this.$user.clearWebAuthnConfig();
@@ -190,6 +192,7 @@ export default {
this.$user.decryptToken();
this.settingsStore.setEnableApplicationLock(false);
this.transactionsStore.saveTransactionDraft();
this.settingsStore.setEnableApplicationLockWebAuthn(false);
this.$user.clearWebAuthnConfig();