mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-19 17:24:26 +08:00
code refactor
This commit is contained in:
+104
-104
@@ -1,14 +1,14 @@
|
|||||||
import moment from 'moment-timezone';
|
import moment from 'moment-timezone';
|
||||||
|
|
||||||
import { defaultLanguage, allLanguages } from '@/locales/index.js';
|
import { defaultLanguage, allLanguages } from '@/locales/index.js';
|
||||||
import numeral from '@/consts/numeral.js';
|
import numeralConstants from '@/consts/numeral.js';
|
||||||
import datetime from '@/consts/datetime.js';
|
import datetimeConstants from '@/consts/datetime.js';
|
||||||
import timezone from '@/consts/timezone.js';
|
import timezoneConstants from '@/consts/timezone.js';
|
||||||
import currency from '@/consts/currency.js';
|
import currencyConstants from '@/consts/currency.js';
|
||||||
import account from '@/consts/account.js';
|
import accountConstants from '@/consts/account.js';
|
||||||
import category from '@/consts/category.js';
|
import categoryConstants from '@/consts/category.js';
|
||||||
import statistics from '@/consts/statistics.js';
|
import statisticsConstants from '@/consts/statistics.js';
|
||||||
import api from '@/consts/api.js';
|
import apiConstants from '@/consts/api.js';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
isString,
|
isString,
|
||||||
@@ -281,22 +281,22 @@ function getAllMinWeekdayNames(translateFn) {
|
|||||||
|
|
||||||
function getAllLongDateFormats(translateFn) {
|
function getAllLongDateFormats(translateFn) {
|
||||||
const defaultLongDateFormatTypeName = translateFn('default.longDateFormat');
|
const defaultLongDateFormatTypeName = translateFn('default.longDateFormat');
|
||||||
return getDateTimeFormats(translateFn, datetime.allLongDateFormat, datetime.allLongDateFormatArray, 'format.longDate', defaultLongDateFormatTypeName, datetime.defaultLongDateFormat);
|
return getDateTimeFormats(translateFn, datetimeConstants.allLongDateFormat, datetimeConstants.allLongDateFormatArray, 'format.longDate', defaultLongDateFormatTypeName, datetimeConstants.defaultLongDateFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllShortDateFormats(translateFn) {
|
function getAllShortDateFormats(translateFn) {
|
||||||
const defaultShortDateFormatTypeName = translateFn('default.shortDateFormat');
|
const defaultShortDateFormatTypeName = translateFn('default.shortDateFormat');
|
||||||
return getDateTimeFormats(translateFn, datetime.allShortDateFormat, datetime.allShortDateFormatArray, 'format.shortDate', defaultShortDateFormatTypeName, datetime.defaultShortDateFormat);
|
return getDateTimeFormats(translateFn, datetimeConstants.allShortDateFormat, datetimeConstants.allShortDateFormatArray, 'format.shortDate', defaultShortDateFormatTypeName, datetimeConstants.defaultShortDateFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllLongTimeFormats(translateFn) {
|
function getAllLongTimeFormats(translateFn) {
|
||||||
const defaultLongTimeFormatTypeName = translateFn('default.longTimeFormat');
|
const defaultLongTimeFormatTypeName = translateFn('default.longTimeFormat');
|
||||||
return getDateTimeFormats(translateFn, datetime.allLongTimeFormat, datetime.allLongTimeFormatArray, 'format.longTime', defaultLongTimeFormatTypeName, datetime.defaultLongTimeFormat);
|
return getDateTimeFormats(translateFn, datetimeConstants.allLongTimeFormat, datetimeConstants.allLongTimeFormatArray, 'format.longTime', defaultLongTimeFormatTypeName, datetimeConstants.defaultLongTimeFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllShortTimeFormats(translateFn) {
|
function getAllShortTimeFormats(translateFn) {
|
||||||
const defaultShortTimeFormatTypeName = translateFn('default.shortTimeFormat');
|
const defaultShortTimeFormatTypeName = translateFn('default.shortTimeFormat');
|
||||||
return getDateTimeFormats(translateFn, datetime.allShortTimeFormat, datetime.allShortTimeFormatArray, 'format.shortTime', defaultShortTimeFormatTypeName, datetime.defaultShortTimeFormat);
|
return getDateTimeFormats(translateFn, datetimeConstants.allShortTimeFormat, datetimeConstants.allShortTimeFormatArray, 'format.shortTime', defaultShortTimeFormatTypeName, datetimeConstants.defaultShortTimeFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getMonthShortName(month, translateFn) {
|
function getMonthShortName(month, translateFn) {
|
||||||
@@ -317,97 +317,97 @@ function getWeekdayLongName(weekDay, translateFn) {
|
|||||||
|
|
||||||
function getI18nLongDateFormat(translateFn, formatTypeValue) {
|
function getI18nLongDateFormat(translateFn, formatTypeValue) {
|
||||||
const defaultLongDateFormatTypeName = translateFn('default.longDateFormat');
|
const defaultLongDateFormatTypeName = translateFn('default.longDateFormat');
|
||||||
return getDateTimeFormat(translateFn, datetime.allLongDateFormat, datetime.allLongDateFormatArray, 'format.longDate', defaultLongDateFormatTypeName, datetime.defaultLongDateFormat, formatTypeValue);
|
return getDateTimeFormat(translateFn, datetimeConstants.allLongDateFormat, datetimeConstants.allLongDateFormatArray, 'format.longDate', defaultLongDateFormatTypeName, datetimeConstants.defaultLongDateFormat, formatTypeValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getI18nShortDateFormat(translateFn, formatTypeValue) {
|
function getI18nShortDateFormat(translateFn, formatTypeValue) {
|
||||||
const defaultShortDateFormatTypeName = translateFn('default.shortDateFormat');
|
const defaultShortDateFormatTypeName = translateFn('default.shortDateFormat');
|
||||||
return getDateTimeFormat(translateFn, datetime.allShortDateFormat, datetime.allShortDateFormatArray, 'format.shortDate', defaultShortDateFormatTypeName, datetime.defaultShortDateFormat, formatTypeValue);
|
return getDateTimeFormat(translateFn, datetimeConstants.allShortDateFormat, datetimeConstants.allShortDateFormatArray, 'format.shortDate', defaultShortDateFormatTypeName, datetimeConstants.defaultShortDateFormat, formatTypeValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getI18nLongYearFormat(translateFn, formatTypeValue) {
|
function getI18nLongYearFormat(translateFn, formatTypeValue) {
|
||||||
const defaultLongDateFormatTypeName = translateFn('default.longDateFormat');
|
const defaultLongDateFormatTypeName = translateFn('default.longDateFormat');
|
||||||
return getDateTimeFormat(translateFn, datetime.allLongDateFormat, datetime.allLongDateFormatArray, 'format.longYear', defaultLongDateFormatTypeName, datetime.defaultLongDateFormat, formatTypeValue);
|
return getDateTimeFormat(translateFn, datetimeConstants.allLongDateFormat, datetimeConstants.allLongDateFormatArray, 'format.longYear', defaultLongDateFormatTypeName, datetimeConstants.defaultLongDateFormat, formatTypeValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getI18nShortYearFormat(translateFn, formatTypeValue) {
|
function getI18nShortYearFormat(translateFn, formatTypeValue) {
|
||||||
const defaultShortDateFormatTypeName = translateFn('default.shortDateFormat');
|
const defaultShortDateFormatTypeName = translateFn('default.shortDateFormat');
|
||||||
return getDateTimeFormat(translateFn, datetime.allShortDateFormat, datetime.allShortDateFormatArray, 'format.shortYear', defaultShortDateFormatTypeName, datetime.defaultShortDateFormat, formatTypeValue);
|
return getDateTimeFormat(translateFn, datetimeConstants.allShortDateFormat, datetimeConstants.allShortDateFormatArray, 'format.shortYear', defaultShortDateFormatTypeName, datetimeConstants.defaultShortDateFormat, formatTypeValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getI18nLongYearMonthFormat(translateFn, formatTypeValue) {
|
function getI18nLongYearMonthFormat(translateFn, formatTypeValue) {
|
||||||
const defaultLongDateFormatTypeName = translateFn('default.longDateFormat');
|
const defaultLongDateFormatTypeName = translateFn('default.longDateFormat');
|
||||||
return getDateTimeFormat(translateFn, datetime.allLongDateFormat, datetime.allLongDateFormatArray, 'format.longYearMonth', defaultLongDateFormatTypeName, datetime.defaultLongDateFormat, formatTypeValue);
|
return getDateTimeFormat(translateFn, datetimeConstants.allLongDateFormat, datetimeConstants.allLongDateFormatArray, 'format.longYearMonth', defaultLongDateFormatTypeName, datetimeConstants.defaultLongDateFormat, formatTypeValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getI18nShortYearMonthFormat(translateFn, formatTypeValue) {
|
function getI18nShortYearMonthFormat(translateFn, formatTypeValue) {
|
||||||
const defaultShortDateFormatTypeName = translateFn('default.shortDateFormat');
|
const defaultShortDateFormatTypeName = translateFn('default.shortDateFormat');
|
||||||
return getDateTimeFormat(translateFn, datetime.allShortDateFormat, datetime.allShortDateFormatArray, 'format.shortYearMonth', defaultShortDateFormatTypeName, datetime.defaultShortDateFormat, formatTypeValue);
|
return getDateTimeFormat(translateFn, datetimeConstants.allShortDateFormat, datetimeConstants.allShortDateFormatArray, 'format.shortYearMonth', defaultShortDateFormatTypeName, datetimeConstants.defaultShortDateFormat, formatTypeValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getI18nLongMonthDayFormat(translateFn, formatTypeValue) {
|
function getI18nLongMonthDayFormat(translateFn, formatTypeValue) {
|
||||||
const defaultLongDateFormatTypeName = translateFn('default.longDateFormat');
|
const defaultLongDateFormatTypeName = translateFn('default.longDateFormat');
|
||||||
return getDateTimeFormat(translateFn, datetime.allLongDateFormat, datetime.allLongDateFormatArray, 'format.longMonthDay', defaultLongDateFormatTypeName, datetime.defaultLongDateFormat, formatTypeValue);
|
return getDateTimeFormat(translateFn, datetimeConstants.allLongDateFormat, datetimeConstants.allLongDateFormatArray, 'format.longMonthDay', defaultLongDateFormatTypeName, datetimeConstants.defaultLongDateFormat, formatTypeValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getI18nShortMonthDayFormat(translateFn, formatTypeValue) {
|
function getI18nShortMonthDayFormat(translateFn, formatTypeValue) {
|
||||||
const defaultShortDateFormatTypeName = translateFn('default.shortDateFormat');
|
const defaultShortDateFormatTypeName = translateFn('default.shortDateFormat');
|
||||||
return getDateTimeFormat(translateFn, datetime.allShortDateFormat, datetime.allShortDateFormatArray, 'format.shortMonthDay', defaultShortDateFormatTypeName, datetime.defaultShortDateFormat, formatTypeValue);
|
return getDateTimeFormat(translateFn, datetimeConstants.allShortDateFormat, datetimeConstants.allShortDateFormatArray, 'format.shortMonthDay', defaultShortDateFormatTypeName, datetimeConstants.defaultShortDateFormat, formatTypeValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isLongDateMonthAfterYear(translateFn, formatTypeValue) {
|
function isLongDateMonthAfterYear(translateFn, formatTypeValue) {
|
||||||
const defaultLongDateFormatTypeName = translateFn('default.longDateFormat');
|
const defaultLongDateFormatTypeName = translateFn('default.longDateFormat');
|
||||||
const type = getDateTimeFormatType(datetime.allLongDateFormat, datetime.allLongDateFormatArray, defaultLongDateFormatTypeName, datetime.defaultLongDateFormat, formatTypeValue);
|
const type = getDateTimeFormatType(datetimeConstants.allLongDateFormat, datetimeConstants.allLongDateFormatArray, defaultLongDateFormatTypeName, datetimeConstants.defaultLongDateFormat, formatTypeValue);
|
||||||
return type.isMonthAfterYear;
|
return type.isMonthAfterYear;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isShortDateMonthAfterYear(translateFn, formatTypeValue) {
|
function isShortDateMonthAfterYear(translateFn, formatTypeValue) {
|
||||||
const defaultShortDateFormatTypeName = translateFn('default.shortDateFormat');
|
const defaultShortDateFormatTypeName = translateFn('default.shortDateFormat');
|
||||||
const type = getDateTimeFormatType(datetime.allShortDateFormat, datetime.allShortDateFormatArray, defaultShortDateFormatTypeName, datetime.defaultShortDateFormat, formatTypeValue);
|
const type = getDateTimeFormatType(datetimeConstants.allShortDateFormat, datetimeConstants.allShortDateFormatArray, defaultShortDateFormatTypeName, datetimeConstants.defaultShortDateFormat, formatTypeValue);
|
||||||
return type.isMonthAfterYear;
|
return type.isMonthAfterYear;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getI18nLongTimeFormat(translateFn, formatTypeValue) {
|
function getI18nLongTimeFormat(translateFn, formatTypeValue) {
|
||||||
const defaultLongTimeFormatTypeName = translateFn('default.longTimeFormat');
|
const defaultLongTimeFormatTypeName = translateFn('default.longTimeFormat');
|
||||||
return getDateTimeFormat(translateFn, datetime.allLongTimeFormat, datetime.allLongTimeFormatArray, 'format.longTime', defaultLongTimeFormatTypeName, datetime.defaultLongTimeFormat, formatTypeValue);
|
return getDateTimeFormat(translateFn, datetimeConstants.allLongTimeFormat, datetimeConstants.allLongTimeFormatArray, 'format.longTime', defaultLongTimeFormatTypeName, datetimeConstants.defaultLongTimeFormat, formatTypeValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getI18nShortTimeFormat(translateFn, formatTypeValue) {
|
function getI18nShortTimeFormat(translateFn, formatTypeValue) {
|
||||||
const defaultShortTimeFormatTypeName = translateFn('default.shortTimeFormat');
|
const defaultShortTimeFormatTypeName = translateFn('default.shortTimeFormat');
|
||||||
return getDateTimeFormat(translateFn, datetime.allShortTimeFormat, datetime.allShortTimeFormatArray, 'format.shortTime', defaultShortTimeFormatTypeName, datetime.defaultShortTimeFormat, formatTypeValue);
|
return getDateTimeFormat(translateFn, datetimeConstants.allShortTimeFormat, datetimeConstants.allShortTimeFormatArray, 'format.shortTime', defaultShortTimeFormatTypeName, datetimeConstants.defaultShortTimeFormat, formatTypeValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isLongTime24HourFormat(translateFn, formatTypeValue) {
|
function isLongTime24HourFormat(translateFn, formatTypeValue) {
|
||||||
const defaultLongTimeFormatTypeName = translateFn('default.longTimeFormat');
|
const defaultLongTimeFormatTypeName = translateFn('default.longTimeFormat');
|
||||||
const type = getDateTimeFormatType(datetime.allLongTimeFormat, datetime.allLongTimeFormatArray, defaultLongTimeFormatTypeName, datetime.defaultLongTimeFormat, formatTypeValue);
|
const type = getDateTimeFormatType(datetimeConstants.allLongTimeFormat, datetimeConstants.allLongTimeFormatArray, defaultLongTimeFormatTypeName, datetimeConstants.defaultLongTimeFormat, formatTypeValue);
|
||||||
return type.is24HourFormat;
|
return type.is24HourFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isLongTimeMeridiemIndicatorFirst(translateFn, formatTypeValue) {
|
function isLongTimeMeridiemIndicatorFirst(translateFn, formatTypeValue) {
|
||||||
const defaultLongTimeFormatTypeName = translateFn('default.longTimeFormat');
|
const defaultLongTimeFormatTypeName = translateFn('default.longTimeFormat');
|
||||||
const type = getDateTimeFormatType(datetime.allLongTimeFormat, datetime.allLongTimeFormatArray, defaultLongTimeFormatTypeName, datetime.defaultLongTimeFormat, formatTypeValue);
|
const type = getDateTimeFormatType(datetimeConstants.allLongTimeFormat, datetimeConstants.allLongTimeFormatArray, defaultLongTimeFormatTypeName, datetimeConstants.defaultLongTimeFormat, formatTypeValue);
|
||||||
return type.isMeridiemIndicatorFirst;
|
return type.isMeridiemIndicatorFirst;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isShortTime24HourFormat(translateFn, formatTypeValue) {
|
function isShortTime24HourFormat(translateFn, formatTypeValue) {
|
||||||
const defaultShortTimeFormatTypeName = translateFn('default.shortTimeFormat');
|
const defaultShortTimeFormatTypeName = translateFn('default.shortTimeFormat');
|
||||||
const type = getDateTimeFormatType(datetime.allShortTimeFormat, datetime.allShortTimeFormatArray, defaultShortTimeFormatTypeName, datetime.defaultShortTimeFormat, formatTypeValue);
|
const type = getDateTimeFormatType(datetimeConstants.allShortTimeFormat, datetimeConstants.allShortTimeFormatArray, defaultShortTimeFormatTypeName, datetimeConstants.defaultShortTimeFormat, formatTypeValue);
|
||||||
return type.is24HourFormat;
|
return type.is24HourFormat;
|
||||||
}
|
}
|
||||||
|
|
||||||
function isShortTimeMeridiemIndicatorFirst(translateFn, formatTypeValue) {
|
function isShortTimeMeridiemIndicatorFirst(translateFn, formatTypeValue) {
|
||||||
const defaultShortTimeFormatTypeName = translateFn('default.shortTimeFormat');
|
const defaultShortTimeFormatTypeName = translateFn('default.shortTimeFormat');
|
||||||
const type = getDateTimeFormatType(datetime.allShortTimeFormat, datetime.allShortTimeFormatArray, defaultShortTimeFormatTypeName, datetime.defaultShortTimeFormat, formatTypeValue);
|
const type = getDateTimeFormatType(datetimeConstants.allShortTimeFormat, datetimeConstants.allShortTimeFormatArray, defaultShortTimeFormatTypeName, datetimeConstants.defaultShortTimeFormat, formatTypeValue);
|
||||||
return type.isMeridiemIndicatorFirst;
|
return type.isMeridiemIndicatorFirst;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDateTimeFormats(translateFn, allFormatMap, allFormatArray, localeFormatPathPrefix, localeDefaultFormatTypeName, systemDefaultFormatType) {
|
function getDateTimeFormats(translateFn, allFormatMap, allFormatArray, localeFormatPathPrefix, localeDefaultFormatTypeName, systemDefaultFormatType) {
|
||||||
const defaultFormat = getDateTimeFormat(translateFn, allFormatMap, allFormatArray,
|
const defaultFormat = getDateTimeFormat(translateFn, allFormatMap, allFormatArray,
|
||||||
localeFormatPathPrefix, localeDefaultFormatTypeName, systemDefaultFormatType, datetime.defaultDateTimeFormatValue);
|
localeFormatPathPrefix, localeDefaultFormatTypeName, systemDefaultFormatType, datetimeConstants.defaultDateTimeFormatValue);
|
||||||
const ret = [];
|
const ret = [];
|
||||||
|
|
||||||
ret.push({
|
ret.push({
|
||||||
type: datetime.defaultDateTimeFormatValue,
|
type: datetimeConstants.defaultDateTimeFormatValue,
|
||||||
format: defaultFormat,
|
format: defaultFormat,
|
||||||
displayName: `${translateFn('Language Default')} (${formatTime(getCurrentDateTime(), defaultFormat)})`
|
displayName: `${translateFn('Language Default')} (${formatTime(getCurrentDateTime(), defaultFormat)})`
|
||||||
});
|
});
|
||||||
@@ -435,11 +435,11 @@ function getDateTimeFormat(translateFn, allFormatMap, allFormatArray, localeForm
|
|||||||
function getAllTimezones(includeSystemDefault, translateFn) {
|
function getAllTimezones(includeSystemDefault, translateFn) {
|
||||||
const defaultTimezoneOffset = getBrowserTimezoneOffset();
|
const defaultTimezoneOffset = getBrowserTimezoneOffset();
|
||||||
const defaultTimezoneOffsetMinutes = getBrowserTimezoneOffsetMinutes();
|
const defaultTimezoneOffsetMinutes = getBrowserTimezoneOffsetMinutes();
|
||||||
const allTimezones = timezone.all;
|
const allTimezones = timezoneConstants.all;
|
||||||
const allTimezoneInfos = [];
|
const allTimezoneInfos = [];
|
||||||
|
|
||||||
for (let i = 0; i < allTimezones.length; i++) {
|
for (let i = 0; i < allTimezones.length; i++) {
|
||||||
const utcOffset = (allTimezones[i].timezoneName !== timezone.utcTimezoneName ? getTimezoneOffset(allTimezones[i].timezoneName) : '');
|
const utcOffset = (allTimezones[i].timezoneName !== timezoneConstants.utcTimezoneName ? getTimezoneOffset(allTimezones[i].timezoneName) : '');
|
||||||
const displayName = translateFn(`timezone.${allTimezones[i].displayName}`);
|
const displayName = translateFn(`timezone.${allTimezones[i].displayName}`);
|
||||||
|
|
||||||
allTimezoneInfos.push({
|
allTimezoneInfos.push({
|
||||||
@@ -509,7 +509,7 @@ function getTimezoneDifferenceDisplayText(utcOffset, translateFn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getAllCurrencies(translateFn) {
|
function getAllCurrencies(translateFn) {
|
||||||
const allCurrencyCodes = currency.all;
|
const allCurrencyCodes = currencyConstants.all;
|
||||||
const allCurrencies = [];
|
const allCurrencies = [];
|
||||||
|
|
||||||
for (let currencyCode in allCurrencyCodes) {
|
for (let currencyCode in allCurrencyCodes) {
|
||||||
@@ -533,8 +533,8 @@ function getAllCurrencies(translateFn) {
|
|||||||
function getAllWeekDays(translateFn) {
|
function getAllWeekDays(translateFn) {
|
||||||
const allWeekDays = [];
|
const allWeekDays = [];
|
||||||
|
|
||||||
for (let i = 0; i < datetime.allWeekDaysArray.length; i++) {
|
for (let i = 0; i < datetimeConstants.allWeekDaysArray.length; i++) {
|
||||||
const weekDay = datetime.allWeekDaysArray[i];
|
const weekDay = datetimeConstants.allWeekDaysArray[i];
|
||||||
|
|
||||||
allWeekDays.push({
|
allWeekDays.push({
|
||||||
type: weekDay.type,
|
type: weekDay.type,
|
||||||
@@ -548,18 +548,18 @@ function getAllWeekDays(translateFn) {
|
|||||||
function getAllDateRanges(scene, includeCustom, translateFn) {
|
function getAllDateRanges(scene, includeCustom, translateFn) {
|
||||||
const allDateRanges = [];
|
const allDateRanges = [];
|
||||||
|
|
||||||
for (let dateRangeField in datetime.allDateRanges) {
|
for (let dateRangeField in datetimeConstants.allDateRanges) {
|
||||||
if (!Object.prototype.hasOwnProperty.call(datetime.allDateRanges, dateRangeField)) {
|
if (!Object.prototype.hasOwnProperty.call(datetimeConstants.allDateRanges, dateRangeField)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const dateRangeType = datetime.allDateRanges[dateRangeField];
|
const dateRangeType = datetimeConstants.allDateRanges[dateRangeField];
|
||||||
|
|
||||||
if (!dateRangeType.availableScenes[scene]) {
|
if (!dateRangeType.availableScenes[scene]) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (includeCustom || dateRangeType.type !== datetime.allDateRanges.Custom.type) {
|
if (includeCustom || dateRangeType.type !== datetimeConstants.allDateRanges.Custom.type) {
|
||||||
allDateRanges.push({
|
allDateRanges.push({
|
||||||
type: dateRangeType.type,
|
type: dateRangeType.type,
|
||||||
displayName: translateFn(dateRangeType.name)
|
displayName: translateFn(dateRangeType.name)
|
||||||
@@ -576,7 +576,7 @@ function getAllRecentMonthDateRanges(userStore, includeAll, includeCustom, trans
|
|||||||
|
|
||||||
if (includeAll) {
|
if (includeAll) {
|
||||||
allRecentMonthDateRanges.push({
|
allRecentMonthDateRanges.push({
|
||||||
dateType: datetime.allDateRanges.All.type,
|
dateType: datetimeConstants.allDateRanges.All.type,
|
||||||
minTime: 0,
|
minTime: 0,
|
||||||
maxTime: 0,
|
maxTime: 0,
|
||||||
displayName: translateFn('All')
|
displayName: translateFn('All')
|
||||||
@@ -599,7 +599,7 @@ function getAllRecentMonthDateRanges(userStore, includeAll, includeCustom, trans
|
|||||||
|
|
||||||
if (includeCustom) {
|
if (includeCustom) {
|
||||||
allRecentMonthDateRanges.push({
|
allRecentMonthDateRanges.push({
|
||||||
dateType: datetime.allDateRanges.Custom.type,
|
dateType: datetimeConstants.allDateRanges.Custom.type,
|
||||||
minTime: 0,
|
minTime: 0,
|
||||||
maxTime: 0,
|
maxTime: 0,
|
||||||
displayName: translateFn('Custom Date')
|
displayName: translateFn('Custom Date')
|
||||||
@@ -610,18 +610,18 @@ function getAllRecentMonthDateRanges(userStore, includeAll, includeCustom, trans
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getDateRangeDisplayName(userStore, dateType, startTime, endTime, translateFn) {
|
function getDateRangeDisplayName(userStore, dateType, startTime, endTime, translateFn) {
|
||||||
if (dateType === datetime.allDateRanges.All.type) {
|
if (dateType === datetimeConstants.allDateRanges.All.type) {
|
||||||
return translateFn(datetime.allDateRanges.All.name);
|
return translateFn(datetimeConstants.allDateRanges.All.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let dateRangeField in datetime.allDateRanges) {
|
for (let dateRangeField in datetimeConstants.allDateRanges) {
|
||||||
if (!Object.prototype.hasOwnProperty.call(datetime.allDateRanges, dateRangeField)) {
|
if (!Object.prototype.hasOwnProperty.call(datetimeConstants.allDateRanges, dateRangeField)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const dateRange = datetime.allDateRanges[dateRangeField];
|
const dateRange = datetimeConstants.allDateRanges[dateRangeField];
|
||||||
|
|
||||||
if (dateRange && dateRange.type !== datetime.allDateRanges.Custom.type && dateRange.type === dateType && dateRange.name) {
|
if (dateRange && dateRange.type !== datetimeConstants.allDateRanges.Custom.type && dateRange.type === dateType && dateRange.name) {
|
||||||
return translateFn(dateRange.name);
|
return translateFn(dateRange.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -662,23 +662,23 @@ function getAllTimezoneTypesUsedForStatistics(currentTimezone, translateFn) {
|
|||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
displayName: translateFn('Application Timezone') + ` (UTC${currentTimezoneOffset})`,
|
displayName: translateFn('Application Timezone') + ` (UTC${currentTimezoneOffset})`,
|
||||||
type: timezone.allTimezoneTypesUsedForStatistics.ApplicationTimezone
|
type: timezoneConstants.allTimezoneTypesUsedForStatistics.ApplicationTimezone
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
displayName: translateFn('Transaction Timezone'),
|
displayName: translateFn('Transaction Timezone'),
|
||||||
type: timezone.allTimezoneTypesUsedForStatistics.TransactionTimezone
|
type: timezoneConstants.allTimezoneTypesUsedForStatistics.TransactionTimezone
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllDecimalSeparators(translateFn) {
|
function getAllDecimalSeparators(translateFn) {
|
||||||
const defaultDecimalSeparatorTypeName = translateFn('default.decimalSeparator');
|
const defaultDecimalSeparatorTypeName = translateFn('default.decimalSeparator');
|
||||||
return getNumeralSeparatorFormats(translateFn, numeral.allDecimalSeparator, numeral.allDecimalSeparatorArray, defaultDecimalSeparatorTypeName, numeral.defaultDecimalSeparator);
|
return getNumeralSeparatorFormats(translateFn, numeralConstants.allDecimalSeparator, numeralConstants.allDecimalSeparatorArray, defaultDecimalSeparatorTypeName, numeralConstants.defaultDecimalSeparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getAllDigitGroupingSymbols(translateFn) {
|
function getAllDigitGroupingSymbols(translateFn) {
|
||||||
const defaultDigitGroupingSymbolTypeName = translateFn('default.digitGroupingSymbol');
|
const defaultDigitGroupingSymbolTypeName = translateFn('default.digitGroupingSymbol');
|
||||||
return getNumeralSeparatorFormats(translateFn, numeral.allDigitGroupingSymbol, numeral.allDigitGroupingSymbolArray, defaultDigitGroupingSymbolTypeName, numeral.defaultDigitGroupingSymbol);
|
return getNumeralSeparatorFormats(translateFn, numeralConstants.allDigitGroupingSymbol, numeralConstants.allDigitGroupingSymbolArray, defaultDigitGroupingSymbolTypeName, numeralConstants.defaultDigitGroupingSymbol);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getNumeralSeparatorFormats(translateFn, allSeparatorMap, allSeparatorArray, localeDefaultTypeName, systemDefaultType) {
|
function getNumeralSeparatorFormats(translateFn, allSeparatorMap, allSeparatorArray, localeDefaultTypeName, systemDefaultType) {
|
||||||
@@ -691,7 +691,7 @@ function getNumeralSeparatorFormats(translateFn, allSeparatorMap, allSeparatorAr
|
|||||||
const ret = [];
|
const ret = [];
|
||||||
|
|
||||||
ret.push({
|
ret.push({
|
||||||
type: numeral.defaultValue,
|
type: numeralConstants.defaultValue,
|
||||||
symbol: defaultSeparatorType.symbol,
|
symbol: defaultSeparatorType.symbol,
|
||||||
displayName: `${translateFn('Language Default')} (${defaultSeparatorType.symbol})`
|
displayName: `${translateFn('Language Default')} (${defaultSeparatorType.symbol})`
|
||||||
});
|
});
|
||||||
@@ -711,21 +711,21 @@ function getNumeralSeparatorFormats(translateFn, allSeparatorMap, allSeparatorAr
|
|||||||
|
|
||||||
function getAllDigitGroupingTypes(translateFn) {
|
function getAllDigitGroupingTypes(translateFn) {
|
||||||
const defaultDigitGroupingTypeName = translateFn('default.digitGrouping');
|
const defaultDigitGroupingTypeName = translateFn('default.digitGrouping');
|
||||||
let defaultDigitGroupingType = numeral.allDigitGroupingType[defaultDigitGroupingTypeName];
|
let defaultDigitGroupingType = numeralConstants.allDigitGroupingType[defaultDigitGroupingTypeName];
|
||||||
|
|
||||||
if (!defaultDigitGroupingType) {
|
if (!defaultDigitGroupingType) {
|
||||||
defaultDigitGroupingType = numeral.defaultDigitGroupingType;
|
defaultDigitGroupingType = numeralConstants.defaultDigitGroupingType;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ret = [];
|
const ret = [];
|
||||||
|
|
||||||
ret.push({
|
ret.push({
|
||||||
type: numeral.defaultValue,
|
type: numeralConstants.defaultValue,
|
||||||
displayName: `${translateFn('Language Default')} (${translateFn('numeral.' + defaultDigitGroupingType.name)})`
|
displayName: `${translateFn('Language Default')} (${translateFn('numeral.' + defaultDigitGroupingType.name)})`
|
||||||
});
|
});
|
||||||
|
|
||||||
for (let i = 0; i < numeral.allDigitGroupingTypeArray.length; i++) {
|
for (let i = 0; i < numeralConstants.allDigitGroupingTypeArray.length; i++) {
|
||||||
const type = numeral.allDigitGroupingTypeArray[i];
|
const type = numeralConstants.allDigitGroupingTypeArray[i];
|
||||||
|
|
||||||
ret.push({
|
ret.push({
|
||||||
type: type.type,
|
type: type.type,
|
||||||
@@ -738,10 +738,10 @@ function getAllDigitGroupingTypes(translateFn) {
|
|||||||
|
|
||||||
function getAllCurrencyDisplayTypes(userStore, settingsStore, translateFn) {
|
function getAllCurrencyDisplayTypes(userStore, settingsStore, translateFn) {
|
||||||
const defaultCurrencyDisplayTypeName = translateFn('default.currencyDisplayType');
|
const defaultCurrencyDisplayTypeName = translateFn('default.currencyDisplayType');
|
||||||
let defaultCurrencyDisplayType = currency.allCurrencyDisplayType[defaultCurrencyDisplayTypeName];
|
let defaultCurrencyDisplayType = currencyConstants.allCurrencyDisplayType[defaultCurrencyDisplayTypeName];
|
||||||
|
|
||||||
if (!defaultCurrencyDisplayType) {
|
if (!defaultCurrencyDisplayType) {
|
||||||
defaultCurrencyDisplayType = currency.defaultCurrencyDisplayType;
|
defaultCurrencyDisplayType = currencyConstants.defaultCurrencyDisplayType;
|
||||||
}
|
}
|
||||||
|
|
||||||
const defaultCurrency = userStore.currentUserDefaultCurrency;
|
const defaultCurrency = userStore.currentUserDefaultCurrency;
|
||||||
@@ -750,15 +750,15 @@ function getAllCurrencyDisplayTypes(userStore, settingsStore, translateFn) {
|
|||||||
const defaultSampleValue = getFormatedAmountWithCurrency(12345, defaultCurrency, translateFn, userStore, settingsStore, false, defaultCurrencyDisplayType);
|
const defaultSampleValue = getFormatedAmountWithCurrency(12345, defaultCurrency, translateFn, userStore, settingsStore, false, defaultCurrencyDisplayType);
|
||||||
|
|
||||||
ret.push({
|
ret.push({
|
||||||
type: currency.defaultCurrencyDisplayTypeValue,
|
type: currencyConstants.defaultCurrencyDisplayTypeValue,
|
||||||
displayName: `${translateFn('Language Default')} (${defaultSampleValue})`
|
displayName: `${translateFn('Language Default')} (${defaultSampleValue})`
|
||||||
});
|
});
|
||||||
|
|
||||||
for (let i = 0; i < currency.allCurrencyDisplayTypeArray.length; i++) {
|
for (let i = 0; i < currencyConstants.allCurrencyDisplayTypeArray.length; i++) {
|
||||||
const type = currency.allCurrencyDisplayTypeArray[i];
|
const type = currencyConstants.allCurrencyDisplayTypeArray[i];
|
||||||
let displayName = translateFn(type.name);
|
let displayName = translateFn(type.name);
|
||||||
|
|
||||||
if (type.symbol !== currency.allCurrencyDisplaySymbol.None) {
|
if (type.symbol !== currencyConstants.allCurrencyDisplaySymbol.None) {
|
||||||
const sampleValue = getFormatedAmountWithCurrency(12345, defaultCurrency, translateFn, userStore, settingsStore, false, type);
|
const sampleValue = getFormatedAmountWithCurrency(12345, defaultCurrency, translateFn, userStore, settingsStore, false, type);
|
||||||
displayName = `${displayName} (${sampleValue})`
|
displayName = `${displayName} (${sampleValue})`
|
||||||
}
|
}
|
||||||
@@ -773,14 +773,14 @@ function getAllCurrencyDisplayTypes(userStore, settingsStore, translateFn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getCurrentDecimalSeparator(translateFn, decimalSeparator) {
|
function getCurrentDecimalSeparator(translateFn, decimalSeparator) {
|
||||||
let decimalSeparatorType = numeral.allDecimalSeparatorMap[decimalSeparator];
|
let decimalSeparatorType = numeralConstants.allDecimalSeparatorMap[decimalSeparator];
|
||||||
|
|
||||||
if (!decimalSeparatorType) {
|
if (!decimalSeparatorType) {
|
||||||
const defaultDecimalSeparatorTypeName = translateFn('default.decimalSeparator');
|
const defaultDecimalSeparatorTypeName = translateFn('default.decimalSeparator');
|
||||||
decimalSeparatorType = numeral.allDecimalSeparator[defaultDecimalSeparatorTypeName];
|
decimalSeparatorType = numeralConstants.allDecimalSeparator[defaultDecimalSeparatorTypeName];
|
||||||
|
|
||||||
if (!decimalSeparatorType) {
|
if (!decimalSeparatorType) {
|
||||||
decimalSeparatorType = numeral.defaultDecimalSeparator;
|
decimalSeparatorType = numeralConstants.defaultDecimalSeparator;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -788,14 +788,14 @@ function getCurrentDecimalSeparator(translateFn, decimalSeparator) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getCurrentDigitGroupingSymbol(translateFn, digitGroupingSymbol) {
|
function getCurrentDigitGroupingSymbol(translateFn, digitGroupingSymbol) {
|
||||||
let digitGroupingSymbolType = numeral.allDigitGroupingSymbolMap[digitGroupingSymbol];
|
let digitGroupingSymbolType = numeralConstants.allDigitGroupingSymbolMap[digitGroupingSymbol];
|
||||||
|
|
||||||
if (!digitGroupingSymbolType) {
|
if (!digitGroupingSymbolType) {
|
||||||
const defaultDigitGroupingSymbolTypeName = translateFn('default.digitGroupingSymbol');
|
const defaultDigitGroupingSymbolTypeName = translateFn('default.digitGroupingSymbol');
|
||||||
digitGroupingSymbolType = numeral.allDigitGroupingSymbol[defaultDigitGroupingSymbolTypeName];
|
digitGroupingSymbolType = numeralConstants.allDigitGroupingSymbol[defaultDigitGroupingSymbolTypeName];
|
||||||
|
|
||||||
if (!digitGroupingSymbolType) {
|
if (!digitGroupingSymbolType) {
|
||||||
digitGroupingSymbolType = numeral.defaultDigitGroupingSymbol;
|
digitGroupingSymbolType = numeralConstants.defaultDigitGroupingSymbol;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -803,14 +803,14 @@ function getCurrentDigitGroupingSymbol(translateFn, digitGroupingSymbol) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getCurrentDigitGroupingType(translateFn, digitGrouping) {
|
function getCurrentDigitGroupingType(translateFn, digitGrouping) {
|
||||||
let digitGroupingType = numeral.allDigitGroupingTypeMap[digitGrouping];
|
let digitGroupingType = numeralConstants.allDigitGroupingTypeMap[digitGrouping];
|
||||||
|
|
||||||
if (!digitGroupingType) {
|
if (!digitGroupingType) {
|
||||||
const defaultDigitGroupingTypeName = translateFn('default.digitGrouping');
|
const defaultDigitGroupingTypeName = translateFn('default.digitGrouping');
|
||||||
digitGroupingType = numeral.allDigitGroupingType[defaultDigitGroupingTypeName];
|
digitGroupingType = numeralConstants.allDigitGroupingType[defaultDigitGroupingTypeName];
|
||||||
|
|
||||||
if (!digitGroupingType) {
|
if (!digitGroupingType) {
|
||||||
digitGroupingType = numeral.defaultDigitGroupingType;
|
digitGroupingType = numeralConstants.defaultDigitGroupingType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -875,15 +875,15 @@ function getFormatedAmountWithCurrency(value, currencyCode, translateFn, userSto
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!currencyDisplayType) {
|
if (!currencyDisplayType) {
|
||||||
currencyDisplayType = currency.allCurrencyDisplayTypeMap[userStore.currentUserCurrencyDisplayType];
|
currencyDisplayType = currencyConstants.allCurrencyDisplayTypeMap[userStore.currentUserCurrencyDisplayType];
|
||||||
|
|
||||||
if (!currencyDisplayType) {
|
if (!currencyDisplayType) {
|
||||||
const defaultCurrencyDisplayTypeName = translateFn('default.currencyDisplayType');
|
const defaultCurrencyDisplayTypeName = translateFn('default.currencyDisplayType');
|
||||||
currencyDisplayType = currency.allCurrencyDisplayType[defaultCurrencyDisplayTypeName];
|
currencyDisplayType = currencyConstants.allCurrencyDisplayType[defaultCurrencyDisplayTypeName];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!currencyDisplayType) {
|
if (!currencyDisplayType) {
|
||||||
currencyDisplayType = currency.defaultCurrencyDisplayType;
|
currencyDisplayType = currencyConstants.defaultCurrencyDisplayType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -930,8 +930,8 @@ function getAmountPrependAndAppendText(currencyCode, translateFn, userStore, set
|
|||||||
function getAllAccountCategories(translateFn) {
|
function getAllAccountCategories(translateFn) {
|
||||||
const allAccountCategories = [];
|
const allAccountCategories = [];
|
||||||
|
|
||||||
for (let i = 0; i < account.allCategories.length; i++) {
|
for (let i = 0; i < accountConstants.allCategories.length; i++) {
|
||||||
const accountCategory = account.allCategories[i];
|
const accountCategory = accountConstants.allCategories[i];
|
||||||
|
|
||||||
allAccountCategories.push({
|
allAccountCategories.push({
|
||||||
id: accountCategory.id,
|
id: accountCategory.id,
|
||||||
@@ -946,8 +946,8 @@ function getAllAccountCategories(translateFn) {
|
|||||||
function getAllAccountTypes(translateFn) {
|
function getAllAccountTypes(translateFn) {
|
||||||
const allAccountTypes = [];
|
const allAccountTypes = [];
|
||||||
|
|
||||||
for (let i = 0; i < account.allAccountTypesArray.length; i++) {
|
for (let i = 0; i < accountConstants.allAccountTypesArray.length; i++) {
|
||||||
const accountType = account.allAccountTypesArray[i];
|
const accountType = accountConstants.allAccountTypesArray[i];
|
||||||
|
|
||||||
allAccountTypes.push({
|
allAccountTypes.push({
|
||||||
id: accountType.id,
|
id: accountType.id,
|
||||||
@@ -961,8 +961,8 @@ function getAllAccountTypes(translateFn) {
|
|||||||
function getAllCategoricalChartTypes(translateFn) {
|
function getAllCategoricalChartTypes(translateFn) {
|
||||||
const allChartTypes = [];
|
const allChartTypes = [];
|
||||||
|
|
||||||
for (let i = 0; i < statistics.allCategoricalChartTypesArray.length; i++) {
|
for (let i = 0; i < statisticsConstants.allCategoricalChartTypesArray.length; i++) {
|
||||||
const chartType = statistics.allCategoricalChartTypesArray[i];
|
const chartType = statisticsConstants.allCategoricalChartTypesArray[i];
|
||||||
|
|
||||||
allChartTypes.push({
|
allChartTypes.push({
|
||||||
type: chartType.type,
|
type: chartType.type,
|
||||||
@@ -976,8 +976,8 @@ function getAllCategoricalChartTypes(translateFn) {
|
|||||||
function getAllTrendChartTypes(translateFn) {
|
function getAllTrendChartTypes(translateFn) {
|
||||||
const allChartTypes = [];
|
const allChartTypes = [];
|
||||||
|
|
||||||
for (let i = 0; i < statistics.allTrendChartTypesArray.length; i++) {
|
for (let i = 0; i < statisticsConstants.allTrendChartTypesArray.length; i++) {
|
||||||
const chartType = statistics.allTrendChartTypesArray[i];
|
const chartType = statisticsConstants.allTrendChartTypesArray[i];
|
||||||
|
|
||||||
allChartTypes.push({
|
allChartTypes.push({
|
||||||
type: chartType.type,
|
type: chartType.type,
|
||||||
@@ -991,12 +991,12 @@ function getAllTrendChartTypes(translateFn) {
|
|||||||
function getAllStatisticsChartDataTypes(translateFn) {
|
function getAllStatisticsChartDataTypes(translateFn) {
|
||||||
const allChartDataTypes = [];
|
const allChartDataTypes = [];
|
||||||
|
|
||||||
for (const dataTypeField in statistics.allChartDataTypes) {
|
for (const dataTypeField in statisticsConstants.allChartDataTypes) {
|
||||||
if (!Object.prototype.hasOwnProperty.call(statistics.allChartDataTypes, dataTypeField)) {
|
if (!Object.prototype.hasOwnProperty.call(statisticsConstants.allChartDataTypes, dataTypeField)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const chartDataType = statistics.allChartDataTypes[dataTypeField];
|
const chartDataType = statisticsConstants.allChartDataTypes[dataTypeField];
|
||||||
|
|
||||||
allChartDataTypes.push({
|
allChartDataTypes.push({
|
||||||
type: chartDataType.type,
|
type: chartDataType.type,
|
||||||
@@ -1011,12 +1011,12 @@ function getAllStatisticsChartDataTypes(translateFn) {
|
|||||||
function getAllStatisticsSortingTypes(translateFn) {
|
function getAllStatisticsSortingTypes(translateFn) {
|
||||||
const allSortingTypes = [];
|
const allSortingTypes = [];
|
||||||
|
|
||||||
for (const sortingTypeField in statistics.allSortingTypes) {
|
for (const sortingTypeField in statisticsConstants.allSortingTypes) {
|
||||||
if (!Object.prototype.hasOwnProperty.call(statistics.allSortingTypes, sortingTypeField)) {
|
if (!Object.prototype.hasOwnProperty.call(statisticsConstants.allSortingTypes, sortingTypeField)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const sortingType = statistics.allSortingTypes[sortingTypeField];
|
const sortingType = statisticsConstants.allSortingTypes[sortingTypeField];
|
||||||
|
|
||||||
allSortingTypes.push({
|
allSortingTypes.push({
|
||||||
type: sortingType.type,
|
type: sortingType.type,
|
||||||
@@ -1058,7 +1058,7 @@ function getAllTransactionDefaultCategories(categoryType, locale, translateFn) {
|
|||||||
const categoryTypes = [];
|
const categoryTypes = [];
|
||||||
|
|
||||||
if (categoryType === 0) {
|
if (categoryType === 0) {
|
||||||
for (let i = category.allCategoryTypes.Income; i <= category.allCategoryTypes.Transfer; i++) {
|
for (let i = categoryConstants.allCategoryTypes.Income; i <= categoryConstants.allCategoryTypes.Transfer; i++) {
|
||||||
categoryTypes.push(i);
|
categoryTypes.push(i);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -1070,12 +1070,12 @@ function getAllTransactionDefaultCategories(categoryType, locale, translateFn) {
|
|||||||
const categoryType = categoryTypes[i];
|
const categoryType = categoryTypes[i];
|
||||||
let defaultCategories = [];
|
let defaultCategories = [];
|
||||||
|
|
||||||
if (categoryType === category.allCategoryTypes.Income) {
|
if (categoryType === categoryConstants.allCategoryTypes.Income) {
|
||||||
defaultCategories = copyArrayTo(category.defaultIncomeCategories, []);
|
defaultCategories = copyArrayTo(categoryConstants.defaultIncomeCategories, []);
|
||||||
} else if (categoryType === category.allCategoryTypes.Expense) {
|
} else if (categoryType === categoryConstants.allCategoryTypes.Expense) {
|
||||||
defaultCategories = copyArrayTo(category.defaultExpenseCategories, []);
|
defaultCategories = copyArrayTo(categoryConstants.defaultExpenseCategories, []);
|
||||||
} else if (categoryType === category.allCategoryTypes.Transfer) {
|
} else if (categoryType === categoryConstants.allCategoryTypes.Transfer) {
|
||||||
defaultCategories = copyArrayTo(category.defaultTransferCategories, []);
|
defaultCategories = copyArrayTo(categoryConstants.defaultTransferCategories, []);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let j = 0; j < defaultCategories.length; j++) {
|
for (let j = 0; j < defaultCategories.length; j++) {
|
||||||
@@ -1218,20 +1218,20 @@ function joinMultiText(textArray, translateFn) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function getLocalizedError(error) {
|
function getLocalizedError(error) {
|
||||||
if (error.errorCode === api.apiNotFoundErrorCode && api.specifiedApiNotFoundErrors[error.path]) {
|
if (error.errorCode === apiConstants.apiNotFoundErrorCode && apiConstants.specifiedApiNotFoundErrors[error.path]) {
|
||||||
return {
|
return {
|
||||||
message: `${api.specifiedApiNotFoundErrors[error.path].message}`
|
message: `${apiConstants.specifiedApiNotFoundErrors[error.path].message}`
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
if (error.errorCode !== api.validatorErrorCode) {
|
if (error.errorCode !== apiConstants.validatorErrorCode) {
|
||||||
return {
|
return {
|
||||||
message: `error.${error.errorMessage}`
|
message: `error.${error.errorMessage}`
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let i = 0; i < api.parameterizedErrors.length; i++) {
|
for (let i = 0; i < apiConstants.parameterizedErrors.length; i++) {
|
||||||
const errorInfo = api.parameterizedErrors[i];
|
const errorInfo = apiConstants.parameterizedErrors[i];
|
||||||
const matches = error.errorMessage.match(errorInfo.regex);
|
const matches = error.errorMessage.match(errorInfo.regex);
|
||||||
|
|
||||||
if (matches && matches.length === errorInfo.parameters.length + 1) {
|
if (matches && matches.length === errorInfo.parameters.length + 1) {
|
||||||
@@ -1309,10 +1309,10 @@ function setLanguage(i18nGlobal, locale, force) {
|
|||||||
|
|
||||||
const defaultCurrency = getDefaultCurrency(i18nGlobal.t);
|
const defaultCurrency = getDefaultCurrency(i18nGlobal.t);
|
||||||
const defaultFirstDayOfWeekName = getDefaultFirstDayOfWeek(i18nGlobal.t);
|
const defaultFirstDayOfWeekName = getDefaultFirstDayOfWeek(i18nGlobal.t);
|
||||||
let defaultFirstDayOfWeek = datetime.defaultFirstDayOfWeek;
|
let defaultFirstDayOfWeek = datetimeConstants.defaultFirstDayOfWeek;
|
||||||
|
|
||||||
if (datetime.allWeekDays[defaultFirstDayOfWeekName]) {
|
if (datetimeConstants.allWeekDays[defaultFirstDayOfWeekName]) {
|
||||||
defaultFirstDayOfWeek = datetime.allWeekDays[defaultFirstDayOfWeekName].type;
|
defaultFirstDayOfWeek = datetimeConstants.allWeekDays[defaultFirstDayOfWeekName].type;
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
+9
-9
@@ -1,6 +1,6 @@
|
|||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
|
|
||||||
import api from '@/consts/api.js';
|
import apiConstants from '@/consts/api.js';
|
||||||
import userState from './userstate.js';
|
import userState from './userstate.js';
|
||||||
import {
|
import {
|
||||||
getGoogleMapAPIKey,
|
getGoogleMapAPIKey,
|
||||||
@@ -12,8 +12,8 @@ import { getTimezoneOffsetMinutes } from './datetime.js';
|
|||||||
let needBlockRequest = false;
|
let needBlockRequest = false;
|
||||||
let blockedRequests = [];
|
let blockedRequests = [];
|
||||||
|
|
||||||
axios.defaults.baseURL = api.baseApiUrlPath;
|
axios.defaults.baseURL = apiConstants.baseApiUrlPath;
|
||||||
axios.defaults.timeout = api.defaultTimeout;
|
axios.defaults.timeout = apiConstants.defaultTimeout;
|
||||||
axios.interceptors.request.use(config => {
|
axios.interceptors.request.use(config => {
|
||||||
const token = userState.getToken();
|
const token = userState.getToken();
|
||||||
|
|
||||||
@@ -508,11 +508,11 @@ export default {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
generateQrCodeUrl: (qrCodeName) => {
|
generateQrCodeUrl: (qrCodeName) => {
|
||||||
return `${api.baseQrcodePath}/${qrCodeName}.png`;
|
return `${apiConstants.baseQrcodePath}/${qrCodeName}.png`;
|
||||||
},
|
},
|
||||||
generateMapProxyTileImageUrl: (mapProvider, language) => {
|
generateMapProxyTileImageUrl: (mapProvider, language) => {
|
||||||
const token = userState.getToken();
|
const token = userState.getToken();
|
||||||
let url = `${api.baseProxyUrlPath}/map/tile/{z}/{x}/{y}.png?provider=${mapProvider}&token=${token}`;
|
let url = `${apiConstants.baseProxyUrlPath}/map/tile/{z}/{x}/{y}.png?provider=${mapProvider}&token=${token}`;
|
||||||
|
|
||||||
if (language) {
|
if (language) {
|
||||||
url = url + `&language=${language}`;
|
url = url + `&language=${language}`;
|
||||||
@@ -521,7 +521,7 @@ export default {
|
|||||||
return url;
|
return url;
|
||||||
},
|
},
|
||||||
generateGoogleMapJavascriptUrl: (language, callbackFnName) => {
|
generateGoogleMapJavascriptUrl: (language, callbackFnName) => {
|
||||||
let url = `${api.googleMapJavascriptUrl}?key=${getGoogleMapAPIKey()}&libraries=core,marker&callback=${callbackFnName}`;
|
let url = `${apiConstants.googleMapJavascriptUrl}?key=${getGoogleMapAPIKey()}&libraries=core,marker&callback=${callbackFnName}`;
|
||||||
|
|
||||||
if (language) {
|
if (language) {
|
||||||
url = url + `&language=${language}`;
|
url = url + `&language=${language}`;
|
||||||
@@ -530,12 +530,12 @@ export default {
|
|||||||
return url;
|
return url;
|
||||||
},
|
},
|
||||||
generateBaiduMapJavascriptUrl: (callbackFnName) => {
|
generateBaiduMapJavascriptUrl: (callbackFnName) => {
|
||||||
return `${api.baiduMapJavascriptUrl}&ak=${getBaiduMapAK()}&callback=${callbackFnName}`;
|
return `${apiConstants.baiduMapJavascriptUrl}&ak=${getBaiduMapAK()}&callback=${callbackFnName}`;
|
||||||
},
|
},
|
||||||
generateAmapJavascriptUrl: (callbackFnName) => {
|
generateAmapJavascriptUrl: (callbackFnName) => {
|
||||||
return `${api.amapJavascriptUrl}&key=${getAmapApplicationKey()}&plugin=AMap.ToolBar&callback=${callbackFnName}`;
|
return `${apiConstants.amapJavascriptUrl}&key=${getAmapApplicationKey()}&plugin=AMap.ToolBar&callback=${callbackFnName}`;
|
||||||
},
|
},
|
||||||
generateAmapApiInternalProxyUrl: () => {
|
generateAmapApiInternalProxyUrl: () => {
|
||||||
return `${window.location.origin}${api.baseAmapApiProxyUrlPath}`;
|
return `${window.location.origin}${apiConstants.baseAmapApiProxyUrlPath}`;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user