add all date type range in transaction list page
This commit is contained in:
+15
-5
@@ -375,15 +375,25 @@ export function getRecentMonthDateRanges(monthCount) {
|
||||
return recentDateRanges;
|
||||
}
|
||||
|
||||
export function getRecentDateRangeTypeByDateType(allRecentMonthDateRanges, dateType) {
|
||||
for (let i = 0; i < allRecentMonthDateRanges.length; i++) {
|
||||
if (!allRecentMonthDateRanges[i].isPreset && allRecentMonthDateRanges[i].dateType === dateType) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return -1;
|
||||
}
|
||||
|
||||
export function getRecentDateRangeType(allRecentMonthDateRanges, dateType, minTime, maxTime, firstDayOfWeek) {
|
||||
let dateRange = getDateRangeByDateType(dateType, firstDayOfWeek);
|
||||
|
||||
if (dateRange && dateRange.dateType === dateTimeConstants.allDateRanges.All.type) {
|
||||
return allRecentMonthDateRanges.length - 1; // Custom
|
||||
return getRecentDateRangeTypeByDateType(allRecentMonthDateRanges, dateTimeConstants.allDateRanges.All.type);
|
||||
}
|
||||
|
||||
if (!dateRange && (!maxTime || !minTime)) {
|
||||
return allRecentMonthDateRanges.length - 1; // Custom
|
||||
return getRecentDateRangeTypeByDateType(allRecentMonthDateRanges, dateTimeConstants.allDateRanges.Custom.type);
|
||||
}
|
||||
|
||||
if (!dateRange) {
|
||||
@@ -394,15 +404,15 @@ export function getRecentDateRangeType(allRecentMonthDateRanges, dateType, minTi
|
||||
};
|
||||
}
|
||||
|
||||
for (let i = 0; i < allRecentMonthDateRanges.length - 1; i++) {
|
||||
for (let i = 0; i < allRecentMonthDateRanges.length; i++) {
|
||||
const recentDateRange = allRecentMonthDateRanges[i];
|
||||
|
||||
if (recentDateRange.minTime === dateRange.minTime && recentDateRange.maxTime === dateRange.maxTime) {
|
||||
if (recentDateRange.isPreset && recentDateRange.minTime === dateRange.minTime && recentDateRange.maxTime === dateRange.maxTime) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
|
||||
return allRecentMonthDateRanges.length - 1; // Custom
|
||||
return getRecentDateRangeTypeByDateType(allRecentMonthDateRanges, dateTimeConstants.allDateRanges.Custom.type);
|
||||
}
|
||||
|
||||
export function isDateRangeMatchFullYears(minTime, maxTime) {
|
||||
|
||||
+12
-2
@@ -597,7 +597,7 @@ function getAllDateRanges(includeCustom, translateFn) {
|
||||
return allDateRanges;
|
||||
}
|
||||
|
||||
function getAllRecentMonthDateRanges(userStore, includeCustom, translateFn) {
|
||||
function getAllRecentMonthDateRanges(userStore, includeAll, includeCustom, translateFn) {
|
||||
const allRecentMonthDateRanges = [];
|
||||
const recentDateRanges = getRecentMonthDateRanges(12);
|
||||
|
||||
@@ -610,10 +610,20 @@ function getAllRecentMonthDateRanges(userStore, includeCustom, translateFn) {
|
||||
maxTime: recentDateRange.maxTime,
|
||||
year: recentDateRange.year,
|
||||
month: recentDateRange.month,
|
||||
isPreset: true,
|
||||
displayName: formatUnixTime(recentDateRange.minTime, getI18nLongYearMonthFormat(translateFn, userStore.currentUserLongDateFormat))
|
||||
});
|
||||
}
|
||||
|
||||
if (includeAll) {
|
||||
allRecentMonthDateRanges.push({
|
||||
dateType: datetime.allDateRanges.All.type,
|
||||
minTime: 0,
|
||||
maxTime: 0,
|
||||
displayName: translateFn('All')
|
||||
});
|
||||
}
|
||||
|
||||
if (includeCustom) {
|
||||
allRecentMonthDateRanges.push({
|
||||
dateType: datetime.allDateRanges.Custom.type,
|
||||
@@ -1054,7 +1064,7 @@ export function i18nFunctions(i18nGlobal) {
|
||||
getAllCurrencies: () => getAllCurrencies(i18nGlobal.t),
|
||||
getAllWeekDays: () => getAllWeekDays(i18nGlobal.t),
|
||||
getAllDateRanges: (includeCustom) => getAllDateRanges(includeCustom, i18nGlobal.t),
|
||||
getAllRecentMonthDateRanges: (userStore, includeCustom) => getAllRecentMonthDateRanges(userStore, includeCustom, i18nGlobal.t),
|
||||
getAllRecentMonthDateRanges: (userStore, includeAll, includeCustom) => getAllRecentMonthDateRanges(userStore, includeAll, includeCustom, i18nGlobal.t),
|
||||
getDateRangeDisplayName: (userStore, dateType, startTime, endTime) => getDateRangeDisplayName(userStore, dateType, startTime, endTime, i18nGlobal.t),
|
||||
getAllStatisticsChartDataTypes: () => getAllStatisticsChartDataTypes(i18nGlobal.t),
|
||||
getAllStatisticsSortingTypes: () => getAllStatisticsSortingTypes(i18nGlobal.t),
|
||||
|
||||
@@ -561,7 +561,7 @@ export default {
|
||||
return primaryCategories;
|
||||
},
|
||||
recentMonthDateRanges() {
|
||||
return this.$locale.getAllRecentMonthDateRanges(this.userStore, true);
|
||||
return this.$locale.getAllRecentMonthDateRanges(this.userStore, true, true);
|
||||
},
|
||||
showTotalAmountInTransactionListPage() {
|
||||
return this.settingsStore.appSettings.showTotalAmountInTransactionListPage;
|
||||
|
||||
Reference in New Issue
Block a user