From 7849b2f05cfd2f81f2cd315675393d8e915ad8df Mon Sep 17 00:00:00 2001 From: MaysWind Date: Sun, 14 Jul 2024 19:55:14 +0800 Subject: [PATCH] update url address when changing the settings on the statistics analysis page --- src/consts/datetime.js | 22 + src/consts/statistics.js | 15 + src/lib/common.js | 10 +- src/router/desktop.js | 13 +- src/stores/statistics.js | 251 +++++---- .../cards/AccountFilterSettingsCard.vue | 6 +- .../cards/CategoryFilterSettingsCard.vue | 6 +- .../desktop/statistics/TransactionPage.vue | 502 ++++++++++++------ .../mobile/statistics/TransactionPage.vue | 2 +- 9 files changed, 558 insertions(+), 269 deletions(-) diff --git a/src/consts/datetime.js b/src/consts/datetime.js index 37903e96..a1958f90 100644 --- a/src/consts/datetime.js +++ b/src/consts/datetime.js @@ -304,6 +304,27 @@ const allDateRanges = { } }; +const allDateRangesMap = { + [allDateRanges.All.type]: allDateRanges.All, + [allDateRanges.Today.type]: allDateRanges.Today, + [allDateRanges.Yesterday.type]: allDateRanges.Yesterday, + [allDateRanges.LastSevenDays.type]: allDateRanges.LastSevenDays, + [allDateRanges.LastThirtyDays.type]: allDateRanges.LastThirtyDays, + [allDateRanges.ThisWeek.type]: allDateRanges.ThisWeek, + [allDateRanges.LastWeek.type]: allDateRanges.LastWeek, + [allDateRanges.ThisMonth.type]: allDateRanges.ThisMonth, + [allDateRanges.LastMonth.type]: allDateRanges.LastMonth, + [allDateRanges.ThisYear.type]: allDateRanges.ThisYear, + [allDateRanges.LastYear.type]: allDateRanges.LastYear, + [allDateRanges.RecentTwelveMonths.type]: allDateRanges.RecentTwelveMonths, + [allDateRanges.RecentTwentyFourMonths.type]: allDateRanges.RecentTwentyFourMonths, + [allDateRanges.RecentThirtySixMonths.type]: allDateRanges.RecentThirtySixMonths, + [allDateRanges.RecentTwoYears.type]: allDateRanges.RecentTwoYears, + [allDateRanges.RecentThreeYears.type]: allDateRanges.RecentThreeYears, + [allDateRanges.RecentFiveYears.type]: allDateRanges.RecentFiveYears, + [allDateRanges.Custom.type]: allDateRanges.Custom +}; + const defaultFirstDayOfWeek = allWeekDays.Sunday.type; const defaultLongDateFormat = allLongDateFormat.YYYYMMDD; const defaultShortDateFormat = allShortDateFormat.YYYYMMDD; @@ -327,6 +348,7 @@ export default { allShortTimeFormatArray: allShortTimeFormatArray, allDateRangeScenes: allDateRangeScenes, allDateRanges: allDateRanges, + allDateRangesMap: allDateRangesMap, defaultFirstDayOfWeek: defaultFirstDayOfWeek, defaultLongDateFormat: defaultLongDateFormat, defaultShortDateFormat: defaultShortDateFormat, diff --git a/src/consts/statistics.js b/src/consts/statistics.js index 662899ee..81be2a44 100644 --- a/src/consts/statistics.js +++ b/src/consts/statistics.js @@ -127,6 +127,20 @@ const allChartDataTypes = { } }; +const allChartDataTypesMap = { + [allChartDataTypes.ExpenseByAccount.type]: allChartDataTypes.ExpenseByAccount, + [allChartDataTypes.ExpenseByPrimaryCategory.type]: allChartDataTypes.ExpenseByPrimaryCategory, + [allChartDataTypes.ExpenseBySecondaryCategory.type]: allChartDataTypes.ExpenseBySecondaryCategory, + [allChartDataTypes.IncomeByAccount.type]: allChartDataTypes.IncomeByAccount, + [allChartDataTypes.IncomeByPrimaryCategory.type]: allChartDataTypes.IncomeByPrimaryCategory, + [allChartDataTypes.IncomeBySecondaryCategory.type]: allChartDataTypes.IncomeBySecondaryCategory, + [allChartDataTypes.AccountTotalAssets.type]: allChartDataTypes.AccountTotalAssets, + [allChartDataTypes.AccountTotalLiabilities.type]: allChartDataTypes.AccountTotalLiabilities, + [allChartDataTypes.TotalExpense.type]: allChartDataTypes.TotalExpense, + [allChartDataTypes.TotalIncome.type]: allChartDataTypes.TotalIncome, + [allChartDataTypes.TotalBalance.type]: allChartDataTypes.TotalBalance +}; + const defaultChartDataType = allChartDataTypes.ExpenseByPrimaryCategory.type; const allSortingTypes = { @@ -164,6 +178,7 @@ export default { allTrendChartTypesArray: allTrendChartTypesArray, defaultTrendChartType: defaultTrendChartType, allChartDataTypes: allChartDataTypes, + allChartDataTypesMap: allChartDataTypesMap, defaultChartDataType: defaultChartDataType, defaultCategoricalChartDataRangeType: datetime.allDateRanges.ThisMonth.type, defaultTrendChartDataRangeType: datetime.allDateRanges.ThisYear.type, diff --git a/src/lib/common.js b/src/lib/common.js index 4025408a..94dd3396 100644 --- a/src/lib/common.js +++ b/src/lib/common.js @@ -2,6 +2,10 @@ export function isFunction(val) { return typeof(val) === 'function'; } +export function isDefined(val) { + return typeof val !== 'undefined'; +} + export function isObject(val) { return val != null && typeof(val) === 'object' && !isArray(val); } @@ -22,6 +26,10 @@ export function isNumber(val) { return typeof(val) === 'number'; } +export function isInteger(val) { + return Number.isInteger(val); +} + export function isBoolean(val) { return typeof(val) === 'boolean'; } @@ -375,7 +383,7 @@ export function arrayContainsFieldValue(array, fieldName, value) { return false; } -export function objectToArray(object) { +export function objectFieldToArrayItem(object) { const ret = []; for (let field in object) { diff --git a/src/router/desktop.js b/src/router/desktop.js index 2127496e..d0a2091b 100644 --- a/src/router/desktop.js +++ b/src/router/desktop.js @@ -107,7 +107,18 @@ const router = createRouter({ { path: '/statistics/transaction', component: StatisticsTransactionPage, - beforeEnter: checkLogin + beforeEnter: checkLogin, + props: route => ({ + initAnalysisType: route.query.analysisType, + initChartDataType: route.query.chartDataType, + initChartType: route.query.chartType, + initChartDateType: route.query.chartDateType, + initStartTime: route.query.startTime, + initEndTime: route.query.endTime, + initFilterAccountIds: route.query.filterAccountIds, + initFilterCategoryIds: route.query.filterCategoryIds, + initSortingType: route.query.sortingType + }) }, { path: '/account/list', diff --git a/src/stores/statistics.js b/src/stores/statistics.js index 0ab845cd..9859a1c6 100644 --- a/src/stores/statistics.js +++ b/src/stores/statistics.js @@ -17,8 +17,10 @@ import { isEquals, isNumber, isObject, + isInteger, isYearMonth, - isObjectEmpty + isObjectEmpty, + objectFieldToArrayItem } from '@/lib/common.js'; import { getYearAndMonthFromUnixTime, @@ -561,186 +563,239 @@ export const useStatisticsStore = defineStore('statistics', { this.transactionCategoryTrendsData = {}; this.transactionStatisticsStateInvalid = true; }, - initTransactionStatisticsFilter(filter) { - if (!filter) { - const settingsStore = useSettingsStore(); - const userStore = useUserStore(); + initTransactionStatisticsFilter(analysisType, filter) { + const settingsStore = useSettingsStore(); + const userStore = useUserStore(); - let defaultChartDataType = settingsStore.appSettings.statistics.defaultChartDataType; - - if (defaultChartDataType < statisticsConstants.allChartDataTypes.ExpenseByAccount.type || defaultChartDataType > statisticsConstants.allChartDataTypes.AccountTotalLiabilities.type) { - defaultChartDataType = statisticsConstants.defaultChartDataType; - } - - let defaultCategoricalChartType = settingsStore.appSettings.statistics.defaultCategoricalChartType; - - if (defaultCategoricalChartType !== statisticsConstants.allCategoricalChartTypes.Pie && defaultCategoricalChartType !== statisticsConstants.allCategoricalChartTypes.Bar) { - defaultCategoricalChartType = statisticsConstants.defaultCategoricalChartType; - } - - let defaultCategoricalChartDateRange = settingsStore.appSettings.statistics.defaultCategoricalChartDataRangeType; - - if (defaultCategoricalChartDateRange < datetimeConstants.allDateRanges.All.type || defaultCategoricalChartDateRange >= datetimeConstants.allDateRanges.Custom.type) { - defaultCategoricalChartDateRange = statisticsConstants.defaultCategoricalChartDataRangeType; - } - - let defaultTrendChartType = settingsStore.appSettings.statistics.defaultTrendChartType; - - if (defaultTrendChartType !== statisticsConstants.allTrendChartTypes.Area && defaultTrendChartType !== statisticsConstants.allTrendChartTypes.Column) { - defaultTrendChartType = statisticsConstants.defaultTrendChartType; - } - - let defaultTrendChartDateRange = settingsStore.appSettings.statistics.defaultTrendChartDataRangeType; - - if (defaultTrendChartDateRange < datetimeConstants.allDateRanges.All.type || defaultTrendChartDateRange >= datetimeConstants.allDateRanges.Custom.type) { - defaultTrendChartDateRange = statisticsConstants.defaultTrendChartDataRangeType; - } - - let defaultSortType = settingsStore.appSettings.statistics.defaultSortingType; - - if (defaultSortType < statisticsConstants.allSortingTypes.Amount.type || defaultSortType > statisticsConstants.allSortingTypes.Name.type) { - defaultSortType = statisticsConstants.defaultSortingType; - } - - const categoricalChartDateRange = getDateRangeByDateType(defaultCategoricalChartDateRange, userStore.currentUserFirstDayOfWeek); - const trendChartDateRange = getDateRangeByDateType(defaultTrendChartDateRange, userStore.currentUserFirstDayOfWeek); - - filter = { - chartDataType: defaultChartDataType, - categoricalChartType: defaultCategoricalChartType, - categoricalChartDateType: categoricalChartDateRange ? categoricalChartDateRange.dateType : undefined, - categoricalChartStartTime: categoricalChartDateRange ? categoricalChartDateRange.minTime : undefined, - categoricalChartEndTime: categoricalChartDateRange ? categoricalChartDateRange.maxTime : undefined, - trendChartType: defaultTrendChartType, - trendChartDateType: trendChartDateRange ? trendChartDateRange.dateType : undefined, - trendChartStartYearMonth: trendChartDateRange ? getYearAndMonthFromUnixTime(trendChartDateRange.minTime) : undefined, - trendChartEndYearMonth: trendChartDateRange ? getYearAndMonthFromUnixTime(trendChartDateRange.maxTime) : undefined, - filterAccountIds: settingsStore.appSettings.statistics.defaultAccountFilter || {}, - filterCategoryIds: settingsStore.appSettings.statistics.defaultTransactionCategoryFilter || {}, - sortingType: defaultSortType, - }; - } - - if (filter && isNumber(filter.chartDataType)) { + if (filter && isInteger(filter.chartDataType)) { this.transactionStatisticsFilter.chartDataType = filter.chartDataType; } else { - this.transactionStatisticsFilter.chartDataType = statisticsConstants.defaultChartDataType; + this.transactionStatisticsFilter.chartDataType = settingsStore.appSettings.statistics.defaultChartDataType; } - if (filter && isNumber(filter.categoricalChartType)) { + if (analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis || analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) { + if (!statisticsConstants.allChartDataTypesMap[this.transactionStatisticsFilter.chartDataType] || + !statisticsConstants.allChartDataTypesMap[this.transactionStatisticsFilter.chartDataType].availableAnalysisTypes[analysisType]) { + this.transactionStatisticsFilter.chartDataType = statisticsConstants.defaultChartDataType; + } + } + + if (filter && isInteger(filter.categoricalChartType)) { this.transactionStatisticsFilter.categoricalChartType = filter.categoricalChartType; } else { + this.transactionStatisticsFilter.categoricalChartType = settingsStore.appSettings.statistics.defaultCategoricalChartType; + } + + if (this.transactionStatisticsFilter.categoricalChartType !== statisticsConstants.allCategoricalChartTypes.Pie && this.transactionStatisticsFilter.categoricalChartType !== statisticsConstants.allCategoricalChartTypes.Bar) { this.transactionStatisticsFilter.categoricalChartType = statisticsConstants.defaultCategoricalChartType; } - if (filter && isNumber(filter.categoricalChartDateType)) { + if (filter && isInteger(filter.categoricalChartDateType)) { this.transactionStatisticsFilter.categoricalChartDateType = filter.categoricalChartDateType; } else { + this.transactionStatisticsFilter.categoricalChartDateType = settingsStore.appSettings.statistics.defaultCategoricalChartDataRangeType; + } + + let categoricalChartDateTypeValid = true; + + if (!datetimeConstants.allDateRangesMap[this.transactionStatisticsFilter.categoricalChartDateType] || + !datetimeConstants.allDateRangesMap[this.transactionStatisticsFilter.categoricalChartDateType].availableScenes[datetimeConstants.allDateRangeScenes.Normal]) { this.transactionStatisticsFilter.categoricalChartDateType = statisticsConstants.defaultCategoricalChartDataRangeType; + categoricalChartDateTypeValid = false; } - if (filter && isNumber(filter.categoricalChartStartTime)) { - this.transactionStatisticsFilter.categoricalChartStartTime = filter.categoricalChartStartTime; + if (categoricalChartDateTypeValid && this.transactionStatisticsFilter.categoricalChartDateType === datetimeConstants.allDateRanges.Custom.type) { + if (filter && isInteger(filter.categoricalChartStartTime)) { + this.transactionStatisticsFilter.categoricalChartStartTime = filter.categoricalChartStartTime; + } else { + this.transactionStatisticsFilter.categoricalChartStartTime = 0; + } + + if (filter && isInteger(filter.categoricalChartEndTime)) { + this.transactionStatisticsFilter.categoricalChartEndTime = filter.categoricalChartEndTime; + } else { + this.transactionStatisticsFilter.categoricalChartEndTime = 0; + } } else { - this.transactionStatisticsFilter.categoricalChartStartTime = 0; + const categoricalChartDateRange = getDateRangeByDateType(this.transactionStatisticsFilter.categoricalChartDateType, userStore.currentUserFirstDayOfWeek); + this.transactionStatisticsFilter.categoricalChartDateType = categoricalChartDateRange.dateType; + this.transactionStatisticsFilter.categoricalChartStartTime = categoricalChartDateRange.minTime; + this.transactionStatisticsFilter.categoricalChartEndTime = categoricalChartDateRange.maxTime; } - if (filter && isNumber(filter.categoricalChartEndTime)) { - this.transactionStatisticsFilter.categoricalChartEndTime = filter.categoricalChartEndTime; - } else { - this.transactionStatisticsFilter.categoricalChartEndTime = 0; - } - - if (filter && isNumber(filter.trendChartType)) { + if (filter && isInteger(filter.trendChartType)) { this.transactionStatisticsFilter.trendChartType = filter.trendChartType; } else { + this.transactionStatisticsFilter.trendChartType = settingsStore.appSettings.statistics.defaultTrendChartType; + } + + if (this.transactionStatisticsFilter.trendChartType !== statisticsConstants.allTrendChartTypes.Area && this.transactionStatisticsFilter.trendChartType !== statisticsConstants.allTrendChartTypes.Column) { this.transactionStatisticsFilter.trendChartType = statisticsConstants.defaultTrendChartType; } - if (filter && isNumber(filter.trendChartDateType)) { + if (filter && isInteger(filter.trendChartDateType)) { this.transactionStatisticsFilter.trendChartDateType = filter.trendChartDateType; } else { + this.transactionStatisticsFilter.trendChartDateType = settingsStore.appSettings.statistics.defaultTrendChartDataRangeType; + } + + let trendChartDateTypeValid = true; + + if (!datetimeConstants.allDateRangesMap[this.transactionStatisticsFilter.trendChartDateType] || + !datetimeConstants.allDateRangesMap[this.transactionStatisticsFilter.trendChartDateType].availableScenes[datetimeConstants.allDateRangeScenes.TrendAnalysis]) { this.transactionStatisticsFilter.trendChartDateType = statisticsConstants.defaultTrendChartDataRangeType; + trendChartDateTypeValid = false; } - if (filter && isYearMonth(filter.trendChartStartYearMonth)) { - this.transactionStatisticsFilter.trendChartStartYearMonth = filter.trendChartStartYearMonth; - } else { - this.transactionStatisticsFilter.trendChartStartYearMonth = ''; - } + if (trendChartDateTypeValid && this.transactionStatisticsFilter.trendChartDateType === datetimeConstants.allDateRanges.Custom.type) { + if (filter && isYearMonth(filter.trendChartStartYearMonth)) { + this.transactionStatisticsFilter.trendChartStartYearMonth = filter.trendChartStartYearMonth; + } else { + this.transactionStatisticsFilter.trendChartStartYearMonth = ''; + } - if (filter && isYearMonth(filter.trendChartEndYearMonth)) { - this.transactionStatisticsFilter.trendChartEndYearMonth = filter.trendChartEndYearMonth; + if (filter && isYearMonth(filter.trendChartEndYearMonth)) { + this.transactionStatisticsFilter.trendChartEndYearMonth = filter.trendChartEndYearMonth; + } else { + this.transactionStatisticsFilter.trendChartEndYearMonth = ''; + } } else { - this.transactionStatisticsFilter.trendChartEndYearMonth = ''; + const trendChartDateRange = getDateRangeByDateType(this.transactionStatisticsFilter.trendChartDateType, userStore.currentUserFirstDayOfWeek); + this.transactionStatisticsFilter.trendChartDateType = trendChartDateRange.dateType; + this.transactionStatisticsFilter.trendChartStartYearMonth = getYearAndMonthFromUnixTime(trendChartDateRange.minTime); + this.transactionStatisticsFilter.trendChartEndYearMonth = getYearAndMonthFromUnixTime(trendChartDateRange.maxTime); } if (filter && isObject(filter.filterAccountIds)) { this.transactionStatisticsFilter.filterAccountIds = filter.filterAccountIds; } else { - this.transactionStatisticsFilter.filterAccountIds = {}; + this.transactionStatisticsFilter.filterAccountIds = settingsStore.appSettings.statistics.defaultAccountFilter || {}; } if (filter && isObject(filter.filterCategoryIds)) { this.transactionStatisticsFilter.filterCategoryIds = filter.filterCategoryIds; } else { - this.transactionStatisticsFilter.filterCategoryIds = {}; + this.transactionStatisticsFilter.filterCategoryIds = settingsStore.appSettings.statistics.defaultTransactionCategoryFilter || {}; } - if (filter && isNumber(filter.sortingType)) { + if (filter && isInteger(filter.sortingType)) { this.transactionStatisticsFilter.sortingType = filter.sortingType; } else { + this.transactionStatisticsFilter.sortingType = settingsStore.appSettings.statistics.defaultSortingType; + } + + if (this.transactionStatisticsFilter.sortingType < statisticsConstants.allSortingTypes.Amount.type || this.transactionStatisticsFilter.sortingType > statisticsConstants.allSortingTypes.Name.type) { this.transactionStatisticsFilter.sortingType = statisticsConstants.defaultSortingType; } }, updateTransactionStatisticsFilter(filter) { - if (filter && isNumber(filter.chartDataType)) { + let changed = false; + + if (filter && isInteger(filter.chartDataType) && this.transactionStatisticsFilter.chartDataType !== filter.chartDataType) { this.transactionStatisticsFilter.chartDataType = filter.chartDataType; + changed = true; } - if (filter && isNumber(filter.categoricalChartType)) { + if (filter && isInteger(filter.categoricalChartType) && this.transactionStatisticsFilter.categoricalChartType !== filter.categoricalChartType) { this.transactionStatisticsFilter.categoricalChartType = filter.categoricalChartType; + changed = true; } - if (filter && isNumber(filter.categoricalChartDateType)) { + if (filter && isInteger(filter.categoricalChartDateType) && this.transactionStatisticsFilter.categoricalChartDateType !== filter.categoricalChartDateType) { this.transactionStatisticsFilter.categoricalChartDateType = filter.categoricalChartDateType; + changed = true; } - if (filter && isNumber(filter.categoricalChartStartTime)) { + if (filter && isInteger(filter.categoricalChartStartTime) && this.transactionStatisticsFilter.categoricalChartStartTime !== filter.categoricalChartStartTime) { this.transactionStatisticsFilter.categoricalChartStartTime = filter.categoricalChartStartTime; + changed = true; } - if (filter && isNumber(filter.categoricalChartEndTime)) { + if (filter && isInteger(filter.categoricalChartEndTime) && this.transactionStatisticsFilter.categoricalChartEndTime !== filter.categoricalChartEndTime) { this.transactionStatisticsFilter.categoricalChartEndTime = filter.categoricalChartEndTime; + changed = true; } - if (filter && isNumber(filter.trendChartType)) { + if (filter && isInteger(filter.trendChartType) && this.transactionStatisticsFilter.trendChartType !== filter.trendChartType) { this.transactionStatisticsFilter.trendChartType = filter.trendChartType; + changed = true; } - if (filter && isNumber(filter.trendChartDateType)) { + if (filter && isInteger(filter.trendChartDateType) && this.transactionStatisticsFilter.trendChartDateType !== filter.trendChartDateType) { this.transactionStatisticsFilter.trendChartDateType = filter.trendChartDateType; + changed = true; } - if (filter && (isYearMonth(filter.trendChartStartYearMonth) || filter.trendChartStartYearMonth === '')) { + if (filter && (isYearMonth(filter.trendChartStartYearMonth) || filter.trendChartStartYearMonth === '') && this.transactionStatisticsFilter.trendChartStartYearMonth !== filter.trendChartStartYearMonth) { this.transactionStatisticsFilter.trendChartStartYearMonth = filter.trendChartStartYearMonth; + changed = true; } - if (filter && (isYearMonth(filter.trendChartEndYearMonth) || filter.trendChartEndYearMonth === '')) { + if (filter && (isYearMonth(filter.trendChartEndYearMonth) || filter.trendChartEndYearMonth === '') && this.transactionStatisticsFilter.trendChartEndYearMonth !== filter.trendChartEndYearMonth) { this.transactionStatisticsFilter.trendChartEndYearMonth = filter.trendChartEndYearMonth; + changed = true; } - if (filter && isObject(filter.filterAccountIds)) { + if (filter && isObject(filter.filterAccountIds) && !isEquals(this.transactionStatisticsFilter.filterAccountIds, filter.filterAccountIds)) { this.transactionStatisticsFilter.filterAccountIds = filter.filterAccountIds; + changed = true; } - if (filter && isObject(filter.filterCategoryIds)) { + if (filter && isObject(filter.filterCategoryIds) && !isEquals(this.transactionStatisticsFilter.filterCategoryIds, filter.filterCategoryIds)) { this.transactionStatisticsFilter.filterCategoryIds = filter.filterCategoryIds; + changed = true; } - if (filter && isNumber(filter.sortingType)) { + if (filter && isInteger(filter.sortingType) && this.transactionStatisticsFilter.sortingType !== filter.sortingType) { this.transactionStatisticsFilter.sortingType = filter.sortingType; + changed = true; } + + return changed; + }, + getTransactionStatisticsPageParams(analysisType) { + const querys = []; + + querys.push('analysisType=' + analysisType); + querys.push('chartDataType=' + this.transactionStatisticsFilter.chartDataType); + + if (analysisType === statisticsConstants.allAnalysisTypes.CategoricalAnalysis) { + querys.push('chartType=' + this.transactionStatisticsFilter.categoricalChartType); + querys.push('chartDateType=' + this.transactionStatisticsFilter.categoricalChartDateType); + + if (this.transactionStatisticsFilter.categoricalChartDateType === datetimeConstants.allDateRanges.Custom.type) { + querys.push('startTime=' + this.transactionStatisticsFilter.categoricalChartStartTime); + querys.push('endTime=' + this.transactionStatisticsFilter.categoricalChartEndTime); + } + } else if (analysisType === statisticsConstants.allAnalysisTypes.TrendAnalysis) { + querys.push('chartType=' + this.transactionStatisticsFilter.trendChartType); + querys.push('chartDateType=' + this.transactionStatisticsFilter.trendChartDateType); + + if (this.transactionStatisticsFilter.trendChartDateType === datetimeConstants.allDateRanges.Custom.type) { + querys.push('startTime=' + this.transactionStatisticsFilter.trendChartStartYearMonth); + querys.push('endTime=' + this.transactionStatisticsFilter.trendChartEndYearMonth); + } + } + + if (this.transactionStatisticsFilter.filterAccountIds) { + const ids = objectFieldToArrayItem(this.transactionStatisticsFilter.filterAccountIds); + + if (ids && ids.length) { + querys.push('filterAccountIds=' + ids.join(',')); + } + } + + if (this.transactionStatisticsFilter.filterCategoryIds) { + const ids = objectFieldToArrayItem(this.transactionStatisticsFilter.filterCategoryIds); + + if (ids && ids.length) { + querys.push('filterCategoryIds=' + ids.join(',')); + } + } + + querys.push('sortingType=' + this.transactionStatisticsFilter.sortingType); + + return querys.join('&'); }, getTransactionListPageParams(analysisType, item, dateRange) { const accountsStore = useAccountsStore(); diff --git a/src/views/desktop/common/cards/AccountFilterSettingsCard.vue b/src/views/desktop/common/cards/AccountFilterSettingsCard.vue index 6e76cc06..4db83e5f 100644 --- a/src/views/desktop/common/cards/AccountFilterSettingsCard.vue +++ b/src/views/desktop/common/cards/AccountFilterSettingsCard.vue @@ -278,9 +278,13 @@ export default { if (this.type === 'statisticsDefault') { self.settingsStore.setStatisticsDefaultAccountFilter(filteredAccountIds); } else if (this.type === 'statisticsCurrent') { - self.statisticsStore.updateTransactionStatisticsFilter({ + changed = self.statisticsStore.updateTransactionStatisticsFilter({ filterAccountIds: filteredAccountIds }); + + if (changed) { + self.statisticsStore.updateTransactionStatisticsInvalidState(true); + } } else if (this.type === 'transactionListCurrent') { changed = self.transactionsStore.updateTransactionListFilter({ accountIds: isAllSelected ? '' : finalAccountIds diff --git a/src/views/desktop/common/cards/CategoryFilterSettingsCard.vue b/src/views/desktop/common/cards/CategoryFilterSettingsCard.vue index 481a6f58..9eb879bb 100644 --- a/src/views/desktop/common/cards/CategoryFilterSettingsCard.vue +++ b/src/views/desktop/common/cards/CategoryFilterSettingsCard.vue @@ -294,9 +294,13 @@ export default { if (this.type === 'statisticsDefault') { self.settingsStore.setStatisticsDefaultTransactionCategoryFilter(filteredCategoryIds); } else if (this.type === 'statisticsCurrent') { - self.statisticsStore.updateTransactionStatisticsFilter({ + changed = self.statisticsStore.updateTransactionStatisticsFilter({ filterCategoryIds: filteredCategoryIds }); + + if (changed) { + self.statisticsStore.updateTransactionStatisticsInvalidState(true); + } } else if (this.type === 'transactionListCurrent') { changed = self.transactionsStore.updateTransactionListFilter({ categoryIds: isAllSelected ? '' : finalCategoryIds diff --git a/src/views/desktop/statistics/TransactionPage.vue b/src/views/desktop/statistics/TransactionPage.vue index 155a019f..22be9820 100644 --- a/src/views/desktop/statistics/TransactionPage.vue +++ b/src/views/desktop/statistics/TransactionPage.vue @@ -8,7 +8,7 @@ + ]" v-model="queryAnalysisType" />
@@ -36,9 +36,9 @@ />
+ :disabled="loading" v-model="queryChartDataType"> + v-for="dataType in allChartDataTypes" v-show="dataType.availableAnalysisTypes[queryAnalysisType]"> {{ $t(dataType.name) }} {{ $t(dataType.name) }} @@ -57,12 +57,12 @@ {{ $t('Statistics & Analysis') }} + :disabled="loading || !canShiftDateRange()" + @click="shiftDateRange(-1)"/> {{ dateRange.displayName }} -
+
{{ queryStartTime }}  - 
@@ -83,8 +83,8 @@ + :disabled="loading || !canShiftDateRange()" + @click="shiftDateRange(1)"/> + v-if="queryAnalysisType === allAnalysisTypes.CategoricalAnalysis && (initing || (categoricalAnalysisData && categoricalAnalysisData.items && categoricalAnalysisData.items.length))"> {{ totalAmountName }} + v-else-if="!initing && ((queryAnalysisType === allAnalysisTypes.CategoricalAnalysis && (!categoricalAnalysisData || !categoricalAnalysisData.items || !categoricalAnalysisData.items.length)) + || (queryAnalysisType === allAnalysisTypes.TrendAnalysis && (!trendsAnalysisData || !trendsAnalysisData.items || !trendsAnalysisData.items.length)))"> {{ $t('No transaction data') }} - + +