mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-15 23:47:33 +08:00
migrate to typescript
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
<script>
|
||||
import {
|
||||
copyObjectTo
|
||||
} from '@/lib/common.js';
|
||||
} from '@/lib/common.ts';
|
||||
import {
|
||||
createMapHolder,
|
||||
initMapInstance,
|
||||
|
||||
@@ -34,8 +34,8 @@ import { mapStores } from 'pinia';
|
||||
import { useSettingsStore } from '@/stores/setting.js';
|
||||
import { useUserStore } from '@/stores/user.js';
|
||||
|
||||
import transactionConstants from '@/consts/transaction.js';
|
||||
import { removeAll } from '@/lib/common.js';
|
||||
import { TRANSACTION_MIN_AMOUNT, TRANSACTION_MAX_AMOUNT } from '@/consts/transaction.ts';
|
||||
import { removeAll } from '@/lib/common.ts';
|
||||
import logger from '@/lib/logger.js';
|
||||
|
||||
export default {
|
||||
@@ -76,7 +76,7 @@ export default {
|
||||
return self.$t('Amount value is not number');
|
||||
}
|
||||
|
||||
return (val >= transactionConstants.minAmountNumber && val <= transactionConstants.maxAmountNumber) || self.$t('Amount value exceeds limitation');
|
||||
return (val >= TRANSACTION_MIN_AMOUNT && val <= TRANSACTION_MAX_AMOUNT) || self.$t('Amount value exceeds limitation');
|
||||
} catch (ex) {
|
||||
logger.warn('cannot parse amount in amount input, original value is ' + v, ex);
|
||||
return self.$t('Amount value is not number');
|
||||
@@ -222,7 +222,7 @@ export default {
|
||||
}
|
||||
|
||||
let decimalLength = 0;
|
||||
let decimalIndex = str.indexOf(decimalSeparator);
|
||||
const decimalIndex = str.indexOf(decimalSeparator);
|
||||
|
||||
if (decimalIndex >= 0) {
|
||||
decimalLength = str.length - str.indexOf(decimalSeparator) - 1;
|
||||
@@ -285,16 +285,16 @@ export default {
|
||||
e.preventDefault();
|
||||
},
|
||||
getValidFormattedValue(value, textualValue, hasDecimalSeparator) {
|
||||
let maxLength = transactionConstants.maxAmountNumber.toString().length;
|
||||
let maxLength = TRANSACTION_MAX_AMOUNT.toString().length;
|
||||
|
||||
if (value < 0) {
|
||||
maxLength = transactionConstants.minAmountNumber.toString().length;
|
||||
maxLength = TRANSACTION_MIN_AMOUNT.toString().length;
|
||||
}
|
||||
|
||||
if (value < transactionConstants.minAmountNumber) {
|
||||
return this.getFormattedValue(this.userStore, transactionConstants.minAmountNumber);
|
||||
} else if (value > transactionConstants.maxAmountNumber) {
|
||||
return this.getFormattedValue(this.userStore, transactionConstants.maxAmountNumber);
|
||||
if (value < TRANSACTION_MIN_AMOUNT) {
|
||||
return this.getFormattedValue(this.userStore, TRANSACTION_MIN_AMOUNT);
|
||||
} else if (value > TRANSACTION_MAX_AMOUNT) {
|
||||
return this.getFormattedValue(this.userStore, TRANSACTION_MAX_AMOUNT);
|
||||
}
|
||||
|
||||
if (!hasDecimalSeparator && textualValue.length > maxLength) {
|
||||
|
||||
@@ -39,10 +39,10 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import colorConstants from '@/consts/color.js';
|
||||
import { arrayContainsFieldValue } from '@/lib/common.js';
|
||||
import { getColorsInRows } from '@/lib/color.js';
|
||||
import { scrollToSelectedItem } from '@/lib/ui.desktop.js';
|
||||
import { DEFAULT_ICON_COLOR } from '@/consts/color.ts';
|
||||
import { arrayContainsFieldValue } from '@/lib/common.ts';
|
||||
import { getColorsInRows } from '@/lib/color.ts';
|
||||
import { scrollToSelectedItem } from '@/lib/ui/desktop.js';
|
||||
|
||||
import {
|
||||
mdiSquareRounded,
|
||||
@@ -89,7 +89,7 @@ export default {
|
||||
return arrayContainsFieldValue(row, 'id', this.modelValue);
|
||||
},
|
||||
getFinalColor(color) {
|
||||
if (color && color !== colorConstants.defaultAccountColor) {
|
||||
if (color && color !== DEFAULT_ICON_COLOR) {
|
||||
return '#' + color;
|
||||
} else {
|
||||
return 'var(--default-icon-color)';
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { isString } from '@/lib/common.js';
|
||||
import { isString } from '@/lib/common.ts';
|
||||
|
||||
export default {
|
||||
props: [
|
||||
|
||||
@@ -60,7 +60,8 @@ import { mapStores } from 'pinia';
|
||||
import { useUserStore } from '@/stores/user.js';
|
||||
|
||||
import datetimeConstants from '@/consts/datetime.js';
|
||||
import { arrangeArrayWithNewStartIndex } from '@/lib/common.js';
|
||||
import { ThemeType } from '@/core/theme.ts';
|
||||
import { arrangeArrayWithNewStartIndex } from '@/lib/common.ts';
|
||||
import {
|
||||
getCurrentUnixTime,
|
||||
getCurrentYear,
|
||||
@@ -122,7 +123,7 @@ export default {
|
||||
}
|
||||
},
|
||||
isDarkMode() {
|
||||
return this.globalTheme.global.name.value === 'dark';
|
||||
return this.globalTheme.global.name.value === ThemeType.Dark;
|
||||
},
|
||||
firstDayOfWeek() {
|
||||
return this.userStore.currentUserFirstDayOfWeek;
|
||||
|
||||
@@ -43,7 +43,8 @@ import { useTheme } from 'vuetify';
|
||||
import { mapStores } from 'pinia';
|
||||
import { useUserStore } from '@/stores/user.js';
|
||||
|
||||
import { arrangeArrayWithNewStartIndex } from '@/lib/common.js';
|
||||
import { ThemeType } from '@/core/theme.ts';
|
||||
import { arrangeArrayWithNewStartIndex } from '@/lib/common.ts';
|
||||
import {
|
||||
getCurrentYear,
|
||||
getTimezoneOffsetMinutes,
|
||||
@@ -90,7 +91,7 @@ export default {
|
||||
}
|
||||
},
|
||||
isDarkMode() {
|
||||
return this.globalTheme.global.name.value === 'dark';
|
||||
return this.globalTheme.global.name.value === ThemeType.Dark;
|
||||
},
|
||||
firstDayOfWeek() {
|
||||
return this.userStore.currentUserFirstDayOfWeek;
|
||||
|
||||
@@ -37,9 +37,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { arrayContainsFieldValue } from '@/lib/common.js';
|
||||
import { getIconsInRows } from '@/lib/icon.js';
|
||||
import { scrollToSelectedItem } from '@/lib/ui.desktop.js';
|
||||
import { arrayContainsFieldValue } from '@/lib/common.ts';
|
||||
import { getIconsInRows } from '@/lib/icon.ts';
|
||||
import { scrollToSelectedItem } from '@/lib/ui/desktop.js';
|
||||
|
||||
import {
|
||||
mdiCheck
|
||||
|
||||
@@ -12,9 +12,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import iconConstants from '@/consts/icon.js';
|
||||
import colorConstants from '@/consts/color.js';
|
||||
import { isNumber } from '@/lib/common.js';
|
||||
import { ALL_ACCOUNT_ICONS, DEFAULT_ACCOUNT_ICON, ALL_CATEGORY_ICONS, DEFAULT_CATEGORY_ICON } from '@/consts/icon.ts';
|
||||
import { DEFAULT_ICON_COLOR, DEFAULT_ACCOUNT_COLOR, DEFAULT_CATEGORY_COLOR } from '@/consts/color.ts';
|
||||
import { isNumber } from '@/lib/common.ts';
|
||||
|
||||
import {
|
||||
mdiEyeOffOutline
|
||||
@@ -74,25 +74,25 @@ export default {
|
||||
iconId = iconId.toString();
|
||||
}
|
||||
|
||||
if (!iconConstants.allAccountIcons[iconId]) {
|
||||
return iconConstants.defaultAccountIcon.icon;
|
||||
if (!ALL_ACCOUNT_ICONS[iconId]) {
|
||||
return DEFAULT_ACCOUNT_ICON.icon;
|
||||
}
|
||||
|
||||
return iconConstants.allAccountIcons[iconId].icon;
|
||||
return ALL_ACCOUNT_ICONS[iconId].icon;
|
||||
},
|
||||
getCategoryIcon(iconId) {
|
||||
if (isNumber(iconId)) {
|
||||
iconId = iconId.toString();
|
||||
}
|
||||
|
||||
if (!iconConstants.allCategoryIcons[iconId]) {
|
||||
return iconConstants.defaultCategoryIcon.icon;
|
||||
if (!ALL_CATEGORY_ICONS[iconId]) {
|
||||
return DEFAULT_CATEGORY_ICON.icon;
|
||||
}
|
||||
|
||||
return iconConstants.allCategoryIcons[iconId].icon;
|
||||
return ALL_CATEGORY_ICONS[iconId].icon;
|
||||
},
|
||||
getAccountIconStyle(color, defaultColor, additionalColorAttr) {
|
||||
if (color && color !== colorConstants.defaultAccountColor) {
|
||||
if (color && color !== DEFAULT_ACCOUNT_COLOR) {
|
||||
color = '#' + color;
|
||||
} else {
|
||||
color = defaultColor;
|
||||
@@ -113,7 +113,7 @@ export default {
|
||||
return ret;
|
||||
},
|
||||
getCategoryIconStyle(color, defaultColor, additionalColorAttr) {
|
||||
if (color && color !== colorConstants.defaultCategoryColor) {
|
||||
if (color && color !== DEFAULT_CATEGORY_COLOR) {
|
||||
color = '#' + color;
|
||||
} else {
|
||||
color = defaultColor;
|
||||
@@ -134,7 +134,7 @@ export default {
|
||||
return ret;
|
||||
},
|
||||
getDefaultIconStyle(color, defaultColor, additionalColorAttr) {
|
||||
if (color && color !== colorConstants.defaultColor) {
|
||||
if (color && color !== DEFAULT_ICON_COLOR) {
|
||||
color = '#' + color;
|
||||
} else {
|
||||
color = defaultColor;
|
||||
|
||||
@@ -69,6 +69,7 @@ import { useTheme } from 'vuetify';
|
||||
import { mapStores } from 'pinia';
|
||||
import { useUserStore } from '@/stores/user.js';
|
||||
|
||||
import { ThemeType } from '@/core/theme.ts';
|
||||
import {
|
||||
getYearMonthObjectFromString,
|
||||
getYearMonthStringFromObject,
|
||||
@@ -125,7 +126,7 @@ export default {
|
||||
}
|
||||
},
|
||||
isDarkMode() {
|
||||
return this.globalTheme.global.name.value === 'dark';
|
||||
return this.globalTheme.global.name.value === ThemeType.Dark;
|
||||
},
|
||||
isYearFirst() {
|
||||
return this.$locale.isLongDateMonthAfterYear(this.userStore);
|
||||
|
||||
@@ -10,7 +10,8 @@ import { mapStores } from 'pinia';
|
||||
import { useSettingsStore } from '@/stores/setting.js';
|
||||
import { useUserStore } from '@/stores/user.js';
|
||||
|
||||
import colorConstants from '@/consts/color.js';
|
||||
import { DEFAULT_ICON_COLOR, DEFAULT_CHART_COLORS } from '@/consts/color.ts';
|
||||
import { ThemeType } from '@/core/theme.ts';
|
||||
import { formatPercent } from '@/lib/numeral.js';
|
||||
|
||||
export default {
|
||||
@@ -40,7 +41,7 @@ export default {
|
||||
computed: {
|
||||
...mapStores(useSettingsStore, useUserStore),
|
||||
isDarkMode() {
|
||||
return this.globalTheme.global.name.value === 'dark';
|
||||
return this.globalTheme.global.name.value === ThemeType.Dark;
|
||||
},
|
||||
itemsMap: function () {
|
||||
const map = {};
|
||||
@@ -87,7 +88,7 @@ export default {
|
||||
percent: (item[this.percentField] > 0 || item[this.percentField] === 0 || item[this.percentField] === '0') ? item[this.percentField] : (item[this.valueField] / totalValidValue * 100),
|
||||
actualPercent: item[this.valueField] / totalValidValue,
|
||||
itemStyle: {
|
||||
color: this.getColor(item[this.colorField] ? item[this.colorField] : colorConstants.defaultChartColors[validItems.length % colorConstants.defaultChartColors.length]),
|
||||
color: this.getColor(item[this.colorField] ? item[this.colorField] : DEFAULT_CHART_COLORS[validItems.length % DEFAULT_CHART_COLORS.length]),
|
||||
},
|
||||
selected: true,
|
||||
sourceItem: item
|
||||
@@ -283,7 +284,7 @@ export default {
|
||||
}
|
||||
},
|
||||
getColor: function (color) {
|
||||
if (color && color !== colorConstants.defaultColor) {
|
||||
if (color && color !== DEFAULT_ICON_COLOR) {
|
||||
color = '#' + color;
|
||||
}
|
||||
|
||||
|
||||
@@ -58,9 +58,9 @@
|
||||
import { mapStores } from 'pinia';
|
||||
import { useUserStore } from '@/stores/user.js';
|
||||
|
||||
import templateConstants from '@/consts/template.js';
|
||||
import { sortNumbersArray } from '@/lib/common.js';
|
||||
import { scrollToSelectedItem } from '@/lib/ui.desktop.js';
|
||||
import { ScheduledTemplateFrequencyType } from '@/core/template.ts';
|
||||
import { sortNumbersArray } from '@/lib/common.ts';
|
||||
import { scrollToSelectedItem } from '@/lib/ui/desktop.js';
|
||||
|
||||
export default {
|
||||
props: [
|
||||
@@ -85,7 +85,7 @@ export default {
|
||||
return this.$locale.getAllTransactionScheduledFrequencyTypes();
|
||||
},
|
||||
allTemplateScheduledFrequencyTypes() {
|
||||
return templateConstants.allTemplateScheduledFrequencyTypes;
|
||||
return ScheduledTemplateFrequencyType.all();
|
||||
},
|
||||
allWeekDays() {
|
||||
return this.$locale.getAllWeekDays(this.firstDayOfWeek);
|
||||
@@ -113,9 +113,9 @@ export default {
|
||||
if (this.type !== value) {
|
||||
this.$emit('update:type', value);
|
||||
|
||||
if (value === templateConstants.allTemplateScheduledFrequencyTypes.Weekly.type) {
|
||||
if (value === ScheduledTemplateFrequencyType.Weekly.type) {
|
||||
this.frequencyValue = [this.firstDayOfWeek];
|
||||
} else if (value === templateConstants.allTemplateScheduledFrequencyTypes.Monthly.type) {
|
||||
} else if (value === ScheduledTemplateFrequencyType.Monthly.type) {
|
||||
this.frequencyValue = [1];
|
||||
} else {
|
||||
this.frequencyValue = [];
|
||||
@@ -141,9 +141,9 @@ export default {
|
||||
}
|
||||
},
|
||||
displayFrequency() {
|
||||
if (this.type === templateConstants.allTemplateScheduledFrequencyTypes.Disabled.type) {
|
||||
if (this.type === ScheduledTemplateFrequencyType.Disabled.type) {
|
||||
return this.$t('Disabled');
|
||||
} else if (this.type === templateConstants.allTemplateScheduledFrequencyTypes.Weekly.type) {
|
||||
} else if (this.type === ScheduledTemplateFrequencyType.Weekly.type) {
|
||||
if (this.frequencyValue.length) {
|
||||
return this.$t('format.misc.everyMultiDaysOfWeek', {
|
||||
days: this.$locale.getMultiWeekdayLongNames(this.frequencyValue, this.firstDayOfWeek)
|
||||
@@ -151,7 +151,7 @@ export default {
|
||||
} else {
|
||||
return this.$t('Weekly');
|
||||
}
|
||||
} else if (this.type === templateConstants.allTemplateScheduledFrequencyTypes.Monthly.type) {
|
||||
} else if (this.type === ScheduledTemplateFrequencyType.Monthly.type) {
|
||||
if (this.frequencyValue.length) {
|
||||
return this.$t('format.misc.everyMultiDaysOfMonth', {
|
||||
days: this.$locale.getMultiMonthdayShortNames(this.frequencyValue)
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
<script>
|
||||
import { getMobileUrlQrCodePath } from '@/lib/qrcode.js';
|
||||
import { getMobileVersionPath } from '@/lib/version.js';
|
||||
import { getMobileVersionPath } from '@/lib/version.ts';
|
||||
|
||||
export default {
|
||||
props: [
|
||||
|
||||
@@ -10,13 +10,14 @@ import { mapStores } from 'pinia';
|
||||
import { useSettingsStore } from '@/stores/setting.js';
|
||||
import { useUserStore } from '@/stores/user.js';
|
||||
|
||||
import colorConstants from '@/consts/color.js';
|
||||
import { DEFAULT_ICON_COLOR, DEFAULT_CHART_COLORS } from '@/consts/color.ts';
|
||||
import datetimeConstants from '@/consts/datetime.js';
|
||||
import statisticsConstants from '@/consts/statistics.js';
|
||||
import { ThemeType } from '@/core/theme.ts';
|
||||
import {
|
||||
isArray,
|
||||
isNumber
|
||||
} from '@/lib/common.js';
|
||||
} from '@/lib/common.ts';
|
||||
import {
|
||||
getYearMonthFirstUnixTime,
|
||||
getYearMonthLastUnixTime,
|
||||
@@ -59,7 +60,7 @@ export default {
|
||||
computed: {
|
||||
...mapStores(useSettingsStore, useUserStore),
|
||||
isDarkMode() {
|
||||
return this.globalTheme.global.name.value === 'dark';
|
||||
return this.globalTheme.global.name.value === ThemeType.Dark;
|
||||
},
|
||||
itemsMap: function () {
|
||||
const map = {};
|
||||
@@ -167,7 +168,7 @@ export default {
|
||||
id: (this.idField && item[this.idField]) ? item[this.idField] : this.getItemName(item[this.nameField]),
|
||||
name: (this.idField && item[this.idField]) ? item[this.idField] : this.getItemName(item[this.nameField]),
|
||||
itemStyle: {
|
||||
color: this.getColor(item[this.colorField] ? item[this.colorField] : colorConstants.defaultChartColors[i % colorConstants.defaultChartColors.length]),
|
||||
color: this.getColor(item[this.colorField] ? item[this.colorField] : DEFAULT_CHART_COLORS[i % DEFAULT_CHART_COLORS.length]),
|
||||
},
|
||||
selected: true,
|
||||
type: 'line',
|
||||
@@ -212,7 +213,7 @@ export default {
|
||||
|
||||
const maxValueText = this.getDisplayCurrency(maxValue, this.defaultCurrency);
|
||||
const minValueText = this.getDisplayCurrency(minValue, this.defaultCurrency);
|
||||
let maxLengthText = maxValueText.length > minValueText.length ? maxValueText : minValueText;
|
||||
const maxLengthText = maxValueText.length > minValueText.length ? maxValueText : minValueText;
|
||||
|
||||
const canvas = document.createElement('canvas');
|
||||
const context = canvas.getContext('2d');
|
||||
@@ -387,7 +388,7 @@ export default {
|
||||
});
|
||||
},
|
||||
getColor: function (color) {
|
||||
if (color && color !== colorConstants.defaultColor) {
|
||||
if (color && color !== DEFAULT_ICON_COLOR) {
|
||||
color = '#' + color;
|
||||
}
|
||||
|
||||
|
||||
@@ -79,8 +79,8 @@ import {
|
||||
getItemByKeyValue,
|
||||
getNameByKeyValue,
|
||||
getPrimaryValueBySecondaryValue
|
||||
} from '@/lib/common.js';
|
||||
import { scrollToSelectedItem } from '@/lib/ui.desktop.js';
|
||||
} from '@/lib/common.ts';
|
||||
import { scrollToSelectedItem } from '@/lib/ui/desktop.js';
|
||||
|
||||
import {
|
||||
mdiChevronRight
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { arrayContainsFieldValue } from '@/lib/common.js';
|
||||
import { getColorsInRows } from '@/lib/color.js';
|
||||
import { scrollToSelectedItem } from '@/lib/ui.mobile.js';
|
||||
import { arrayContainsFieldValue } from '@/lib/common.ts';
|
||||
import { getColorsInRows } from '@/lib/color.ts';
|
||||
import { scrollToSelectedItem } from '@/lib/ui/mobile.js';
|
||||
|
||||
export default {
|
||||
props: [
|
||||
|
||||
@@ -57,7 +57,7 @@ import { mapStores } from 'pinia';
|
||||
import { useUserStore } from '@/stores/user.js';
|
||||
|
||||
import datetimeConstants from '@/consts/datetime.js';
|
||||
import { arrangeArrayWithNewStartIndex } from '@/lib/common.js';
|
||||
import { arrangeArrayWithNewStartIndex } from '@/lib/common.ts';
|
||||
import {
|
||||
getCurrentUnixTime,
|
||||
getCurrentYear,
|
||||
|
||||
@@ -53,7 +53,7 @@ import { mapStores } from 'pinia';
|
||||
import { useUserStore } from '@/stores/user.js';
|
||||
|
||||
import datetimeConstants from '@/consts/datetime.js';
|
||||
import { arrangeArrayWithNewStartIndex } from '@/lib/common.js';
|
||||
import { arrangeArrayWithNewStartIndex } from '@/lib/common.ts';
|
||||
import {
|
||||
getCurrentUnixTime,
|
||||
getCurrentYear,
|
||||
@@ -65,7 +65,7 @@ import {
|
||||
getTimeValues,
|
||||
getCombinedDateAndTimeValues
|
||||
} from '@/lib/datetime.js';
|
||||
import { createInlinePicker } from '@/lib/ui.mobile.js';
|
||||
import { createInlinePicker } from '@/lib/ui/mobile.js';
|
||||
|
||||
export default {
|
||||
props: [
|
||||
|
||||
@@ -29,9 +29,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { arrayContainsFieldValue } from '@/lib/common.js';
|
||||
import { getIconsInRows } from '@/lib/icon.js';
|
||||
import { scrollToSelectedItem } from '@/lib/ui.mobile.js';
|
||||
import { arrayContainsFieldValue } from '@/lib/common.ts';
|
||||
import { getIconsInRows } from '@/lib/icon.ts';
|
||||
import { scrollToSelectedItem } from '@/lib/ui/mobile.js';
|
||||
|
||||
export default {
|
||||
props: [
|
||||
|
||||
@@ -25,7 +25,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { makeButtonCopyToClipboard, changeClipboardObjectText } from '@/lib/misc.js';
|
||||
import { ClipboardHolder } from '@/lib/clipboard.ts';
|
||||
|
||||
export default {
|
||||
props: [
|
||||
@@ -54,7 +54,7 @@ export default {
|
||||
watch: {
|
||||
'information': function (newValue) {
|
||||
if (this.clipboardHolder) {
|
||||
changeClipboardObjectText(this.clipboardHolder, newValue);
|
||||
this.clipboardHolder.setClipboardText(newValue);
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -73,7 +73,7 @@ export default {
|
||||
}
|
||||
|
||||
if (self.$refs.copyToClipboardIcon) {
|
||||
self.clipboardHolder = makeButtonCopyToClipboard({
|
||||
self.clipboardHolder = ClipboardHolder.create({
|
||||
el: '#copy-to-clipboard-icon',
|
||||
text: self.information,
|
||||
successCallback: function () {
|
||||
|
||||
@@ -5,9 +5,9 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import iconConstants from '@/consts/icon.js';
|
||||
import colorConstants from '@/consts/color.js';
|
||||
import { isNumber } from '@/lib/common.js';
|
||||
import { ALL_ACCOUNT_ICONS, DEFAULT_ACCOUNT_ICON, ALL_CATEGORY_ICONS, DEFAULT_CATEGORY_ICON } from '@/consts/icon.ts';
|
||||
import { DEFAULT_ICON_COLOR, DEFAULT_ACCOUNT_COLOR, DEFAULT_CATEGORY_COLOR } from '@/consts/color.ts';
|
||||
import { isNumber } from '@/lib/common.ts';
|
||||
|
||||
export default {
|
||||
props: [
|
||||
@@ -58,25 +58,25 @@ export default {
|
||||
iconId = iconId.toString();
|
||||
}
|
||||
|
||||
if (!iconConstants.allAccountIcons[iconId]) {
|
||||
return iconConstants.defaultAccountIcon.icon;
|
||||
if (!ALL_ACCOUNT_ICONS[iconId]) {
|
||||
return DEFAULT_ACCOUNT_ICON.icon;
|
||||
}
|
||||
|
||||
return iconConstants.allAccountIcons[iconId].icon;
|
||||
return ALL_ACCOUNT_ICONS[iconId].icon;
|
||||
},
|
||||
getCategoryIcon(iconId) {
|
||||
if (isNumber(iconId)) {
|
||||
iconId = iconId.toString();
|
||||
}
|
||||
|
||||
if (!iconConstants.allCategoryIcons[iconId]) {
|
||||
return iconConstants.defaultCategoryIcon.icon;
|
||||
if (!ALL_CATEGORY_ICONS[iconId]) {
|
||||
return DEFAULT_CATEGORY_ICON.icon;
|
||||
}
|
||||
|
||||
return iconConstants.allCategoryIcons[iconId].icon;
|
||||
return ALL_CATEGORY_ICONS[iconId].icon;
|
||||
},
|
||||
getAccountIconStyle(color, defaultColor, additionalColorAttr) {
|
||||
if (color && color !== colorConstants.defaultAccountColor) {
|
||||
if (color && color !== DEFAULT_ACCOUNT_COLOR) {
|
||||
color = '#' + color;
|
||||
} else {
|
||||
color = defaultColor;
|
||||
@@ -93,7 +93,7 @@ export default {
|
||||
return ret;
|
||||
},
|
||||
getCategoryIconStyle(color, defaultColor, additionalColorAttr) {
|
||||
if (color && color !== colorConstants.defaultCategoryColor) {
|
||||
if (color && color !== DEFAULT_CATEGORY_COLOR) {
|
||||
color = '#' + color;
|
||||
} else {
|
||||
color = defaultColor;
|
||||
@@ -110,7 +110,7 @@ export default {
|
||||
return ret;
|
||||
},
|
||||
getDefaultIconStyle(color, defaultColor, additionalColorAttr) {
|
||||
if (color && color !== colorConstants.defaultColor) {
|
||||
if (color && color !== DEFAULT_ICON_COLOR) {
|
||||
color = '#' + color;
|
||||
} else {
|
||||
color = defaultColor;
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { scrollToSelectedItem } from '@/lib/ui.mobile.js';
|
||||
import { scrollToSelectedItem } from '@/lib/ui/mobile.js';
|
||||
|
||||
export default {
|
||||
props: [
|
||||
|
||||
@@ -69,8 +69,8 @@
|
||||
import { mapStores } from 'pinia';
|
||||
import { useUserStore } from '@/stores/user.js';
|
||||
|
||||
import currencyConstants from '@/consts/currency.js';
|
||||
import { isString, isNumber, removeAll } from '@/lib/common.js';
|
||||
import { ALL_CURRENCIES } from '@/consts/currency.ts';
|
||||
import { isString, isNumber, removeAll } from '@/lib/common.ts';
|
||||
|
||||
export default {
|
||||
props: [
|
||||
@@ -100,11 +100,11 @@ export default {
|
||||
return this.$locale.getCurrentDecimalSeparator(this.userStore);
|
||||
},
|
||||
supportDecimalSeparator() {
|
||||
if (!this.currency || !currencyConstants.all[this.currency] || !isNumber(currencyConstants.all[this.currency].fraction)) {
|
||||
if (!this.currency || !ALL_CURRENCIES[this.currency] || !isNumber(ALL_CURRENCIES[this.currency].fraction)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return currencyConstants.all[this.currency].fraction > 0;
|
||||
return ALL_CURRENCIES[this.currency].fraction > 0;
|
||||
},
|
||||
currentDisplay() {
|
||||
const previousValue = this.$locale.appendDigitGroupingSymbol(this.userStore, this.previousValue);
|
||||
@@ -160,8 +160,8 @@ export default {
|
||||
return str;
|
||||
}
|
||||
|
||||
let integer = str.substring(0, decimalSeparatorPos);
|
||||
let decimals = str.substring(decimalSeparatorPos + 1, str.length);
|
||||
const integer = str.substring(0, decimalSeparatorPos);
|
||||
const decimals = str.substring(decimalSeparatorPos + 1, str.length);
|
||||
let newDecimals = '';
|
||||
|
||||
for (let i = decimals.length - 1; i >= 0; i--) {
|
||||
|
||||
@@ -81,7 +81,7 @@ import { mapStores } from 'pinia';
|
||||
import { useSettingsStore } from '@/stores/setting.js';
|
||||
import { useUserStore } from '@/stores/user.js';
|
||||
|
||||
import colorConstants from '@/consts/color.js';
|
||||
import { DEFAULT_ICON_COLOR, DEFAULT_CHART_COLORS } from '@/consts/color.ts';
|
||||
import { formatPercent } from '@/lib/numeral.js';
|
||||
|
||||
export default {
|
||||
@@ -139,7 +139,7 @@ export default {
|
||||
value: item[this.valueField],
|
||||
percent: (item[this.percentField] > 0 || item[this.percentField] === 0 || item[this.percentField] === '0') ? item[this.percentField] : (item[this.valueField] / totalValidValue * 100),
|
||||
actualPercent: item[this.valueField] / totalValidValue,
|
||||
color: item[this.colorField] ? item[this.colorField] : colorConstants.defaultChartColors[validItems.length % colorConstants.defaultChartColors.length],
|
||||
color: item[this.colorField] ? item[this.colorField] : DEFAULT_CHART_COLORS[validItems.length % DEFAULT_CHART_COLORS.length],
|
||||
sourceItem: item
|
||||
};
|
||||
|
||||
@@ -223,7 +223,7 @@ export default {
|
||||
}
|
||||
},
|
||||
getColor: function (color) {
|
||||
if (color && color !== colorConstants.defaultColor) {
|
||||
if (color && color !== DEFAULT_ICON_COLOR) {
|
||||
color = '#' + color;
|
||||
} else {
|
||||
color = 'var(--default-icon-color)';
|
||||
|
||||
@@ -68,9 +68,9 @@
|
||||
import { mapStores } from 'pinia';
|
||||
import { useUserStore } from '@/stores/user.js';
|
||||
|
||||
import templateConstants from '@/consts/template.js';
|
||||
import { sortNumbersArray } from '@/lib/common.js';
|
||||
import { scrollToSelectedItem } from '@/lib/ui.mobile.js';
|
||||
import { ScheduledTemplateFrequencyType } from '@/core/template.ts';
|
||||
import { sortNumbersArray } from '@/lib/common.ts';
|
||||
import { scrollToSelectedItem } from '@/lib/ui/mobile.js';
|
||||
|
||||
export default {
|
||||
props: [
|
||||
@@ -100,7 +100,7 @@ export default {
|
||||
return this.$locale.getAllTransactionScheduledFrequencyTypes();
|
||||
},
|
||||
allTemplateScheduledFrequencyTypes() {
|
||||
return templateConstants.allTemplateScheduledFrequencyTypes;
|
||||
return ScheduledTemplateFrequencyType.all();
|
||||
},
|
||||
allWeekDays() {
|
||||
return this.$locale.getAllWeekDays(this.firstDayOfWeek);
|
||||
@@ -134,9 +134,9 @@ export default {
|
||||
if (this.currentFrequencyType !== value) {
|
||||
this.currentFrequencyType = value;
|
||||
|
||||
if (value === templateConstants.allTemplateScheduledFrequencyTypes.Weekly.type) {
|
||||
if (value === ScheduledTemplateFrequencyType.Weekly.type) {
|
||||
this.currentFrequencyValue = [this.firstDayOfWeek];
|
||||
} else if (value === templateConstants.allTemplateScheduledFrequencyTypes.Monthly.type) {
|
||||
} else if (value === ScheduledTemplateFrequencyType.Monthly.type) {
|
||||
this.currentFrequencyValue = [1];
|
||||
} else {
|
||||
this.currentFrequencyValue = [];
|
||||
|
||||
@@ -79,8 +79,8 @@
|
||||
import { mapStores } from 'pinia';
|
||||
import { useTransactionTagsStore } from '@/stores/transactionTag.js';
|
||||
|
||||
import { copyArrayTo } from '@/lib/common.js';
|
||||
import { scrollToSelectedItem } from '@/lib/ui.mobile.js';
|
||||
import { copyArrayTo } from '@/lib/common.ts';
|
||||
import { scrollToSelectedItem } from '@/lib/ui/mobile.js';
|
||||
|
||||
export default {
|
||||
props: [
|
||||
|
||||
@@ -41,8 +41,8 @@
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import { isArray } from '@/lib/common.js';
|
||||
import { scrollToSelectedItem } from '@/lib/ui.mobile.js';
|
||||
import { isArray } from '@/lib/common.ts';
|
||||
import { scrollToSelectedItem } from '@/lib/ui/mobile.js';
|
||||
|
||||
export default {
|
||||
props: [
|
||||
@@ -85,7 +85,7 @@ export default {
|
||||
if (isArray(this.items)) {
|
||||
count = this.items.length;
|
||||
} else {
|
||||
for (let field in this.items) {
|
||||
for (const field in this.items) {
|
||||
if (!Object.prototype.hasOwnProperty.call(this.items, field)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -93,10 +93,10 @@ import { mapStores } from 'pinia';
|
||||
import { useSettingsStore } from '@/stores/setting.js';
|
||||
import { useUserStore } from '@/stores/user.js';
|
||||
|
||||
import colorConstants from '@/consts/color.js';
|
||||
import { DEFAULT_ICON_COLOR, DEFAULT_CHART_COLORS } from '@/consts/color.ts';
|
||||
import datetimeConstants from '@/consts/datetime.js';
|
||||
import statisticsConstants from '@/consts/statistics.js';
|
||||
import { isNumber } from '@/lib/common.js';
|
||||
import { isNumber } from '@/lib/common.ts';
|
||||
import {
|
||||
getYearMonthFirstUnixTime,
|
||||
getYearMonthLastUnixTime,
|
||||
@@ -154,7 +154,7 @@ export default {
|
||||
const legend = {
|
||||
id: id,
|
||||
name: (this.nameField && item[this.nameField]) ? this.getItemName(item[this.nameField]) : id,
|
||||
color: this.getColor(item[this.colorField] ? item[this.colorField] : colorConstants.defaultChartColors[i % colorConstants.defaultChartColors.length]),
|
||||
color: this.getColor(item[this.colorField] ? item[this.colorField] : DEFAULT_CHART_COLORS[i % DEFAULT_CHART_COLORS.length]),
|
||||
displayOrders: (this.displayOrdersField && item[this.displayOrdersField]) ? item[this.displayOrdersField] : [0]
|
||||
};
|
||||
|
||||
@@ -322,7 +322,7 @@ export default {
|
||||
}
|
||||
},
|
||||
getColor: function (color) {
|
||||
if (color && color !== colorConstants.defaultColor) {
|
||||
if (color && color !== DEFAULT_ICON_COLOR) {
|
||||
color = '#' + color;
|
||||
}
|
||||
|
||||
|
||||
@@ -65,8 +65,8 @@
|
||||
import {
|
||||
getItemByKeyValue,
|
||||
getPrimaryValueBySecondaryValue
|
||||
} from '@/lib/common.js';
|
||||
import { scrollToSelectedItem } from '@/lib/ui.mobile.js';
|
||||
} from '@/lib/common.ts';
|
||||
import { scrollToSelectedItem } from '@/lib/ui/mobile.js';
|
||||
|
||||
export default {
|
||||
props: [
|
||||
|
||||
Reference in New Issue
Block a user