self.allSortingTypes.Name.type) {
+ defaultSortType = self.$constants.statistics.defaultSortingType;
+ }
+
const dateRange = self.$utilities.getDateRangeByDateType(defaultDateRange, self.firstDayOfWeek);
self.$store.dispatch('initTransactionStatisticsFilter', {
@@ -398,6 +433,7 @@ export default {
chartDataType: defaultChartDataType,
filterAccountIds: self.$settings.getStatisticsDefaultAccountFilter() || {},
filterCategoryIds: self.$settings.getStatisticsDefaultTransactionCategoryFilter() || {},
+ sortingType: defaultSortType,
});
Promise.all([
@@ -420,10 +456,6 @@ export default {
},
methods: {
onPageAfterIn() {
- if (this.sortBy !== this.$settings.getStatisticsSortingType()) {
- this.sortBy = this.$settings.getStatisticsSortingType();
- }
-
if (this.$store.state.transactionStatisticsStateInvalid && !this.loading) {
this.reload(null);
}
@@ -432,22 +464,39 @@ export default {
},
reload(done) {
const self = this;
+ let dispatchPromise = null;
- self.$store.dispatch('loadTransactionStatistics', {
- defaultCurrency: self.defaultCurrency
- }).then(() => {
- if (done) {
- done();
- }
- }).catch(error => {
- if (done) {
- done();
- }
+ if (self.query.chartDataType === self.allChartDataTypes.ExpenseByAccount.type ||
+ self.query.chartDataType === self.allChartDataTypes.ExpenseByPrimaryCategory.type ||
+ self.query.chartDataType === self.allChartDataTypes.ExpenseBySecondaryCategory.type ||
+ self.query.chartDataType === self.allChartDataTypes.IncomeByAccount.type ||
+ self.query.chartDataType === self.allChartDataTypes.IncomeByPrimaryCategory.type ||
+ self.query.chartDataType === self.allChartDataTypes.IncomeBySecondaryCategory.type) {
+ dispatchPromise = self.$store.dispatch('loadTransactionStatistics', {
+ defaultCurrency: self.defaultCurrency
+ });
+ } else if (self.query.chartDataType === self.allChartDataTypes.AccountTotalAssets.type ||
+ self.query.chartDataType === self.allChartDataTypes.AccountTotalLiabilities.type) {
+ dispatchPromise = self.$store.dispatch('loadAllAccounts', {
+ force: true
+ });
+ }
- if (!error.processed) {
- self.$toast(error.message || error);
- }
- });
+ if (dispatchPromise) {
+ dispatchPromise.then(() => {
+ if (done) {
+ done();
+ }
+ }).catch(error => {
+ if (done) {
+ done();
+ }
+
+ if (!error.processed) {
+ self.$toast(error.message || error);
+ }
+ });
+ }
},
setChartType(chartType) {
this.$store.dispatch('updateTransactionStatisticsFilter', {
@@ -460,6 +509,19 @@ export default {
});
this.showChartDataTypePopover = false;
},
+ setSortingType(sortingType) {
+ if (sortingType < this.allSortingTypes.Amount.type || sortingType > this.allSortingTypes.Name.type) {
+ this.showSortingTypePopover = false;
+ return;
+ }
+
+ this.$store.dispatch('updateTransactionStatisticsFilter', {
+ sortingType: sortingType
+ });
+
+ this.showSortingTypePopover = false;
+ this.reload(null);
+ },
setDateFilter(dateType) {
if (dateType === this.allDateRanges.Custom.type) { // Custom
this.showCustomDateRangeSheet = true;
@@ -663,6 +725,10 @@ export default {