mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 17:24:26 +08:00
highlight the save button when the explorer has been updated
This commit is contained in:
@@ -17,6 +17,7 @@ export const AMAP_JAVASCRIPT_URL: string = 'https://webapi.amap.com/maps?v=2.0';
|
|||||||
export enum KnownErrorCode {
|
export enum KnownErrorCode {
|
||||||
ApiNotFound = 100001,
|
ApiNotFound = 100001,
|
||||||
ValidatorError = 200000,
|
ValidatorError = 200000,
|
||||||
|
NothingWillBeUpdated = 200004,
|
||||||
UserEmailNotVerified = 201020,
|
UserEmailNotVerified = 201020,
|
||||||
TwoFactorAuthorizationPasscodeEmpty = 203005,
|
TwoFactorAuthorizationPasscodeEmpty = 203005,
|
||||||
TransactionCannotCreateInThisTime = 205017,
|
TransactionCannotCreateInThisTime = 205017,
|
||||||
|
|||||||
@@ -74,7 +74,9 @@
|
|||||||
<v-tooltip activator="parent">{{ tt('Refresh') }}</v-tooltip>
|
<v-tooltip activator="parent">{{ tt('Refresh') }}</v-tooltip>
|
||||||
</v-btn>
|
</v-btn>
|
||||||
<v-spacer/>
|
<v-spacer/>
|
||||||
<v-btn class="ms-3" color="default" variant="outlined"
|
<v-btn class="ms-3"
|
||||||
|
:color="isCurrentExplorerModified ? 'primary' : 'default'"
|
||||||
|
:variant="isCurrentExplorerModified ? 'elevated' : 'outlined'"
|
||||||
:disabled="loading || updating" @click="saveExplorer(false)">
|
:disabled="loading || updating" @click="saveExplorer(false)">
|
||||||
{{ tt('Save Explorer') }}
|
{{ tt('Save Explorer') }}
|
||||||
<v-progress-circular indeterminate size="22" class="ms-2" v-if="updating"></v-progress-circular>
|
<v-progress-circular indeterminate size="22" class="ms-2" v-if="updating"></v-progress-circular>
|
||||||
@@ -171,7 +173,7 @@ import ExplorerRenameDialog from '@/views/desktop/insights/dialogs/ExplorerRenam
|
|||||||
import EditDialog from '@/views/desktop/transactions/list/dialogs/EditDialog.vue';
|
import EditDialog from '@/views/desktop/transactions/list/dialogs/EditDialog.vue';
|
||||||
import ExportDialog from '@/views/desktop/statistics/transaction/dialogs/ExportDialog.vue';
|
import ExportDialog from '@/views/desktop/statistics/transaction/dialogs/ExportDialog.vue';
|
||||||
|
|
||||||
import { ref, computed, useTemplateRef, watch } from 'vue';
|
import { ref, computed, useTemplateRef, watch, nextTick } from 'vue';
|
||||||
import { useRouter, onBeforeRouteUpdate } from 'vue-router';
|
import { useRouter, onBeforeRouteUpdate } from 'vue-router';
|
||||||
import { useDisplay } from 'vuetify';
|
import { useDisplay } from 'vuetify';
|
||||||
|
|
||||||
@@ -187,6 +189,7 @@ import { type TransactionExplorerPartialFilter, type TransactionExplorerFilter,
|
|||||||
import type { TypeAndDisplayName } from '@/core/base.ts';
|
import type { TypeAndDisplayName } from '@/core/base.ts';
|
||||||
import { type WeekDayValue, type LocalizedDateRange, DateRangeScene, DateRange } from '@/core/datetime.ts';
|
import { type WeekDayValue, type LocalizedDateRange, DateRangeScene, DateRange } from '@/core/datetime.ts';
|
||||||
import { TimezoneTypeForStatistics } from '@/core/timezone.ts';
|
import { TimezoneTypeForStatistics } from '@/core/timezone.ts';
|
||||||
|
import { KnownErrorCode } from '@/consts/api.ts';
|
||||||
|
|
||||||
import { type TransactionInsightDataItem, Transaction } from '@/models/transaction.ts';
|
import { type TransactionInsightDataItem, Transaction } from '@/models/transaction.ts';
|
||||||
import { InsightsExplorerBasicInfo, InsightsExplorer } from '@/models/explorer.ts';
|
import { InsightsExplorerBasicInfo, InsightsExplorer } from '@/models/explorer.ts';
|
||||||
@@ -270,6 +273,7 @@ const loading = ref<boolean>(true);
|
|||||||
const initing = ref<boolean>(true);
|
const initing = ref<boolean>(true);
|
||||||
const updating = ref<boolean>(false);
|
const updating = ref<boolean>(false);
|
||||||
const clientSessionId = ref<string>('');
|
const clientSessionId = ref<string>('');
|
||||||
|
const isCurrentExplorerModified = ref<boolean>(false);
|
||||||
const alwaysShowNav = ref<boolean>(display.mdAndUp.value);
|
const alwaysShowNav = ref<boolean>(display.mdAndUp.value);
|
||||||
const showNav = ref<boolean>(display.mdAndUp.value);
|
const showNav = ref<boolean>(display.mdAndUp.value);
|
||||||
const activeTab = ref<ExplorerPageTabType>('query');
|
const activeTab = ref<ExplorerPageTabType>('query');
|
||||||
@@ -375,6 +379,7 @@ function init(initProps: InsightsExplorerProps): void {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
explorersStore.updateCurrentInsightsExplorer(InsightsExplorer.createNewExplorer(generateRandomUUID()));
|
explorersStore.updateCurrentInsightsExplorer(InsightsExplorer.createNewExplorer(generateRandomUUID()));
|
||||||
|
isCurrentExplorerModified.value = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!needReload && !explorersStore.transactionExplorerStateInvalid && !explorersStore.insightsExplorerListStateInvalid) {
|
if (!needReload && !explorersStore.transactionExplorerStateInvalid && !explorersStore.insightsExplorerListStateInvalid) {
|
||||||
@@ -429,6 +434,7 @@ function createNewExplorer(): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
explorersStore.updateCurrentInsightsExplorer(InsightsExplorer.createNewExplorer(generateRandomUUID()));
|
explorersStore.updateCurrentInsightsExplorer(InsightsExplorer.createNewExplorer(generateRandomUUID()));
|
||||||
|
isCurrentExplorerModified.value = true;
|
||||||
router.push(getFilterLinkUrl());
|
router.push(getFilterLinkUrl());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -443,6 +449,11 @@ function loadExplorer(explorerId: string): void {
|
|||||||
explorerId: explorerId
|
explorerId: explorerId
|
||||||
}).then(explorer => {
|
}).then(explorer => {
|
||||||
explorersStore.updateCurrentInsightsExplorer(explorer);
|
explorersStore.updateCurrentInsightsExplorer(explorer);
|
||||||
|
|
||||||
|
nextTick(() => {
|
||||||
|
isCurrentExplorerModified.value = false;
|
||||||
|
});
|
||||||
|
|
||||||
loading.value = false;
|
loading.value = false;
|
||||||
router.push(getFilterLinkUrl());
|
router.push(getFilterLinkUrl());
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
@@ -479,6 +490,10 @@ function doSaveExplorer(saveAs?: boolean): Promise<unknown> {
|
|||||||
clientSessionId.value = generateRandomUUID();
|
clientSessionId.value = generateRandomUUID();
|
||||||
explorersStore.updateCurrentInsightsExplorer(newExplorer);
|
explorersStore.updateCurrentInsightsExplorer(newExplorer);
|
||||||
|
|
||||||
|
nextTick(() => {
|
||||||
|
isCurrentExplorerModified.value = false;
|
||||||
|
});
|
||||||
|
|
||||||
if (oldExplorerId !== newExplorer.id) {
|
if (oldExplorerId !== newExplorer.id) {
|
||||||
router.push(getFilterLinkUrl());
|
router.push(getFilterLinkUrl());
|
||||||
}
|
}
|
||||||
@@ -487,6 +502,12 @@ function doSaveExplorer(saveAs?: boolean): Promise<unknown> {
|
|||||||
|
|
||||||
if (!error.processed) {
|
if (!error.processed) {
|
||||||
snackbar.value?.showError(error);
|
snackbar.value?.showError(error);
|
||||||
|
|
||||||
|
if (error.error && error.error.errorCode === KnownErrorCode.NothingWillBeUpdated) {
|
||||||
|
nextTick(() => {
|
||||||
|
isCurrentExplorerModified.value = false;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -506,6 +527,10 @@ function hideExplorer(hidden: boolean): void {
|
|||||||
}).then(() => {
|
}).then(() => {
|
||||||
updating.value = false;
|
updating.value = false;
|
||||||
currentExplorer.value.hidden = hidden;
|
currentExplorer.value.hidden = hidden;
|
||||||
|
|
||||||
|
nextTick(() => {
|
||||||
|
isCurrentExplorerModified.value = false;
|
||||||
|
});
|
||||||
}).catch(error => {
|
}).catch(error => {
|
||||||
updating.value = false;
|
updating.value = false;
|
||||||
|
|
||||||
@@ -670,5 +695,15 @@ watch(activeTab, () => {
|
|||||||
router.push(getFilterLinkUrl());
|
router.push(getFilterLinkUrl());
|
||||||
});
|
});
|
||||||
|
|
||||||
|
watch(currentExplorer, () => {
|
||||||
|
if (initing.value || loading.value) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
isCurrentExplorerModified.value = true;
|
||||||
|
}, {
|
||||||
|
deep: true
|
||||||
|
});
|
||||||
|
|
||||||
init(props);
|
init(props);
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
Reference in New Issue
Block a user