code refactor

This commit is contained in:
MaysWind
2023-06-24 17:02:57 +08:00
parent a9338ed822
commit fb7790ba4a
36 changed files with 644 additions and 354 deletions
+7 -5
View File
@@ -80,7 +80,7 @@
</v-btn>
</v-col>
<v-col cols="12" class="text-center text-base">
<v-col cols="12" class="text-center text-base" v-if="isUserRegistrationEnabled">
<span>{{ $t('Don\'t have an account?') }}</span>&nbsp;
<router-link class="text-primary ms-2" to="/signup">
{{ $t('Create an account') }}
@@ -141,6 +141,8 @@ import { useRootStore } from '@/stores/index.js';
import { useSettingsStore } from '@/stores/setting.js';
import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
import { isUserRegistrationEnabled } from '@/lib/server_settings.js';
import {
mdiEyeOutline,
mdiEyeOffOutline,
@@ -181,7 +183,7 @@ export default {
return this.$locale.getAllLanguageInfos();
},
isUserRegistrationEnabled() {
return this.$settings.isUserRegistrationEnabled();
return isUserRegistrationEnabled();
},
inputIsEmpty() {
return !this.username || !this.password;
@@ -255,8 +257,8 @@ export default {
self.settingsStore.updateLocalizedDefaultSettings(localeDefaultSettings);
}
if (self.$settings.isAutoUpdateExchangeRatesData()) {
self.exchangeRatesStore.getLatestExchangeRates({silent: true, force: false});
if (self.settingsStore.appSettings.autoUpdateExchangeRatesData) {
self.exchangeRatesStore.getLatestExchangeRates({ silent: true, force: false });
}
this.$router.replace('/');
@@ -297,7 +299,7 @@ export default {
self.settingsStore.updateLocalizedDefaultSettings(localeDefaultSettings);
}
if (self.$settings.isAutoUpdateExchangeRatesData()) {
if (self.settingsStore.appSettings.autoUpdateExchangeRatesData) {
self.exchangeRatesStore.getLatestExchangeRates({ silent: true, force: false });
}
+8 -12
View File
@@ -97,8 +97,8 @@
</div>
<v-spacer />
<v-btn color="primary" variant="text" class="me-2"
:icon="true" @click="(currentTheme === 'light' ? currentTheme = 'dark' : (currentTheme === 'dark' ? currentTheme = 'auto' : currentTheme = 'light'))">
<v-icon :icon="(currentTheme === 'light' ? icons.themeLight : (currentTheme === 'dark' ? icons.themeDark : icons.themeAuto))" size="24" />
:icon="true" @click="(theme === 'light' ? theme = 'dark' : (theme === 'dark' ? theme = 'auto' : theme = 'light'))">
<v-icon :icon="(theme === 'light' ? icons.themeLight : (theme === 'dark' ? icons.themeDark : icons.themeAuto))" size="24" />
</v-btn>
<v-avatar class="cursor-pointer" color="primary" variant="tonal">
<v-icon :icon="icons.user"/>
@@ -197,10 +197,7 @@ import {
export default {
data() {
const self = this;
return {
theme: self.$settings.getTheme(),
logouting: false,
isVerticalNavScrolled: false,
showVerticalOverlayMenu: false,
@@ -236,14 +233,13 @@ export default {
currentNickName() {
return this.userStore.currentUserNickname || this.$t('User');
},
currentTheme: {
theme: {
get: function () {
return this.theme;
return this.settingsStore.appSettings.theme;
},
set: function (value) {
if (value !== this.$settings.getTheme()) {
this.theme = value;
this.$settings.setTheme(value);
if (value !== this.settingsStore.appSettings.theme) {
this.settingsStore.setTheme(value);
if (value === 'light' || value === 'dark') {
this.globalTheme.global.name.value = value;
@@ -275,9 +271,9 @@ export default {
self.logouting = false;
self.showLoading = false;
self.$settings.clearSettings();
self.settingsStore.clearAppSettings();
const localeDefaultSettings = self.$locale.initLocale(self.userStore.currentUserLanguage);
const localeDefaultSettings = self.$locale.initLocale(self.userStore.currentUserLanguage, self.settingsStore.appSettings.timeZone);
self.settingsStore.updateLocalizedDefaultSettings(localeDefaultSettings);
this.$router.replace('/login');
@@ -76,7 +76,7 @@
</v-card>
</v-col>
<v-col cols="12">
<v-col cols="12" v-if="isDataExportingEnabled">
<v-card :class="{ 'disabled': exportingData }" :title="$t('Export Data')">
<v-card-text>
<span class="text-subtitle-1">{{ $t('Export all data to csv file.') }}&nbsp;{{ $t('It may take a long time, please wait for a few minutes.') }}</span>
@@ -153,6 +153,7 @@ import { useRootStore } from '@/stores/index.js';
import { useUserStore } from '@/stores/user.js';
import { appendThousandsSeparator } from '@/lib/common.js';
import { isDataExportingEnabled } from '@/lib/server_settings.js';
import { startDownloadFile } from '@/lib/ui.js';
import {
@@ -206,7 +207,7 @@ export default {
};
},
isDataExportingEnabled() {
return this.$settings.isDataExportingEnabled();
return isDataExportingEnabled();
},
exportFileName() {
const nickname = this.userStore.currentUserNickname;
+27 -16
View File
@@ -37,6 +37,7 @@
<script>
import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/setting.js';
import { useUserStore } from '@/stores/user.js';
import logger from '@/lib/logger.js';
@@ -46,8 +47,6 @@ export default {
data() {
return {
isSupportedWebAuthn: false,
isEnableApplicationLock: this.$settings.isEnableApplicationLock(),
isEnableApplicationLockWebAuthn: this.$settings.isEnableApplicationLockWebAuthn(),
currentPinCodeForEnable: '',
currentPinCodeForDisable: '',
showInputPinCodeSheetForEnable: false,
@@ -55,7 +54,23 @@ export default {
};
},
computed: {
...mapStores(useUserStore)
...mapStores(useSettingsStore, useUserStore),
isEnableApplicationLock: {
get: function () {
return this.settingsStore.appSettings.applicationLock;
},
set: function (value) {
this.settingsStore.setEnableApplicationLock(value);
}
},
isEnableApplicationLockWebAuthn: {
get: function () {
return this.settingsStore.appSettings.applicationLockWebAuthn;
},
set: function (value) {
this.settingsStore.setEnableApplicationLockWebAuthn(value);
}
}
},
watch: {
isEnableApplicationLockWebAuthn: function (newValue) {
@@ -71,7 +86,7 @@ export default {
self.$hideLoading();
self.$user.saveWebAuthnConfig(id);
self.$settings.setEnableApplicationLockWebAuthn(true);
self.settingsStore.setEnableApplicationLockWebAuthn(true);
self.$toast('You have enabled WebAuthn successfully');
}).catch(error => {
logger.error('failed to enable WebAuthn', error);
@@ -89,11 +104,11 @@ export default {
}
self.isEnableApplicationLockWebAuthn = false;
self.$settings.setEnableApplicationLockWebAuthn(false);
self.settingsStore.setEnableApplicationLockWebAuthn(false);
self.$user.clearWebAuthnConfig();
});
} else {
self.$settings.setEnableApplicationLockWebAuthn(false);
self.settingsStore.setEnableApplicationLockWebAuthn(false);
self.$user.clearWebAuthnConfig();
}
}
@@ -106,7 +121,7 @@ export default {
},
methods: {
enable(pinCode) {
if (this.$settings.isEnableApplicationLock()) {
if (this.settingsStore.appSettings.applicationLock) {
this.$alert('Application lock has been enabled');
return;
}
@@ -129,17 +144,15 @@ export default {
}
this.$user.encryptToken(user.username, pinCode);
this.$settings.setEnableApplicationLock(true);
this.isEnableApplicationLock = true;
this.settingsStore.setEnableApplicationLock(true);
this.$settings.setEnableApplicationLockWebAuthn(false);
this.settingsStore.setEnableApplicationLockWebAuthn(false);
this.$user.clearWebAuthnConfig();
this.isEnableApplicationLockWebAuthn = false;
this.showInputPinCodeSheetForEnable = false;
},
disable(pinCode) {
if (!this.$settings.isEnableApplicationLock()) {
if (!this.settingsStore.appSettings.applicationLock) {
this.$alert('Application lock is not enabled');
return;
}
@@ -155,12 +168,10 @@ export default {
}
this.$user.decryptToken();
this.$settings.setEnableApplicationLock(false);
this.isEnableApplicationLock = false;
this.settingsStore.setEnableApplicationLock(false);
this.$settings.setEnableApplicationLockWebAuthn(false);
this.settingsStore.setEnableApplicationLockWebAuthn(false);
this.$user.clearWebAuthnConfig();
this.isEnableApplicationLockWebAuthn = false;
this.showInputPinCodeSheetForDisable = false;
}
+18 -18
View File
@@ -21,7 +21,7 @@
<p class="no-margin">
<span class="month-expense" v-if="loading">0.00 USD</span>
<span class="month-expense" v-else-if="!loading">{{ transactionOverview.thisMonth.expenseAmount }}</span>
<f7-link class="margin-left-half" @click="toggleShowAmountInHomePage()">
<f7-link class="margin-left-half" @click="showAmountInHomePage = !showAmountInHomePage">
<f7-icon class="ebk-hide-icon" :f7="showAmountInHomePage ? 'eye_slash_fill' : 'eye_fill'"></f7-icon>
</f7-link>
</p>
@@ -189,6 +189,7 @@
<script>
import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/setting.js';
import { useUserStore } from '@/stores/user.js';
import { useOverviewStore } from '@/stores/overview.js';
@@ -212,14 +213,25 @@ export default {
return {
loading: true,
todayFirstUnixTime: getTodayFirstUnixTime(),
todayLastUnixTime: getTodayLastUnixTime(),
showAmountInHomePage: self.$settings.isShowAmountInHomePage(),
isEnableThousandsSeparator: self.$settings.isEnableThousandsSeparator(),
currencyDisplayMode: self.$settings.getCurrencyDisplayMode()
todayLastUnixTime: getTodayLastUnixTime()
};
},
computed: {
...mapStores(useUserStore, useOverviewStore),
...mapStores(useSettingsStore, useUserStore, useOverviewStore),
showAmountInHomePage: {
get: function() {
return this.settingsStore.appSettings.showAmountInHomePage;
},
set: function(value) {
this.settingsStore.setShowAmountInHomePage(value);
}
},
isEnableThousandsSeparator() {
return this.settingsStore.appSettings.thousandsSeparator;
},
currencyDisplayMode() {
return this.settingsStore.appSettings.currencyDisplayMode;
},
defaultCurrency() {
return this.userStore.currentUserDefaultCurrency;
},
@@ -330,14 +342,6 @@ export default {
},
methods: {
onPageAfterIn() {
this.showAmountInHomePage = this.$settings.isShowAmountInHomePage();
if (this.isEnableThousandsSeparator !== this.$settings.isEnableThousandsSeparator() || this.currencyDisplayMode !== this.$settings.getCurrencyDisplayMode()) {
this.isEnableThousandsSeparator = this.$settings.isEnableThousandsSeparator();
this.currencyDisplayMode = this.$settings.getCurrencyDisplayMode();
this.$forceUpdate();
}
let dateChanged = false;
if (this.todayFirstUnixTime !== getTodayFirstUnixTime()) {
@@ -377,10 +381,6 @@ export default {
}
});
},
toggleShowAmountInHomePage() {
this.showAmountInHomePage = !this.showAmountInHomePage;
this.$settings.setShowAmountInHomePage(this.showAmountInHomePage);
},
getDisplayAmount(amount, incomplete) {
if (!this.showAmountInHomePage) {
return this.$locale.getDisplayCurrency('***', this.defaultCurrency);
+4 -3
View File
@@ -115,6 +115,7 @@ import { useRootStore } from '@/stores/index.js';
import { useSettingsStore } from '@/stores/setting.js';
import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
import { isUserRegistrationEnabled } from '@/lib/server_settings.js';
import { isModalShowing } from '@/lib/ui.mobile.js';
export default {
@@ -143,7 +144,7 @@ export default {
return this.$locale.getAllLanguageInfos();
},
isUserRegistrationEnabled() {
return this.$settings.isUserRegistrationEnabled();
return isUserRegistrationEnabled();
},
inputIsEmpty() {
return !this.username || !this.password;
@@ -214,7 +215,7 @@ export default {
self.settingsStore.updateLocalizedDefaultSettings(localeDefaultSettings);
}
if (self.$settings.isAutoUpdateExchangeRatesData()) {
if (self.settingsStore.appSettings.autoUpdateExchangeRatesData) {
self.exchangeRatesStore.getLatestExchangeRates({ silent: true, force: false });
}
@@ -267,7 +268,7 @@ export default {
self.settingsStore.updateLocalizedDefaultSettings(localeDefaultSettings);
}
if (self.$settings.isAutoUpdateExchangeRatesData()) {
if (self.settingsStore.appSettings.autoUpdateExchangeRatesData) {
self.exchangeRatesStore.getLatestExchangeRates({ silent: true, force: false });
}
+39 -38
View File
@@ -32,10 +32,10 @@
:key="currentLocale + '_timezone'"
:title="$t('Timezone')"
smart-select :smart-select-params="{ openIn: 'popup', popupPush: true, closeOnSelect: true, scrollToSelectedItem: true, searchbar: true, searchbarPlaceholder: $t('Timezone'), searchbarDisableText: $t('Cancel'), appendSearchbarNotFound: $t('No results'), popupCloseLinkText: $t('Done') }">
<select v-model="currentTimezone">
<option :value="timezone.name"
:key="timezone.name"
v-for="timezone in allTimezones">{{ `(UTC${timezone.utcOffset}) ${timezone.displayName}` }}</option>
<select v-model="timeZone">
<option :value="tz.name"
:key="tz.name"
v-for="tz in allTimezones">{{ `(UTC${tz.utcOffset}) ${tz.displayName}` }}</option>
</select>
</f7-list-item>
@@ -114,8 +114,7 @@ export default {
const self = this;
return {
currentLocale: this.$i18n.locale,
isEnableApplicationLock: self.$settings.isEnableApplicationLock(),
currentLocale: self.$i18n.locale,
logouting: false
};
},
@@ -127,98 +126,101 @@ export default {
allTimezones() {
return this.$locale.getAllTimezones(true);
},
allCurrencyDisplayModes() {
return currencyConstants.allCurrencyDisplayModes;
},
currentNickName() {
return this.userStore.currentUserNickname || this.$t('User');
},
theme: {
get: function () {
return this.$settings.getTheme();
return this.settingsStore.appSettings.theme;
},
set: function (value) {
if (value !== this.$settings.getTheme()) {
this.$settings.setTheme(value);
if (value !== this.settingsStore.appSettings.theme) {
this.settingsStore.setTheme(value);
location.reload();
}
}
},
currentTimezone: {
timeZone: {
get: function () {
return this.$locale.getTimezone();
return this.settingsStore.appSettings.timeZone;
},
set: function (value) {
this.$locale.setTimezone(value);
this.settingsStore.setTimeZone(value);
}
},
currentNickName() {
return this.userStore.currentUserNickname || this.$t('User');
},
exchangeRatesLastUpdateDate() {
const exchangeRatesLastUpdateTime = this.exchangeRatesStore.exchangeRatesLastUpdateTime;
return exchangeRatesLastUpdateTime ? this.$locale.formatUnixTimeToLongDate(this.userStore, exchangeRatesLastUpdateTime) : '';
},
allCurrencyDisplayModes() {
return currencyConstants.allCurrencyDisplayModes;
},
isAutoUpdateExchangeRatesData: {
get: function () {
return this.$settings.isAutoUpdateExchangeRatesData();
return this.settingsStore.appSettings.autoUpdateExchangeRatesData;
},
set: function (value) {
this.$settings.setAutoUpdateExchangeRatesData(value);
this.settingsStore.setAutoUpdateExchangeRatesData(value);
}
},
isEnableApplicationLock() {
return this.settingsStore.appSettings.applicationLock;
},
isAutoGetCurrentGeoLocation: {
get: function () {
return this.$settings.isAutoGetCurrentGeoLocation();
return this.settingsStore.appSettings.autoGetCurrentGeoLocation;
},
set: function (value) {
this.$settings.setAutoGetCurrentGeoLocation(value);
this.settingsStore.setAutoGetCurrentGeoLocation(value);
}
},
isEnableThousandsSeparator: {
get: function () {
return this.$settings.isEnableThousandsSeparator();
return this.settingsStore.appSettings.thousandsSeparator;
},
set: function (value) {
this.$settings.setEnableThousandsSeparator(value);
this.settingsStore.setEnableThousandsSeparator(value);
}
},
currencyDisplayMode: {
get: function () {
return this.$settings.getCurrencyDisplayMode();
return this.settingsStore.appSettings.currencyDisplayMode;
},
set: function (value) {
this.$settings.setCurrencyDisplayMode(value);
this.settingsStore.setCurrencyDisplayMode(value);
}
},
showAmountInHomePage: {
get: function () {
return this.$settings.isShowAmountInHomePage();
return this.settingsStore.appSettings.showAmountInHomePage;
},
set: function (value) {
this.$settings.setShowAmountInHomePage(value);
this.settingsStore.setShowAmountInHomePage(value);
}
},
showAccountBalance: {
get: function () {
return this.$settings.isShowAccountBalance();
return this.settingsStore.appSettings.showAccountBalance;
},
set: function (value) {
this.$settings.setShowAccountBalance(value);
this.settingsStore.setShowAccountBalance(value);
}
},
showTotalAmountInTransactionListPage: {
get: function () {
return this.$settings.isShowTotalAmountInTransactionListPage();
return this.settingsStore.appSettings.showTotalAmountInTransactionListPage;
},
set: function (value) {
this.$settings.setShowTotalAmountInTransactionListPage(value);
this.settingsStore.setShowTotalAmountInTransactionListPage(value);
}
},
isEnableAnimate: {
get: function () {
return this.$settings.isEnableAnimate();
return this.settingsStore.appSettings.animate;
},
set: function (value) {
if (value !== this.$settings.isEnableAnimate()) {
this.$settings.setEnableAnimate(value);
if (value !== this.settingsStore.appSettings.animate) {
this.settingsStore.setEnableAnimate(value);
location.reload();
}
}
@@ -227,7 +229,6 @@ export default {
methods: {
onPageAfterIn() {
this.currentLocale = this.$i18n.locale;
this.isEnableApplicationLock = this.$settings.isEnableApplicationLock();
},
logout() {
const self = this;
@@ -241,9 +242,9 @@ export default {
self.logouting = false;
self.$hideLoading();
self.$settings.clearSettings();
self.settingsStore.clearAppSettings();
const localeDefaultSettings = self.$locale.initLocale(self.userStore.currentUserLanguage);
const localeDefaultSettings = self.$locale.initLocale(self.userStore.currentUserLanguage, self.settingsStore.appSettings.timeZone);
self.settingsStore.updateLocalizedDefaultSettings(localeDefaultSettings);
router.navigate('/');
+7 -7
View File
@@ -199,8 +199,8 @@ export default {
email: '',
nickname: '',
language: self.$i18n.locale,
defaultCurrency: settingsStore.defaultSetting.currency,
firstDayOfWeek: settingsStore.defaultSetting.firstDayOfWeek,
defaultCurrency: settingsStore.localeDefaultSettings.currency,
firstDayOfWeek: settingsStore.localeDefaultSettings.firstDayOfWeek,
},
submitting: false,
presetCategories: {
@@ -230,8 +230,8 @@ export default {
return this.$i18n.locale;
},
set: function (value) {
const isCurrencyDefault = this.user.defaultCurrency === this.settingsStore.defaultSetting.currency;
const isFirstWeekDayDefault = this.user.firstDayOfWeek === this.settingsStore.defaultSetting.firstDayOfWeek;
const isCurrencyDefault = this.user.defaultCurrency === this.settingsStore.localeDefaultSettings.currency;
const isFirstWeekDayDefault = this.user.firstDayOfWeek === this.settingsStore.localeDefaultSettings.firstDayOfWeek;
this.user.language = value;
@@ -239,11 +239,11 @@ export default {
this.settingsStore.updateLocalizedDefaultSettings(localeDefaultSettings);
if (isCurrencyDefault) {
this.user.defaultCurrency = this.settingsStore.defaultSetting.currency;
this.user.defaultCurrency = this.settingsStore.localeDefaultSettings.currency;
}
if (isFirstWeekDayDefault) {
this.user.firstDayOfWeek = this.settingsStore.defaultSetting.firstDayOfWeek;
this.user.firstDayOfWeek = this.settingsStore.localeDefaultSettings.firstDayOfWeek;
}
}
},
@@ -362,7 +362,7 @@ export default {
self.settingsStore.updateLocalizedDefaultSettings(localeDefaultSettings);
}
if (self.$settings.isAutoUpdateExchangeRatesData()) {
if (self.settingsStore.appSettings.autoUpdateExchangeRatesData) {
self.exchangeRatesStore.getLatestExchangeRates({ silent: true, force: false });
}
+6 -6
View File
@@ -86,7 +86,7 @@ export default {
return this.$locale.getAllLanguageInfos();
},
isWebAuthnAvailable() {
return this.$settings.isEnableApplicationLockWebAuthn()
return this.settingsStore.appSettings.applicationLockWebAuthn
&& this.$user.getWebAuthnCredentialId()
&& webauthn.isSupported();
},
@@ -106,7 +106,7 @@ export default {
const self = this;
const router = self.f7router;
if (!self.$settings.isEnableApplicationLockWebAuthn() || !self.$user.getWebAuthnCredentialId()) {
if (!self.settingsStore.appSettings.applicationLockWebAuthn || !self.$user.getWebAuthnCredentialId()) {
self.$toast('WebAuthn is not enabled');
return;
}
@@ -132,7 +132,7 @@ export default {
}
});
if (self.$settings.isAutoUpdateExchangeRatesData()) {
if (self.settingsStore.appSettings.autoUpdateExchangeRatesData) {
self.exchangeRatesStore.getLatestExchangeRates({ silent: true, force: false });
}
@@ -180,7 +180,7 @@ export default {
}
});
if (self.$settings.isAutoUpdateExchangeRatesData()) {
if (self.settingsStore.appSettings.autoUpdateExchangeRatesData) {
self.exchangeRatesStore.getLatestExchangeRates({ silent: true, force: false });
}
@@ -196,9 +196,9 @@ export default {
self.$confirm('Are you sure you want to re-login?', () => {
self.rootStore.forceLogout();
self.$settings.clearSettings();
self.settingsStore.clearAppSettings();
const localeDefaultSettings = self.$locale.initLocale(self.userStore.currentUserLanguage);
const localeDefaultSettings = self.$locale.initLocale(self.userStore.currentUserLanguage, self.settingsStore.appSettings.timeZone);
self.settingsStore.updateLocalizedDefaultSettings(localeDefaultSettings);
router.navigate('/login', {
+11 -7
View File
@@ -19,7 +19,7 @@
<p class="no-margin">
<span class="net-assets" v-if="loading">0.00 USD</span>
<span class="net-assets" v-else-if="!loading">{{ netAssets }}</span>
<f7-link class="margin-left-half" @click="toggleShowAccountBalance()">
<f7-link class="margin-left-half" @click="showAccountBalance = !showAccountBalance">
<f7-icon class="ebk-hide-icon" :f7="showAccountBalance ? 'eye_slash_fill' : 'eye_fill'"></f7-icon>
</f7-link>
</p>
@@ -166,6 +166,7 @@
<script>
import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/setting.js';
import { useUserStore } from '@/stores/user.js';
import { useAccountsStore } from '@/stores/account.js';
import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
@@ -184,7 +185,6 @@ export default {
showHidden: false,
sortable: false,
accountToDelete: null,
showAccountBalance: this.$settings.isShowAccountBalance(),
showMoreActionSheet: false,
showDeleteActionSheet: false,
displayOrderModified: false,
@@ -192,7 +192,7 @@ export default {
};
},
computed: {
...mapStores(useUserStore, useAccountsStore, useExchangeRatesStore),
...mapStores(useSettingsStore, useUserStore, useAccountsStore, useExchangeRatesStore),
defaultCurrency() {
return this.userStore.currentUserDefaultCurrency;
},
@@ -232,6 +232,14 @@ export default {
totalLiabilities() {
const totalLiabilities = this.accountsStore.getTotalLiabilities(this.showAccountBalance);
return this.$locale.getDisplayCurrency(totalLiabilities, this.defaultCurrency);
},
showAccountBalance: {
get: function () {
return this.settingsStore.appSettings.showAccountBalance;
},
set: function (value) {
this.settingsStore.setShowAccountBalance(value);
}
}
},
created() {
@@ -295,10 +303,6 @@ export default {
hasVisibleSubAccount(account) {
return this.accountsStore.hasVisibleSubAccount(this.showHidden, account);
},
toggleShowAccountBalance() {
this.showAccountBalance = !this.showAccountBalance;
this.$settings.setShowAccountBalance(this.showAccountBalance);
},
accountBalance(account) {
const balance = this.accountsStore.getAccountBalance(this.showAccountBalance, account);
return this.$locale.getDisplayCurrency(balance, account.currency);
@@ -106,6 +106,7 @@
<script>
import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/setting.js';
import { useUserStore } from '@/stores/user.js';
import fontConstants from '@/consts/font.js';
@@ -117,15 +118,15 @@ export default {
'f7router'
],
data() {
const self = this;
const settingsStore = useSettingsStore();
return {
currentTime: getCurrentUnixTime(),
fontSize: self.$settings.getFontSize()
fontSize: settingsStore.appSettings.fontSize
}
},
computed: {
...mapStores(useUserStore),
...mapStores(useSettingsStore, useUserStore),
minFontSizeType() {
return 0;
},
@@ -152,8 +153,8 @@ export default {
setFontSize() {
const router = this.f7router;
if (this.fontSize !== this.$settings.getFontSize()) {
this.$settings.setFontSize(this.fontSize);
if (this.fontSize !== this.settingsStore.appSettings.fontSize) {
this.settingsStore.setFontSize(this.fontSize);
setAppFontSize(this.fontSize);
}
@@ -115,6 +115,7 @@
<script>
import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/setting.js';
import { useAccountsStore } from '@/stores/account.js';
import { useStatisticsStore } from '@/stores/statistics.js';
@@ -140,7 +141,7 @@ export default {
}
},
computed: {
...mapStores(useAccountsStore, useStatisticsStore),
...mapStores(useSettingsStore, useAccountsStore, useStatisticsStore),
title() {
if (this.modifyDefault) {
return 'Default Account Filter';
@@ -188,7 +189,7 @@ export default {
}
if (self.modifyDefault) {
self.filterAccountIds = copyObjectTo(self.$settings.getStatisticsDefaultAccountFilter(), allAccountIds);
self.filterAccountIds = copyObjectTo(self.settingsStore.appSettings.statistics.defaultAccountFilter, allAccountIds);
} else {
self.filterAccountIds = copyObjectTo(self.statisticsStore.transactionStatisticsFilter.filterAccountIds, allAccountIds);
}
@@ -222,7 +223,7 @@ export default {
}
if (self.modifyDefault) {
self.$settings.setStatisticsDefaultAccountFilter(filteredAccountIds);
self.settingsStore.setStatisticsDefaultAccountFilter(filteredAccountIds);
} else {
self.statisticsStore.updateTransactionStatisticsFilter({
filterAccountIds: filteredAccountIds
@@ -124,6 +124,7 @@
<script>
import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/setting.js';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
import { useStatisticsStore } from '@/stores/statistics.js';
@@ -149,7 +150,7 @@ export default {
}
},
computed: {
...mapStores(useTransactionCategoriesStore, useStatisticsStore),
...mapStores(useSettingsStore, useTransactionCategoriesStore, useStatisticsStore),
title() {
if (this.modifyDefault) {
@@ -221,7 +222,7 @@ export default {
}
if (self.modifyDefault) {
self.filterCategoryIds = copyObjectTo(self.$settings.getStatisticsDefaultTransactionCategoryFilter(), allCategoryIds);
self.filterCategoryIds = copyObjectTo(self.settingsStore.appSettings.statistics.defaultTransactionCategoryFilter, allCategoryIds);
} else {
self.filterCategoryIds = copyObjectTo(self.statisticsStore.transactionStatisticsFilter.filterCategoryIds, allCategoryIds);
}
@@ -255,7 +256,7 @@ export default {
}
if (self.modifyDefault) {
self.$settings.setStatisticsDefaultTransactionCategoryFilter(filteredCategoryIds);
self.settingsStore.setStatisticsDefaultTransactionCategoryFilter(filteredCategoryIds);
} else {
self.statisticsStore.updateTransactionStatisticsFilter({
filterCategoryIds: filteredCategoryIds
+12 -8
View File
@@ -50,11 +50,15 @@
</template>
<script>
import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/setting.js';
import datetimeConstants from '@/consts/datetime.js';
import statisticsConstants from '@/consts/statistics.js';
export default {
computed: {
...mapStores(useSettingsStore),
allChartTypes() {
return statisticsConstants.allChartTypes;
},
@@ -83,34 +87,34 @@ export default {
},
defaultChartType: {
get: function () {
return this.$settings.getStatisticsDefaultChartType();
return this.settingsStore.appSettings.statistics.defaultChartType;
},
set: function (value) {
this.$settings.setStatisticsDefaultChartType(value);
this.settingsStore.setStatisticsDefaultChartType(value);
}
},
defaultChartDataType: {
get: function () {
return this.$settings.getStatisticsDefaultChartDataType();
return this.settingsStore.appSettings.statistics.defaultChartDataType;
},
set: function (value) {
this.$settings.setStatisticsDefaultChartDataType(value);
this.settingsStore.setStatisticsDefaultChartDataType(value);
}
},
defaultDateRange: {
get: function () {
return this.$settings.getStatisticsDefaultDateRange();
return this.settingsStore.appSettings.statistics.defaultDataRangeType;
},
set: function (value) {
this.$settings.setStatisticsDefaultDateRange(value);
this.settingsStore.setStatisticsDefaultDateRange(value);
}
},
defaultSortingType: {
get: function () {
return this.$settings.getStatisticsSortingType();
return this.settingsStore.appSettings.statistics.defaultSortingType;
},
set: function (value) {
this.$settings.setStatisticsSortingType(value);
this.settingsStore.setStatisticsSortingType(value);
}
}
}
+11 -10
View File
@@ -251,6 +251,7 @@
<script>
import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/setting.js';
import { useUserStore } from '@/stores/user.js';
import { useAccountsStore } from '@/stores/account.js';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
@@ -273,12 +274,9 @@ export default {
'f7router'
],
data() {
const self = this;
return {
loading: true,
loadingError: null,
showAccountBalance: self.$settings.isShowAccountBalance(),
showChartDataTypePopover: false,
showSortingTypePopover: false,
showDatePopover: false,
@@ -287,7 +285,7 @@ export default {
};
},
computed: {
...mapStores(useUserStore, useAccountsStore, useTransactionCategoriesStore, useStatisticsStore),
...mapStores(useSettingsStore, useUserStore, useAccountsStore, useTransactionCategoriesStore, useStatisticsStore),
defaultCurrency() {
return this.userStore.currentUserDefaultCurrency;
},
@@ -323,6 +321,9 @@ export default {
allDateRanges() {
return datetimeConstants.allDateRanges;
},
showAccountBalance() {
return this.settingsStore.appSettings.showAccountBalance;
},
totalAmountName() {
if (this.query.chartDataType === this.allChartDataTypes.IncomeByAccount.type
|| this.query.chartDataType === this.allChartDataTypes.IncomeByPrimaryCategory.type
@@ -431,25 +432,25 @@ export default {
created() {
const self = this;
let defaultChartType = self.$settings.getStatisticsDefaultChartType();
let defaultChartType = self.settingsStore.appSettings.statistics.defaultChartType;
if (defaultChartType !== self.allChartTypes.Pie && defaultChartType !== self.allChartTypes.Bar) {
defaultChartType = statisticsConstants.defaultChartType;
}
let defaultChartDataType = self.$settings.getStatisticsDefaultChartDataType();
let defaultChartDataType = self.settingsStore.appSettings.statistics.defaultChartDataType;
if (defaultChartDataType < self.allChartDataTypes.ExpenseByAccount.type || defaultChartDataType > self.allChartDataTypes.AccountTotalLiabilities.type) {
defaultChartDataType = statisticsConstants.defaultChartDataType;
}
let defaultDateRange = self.$settings.getStatisticsDefaultDateRange();
let defaultDateRange = self.settingsStore.appSettings.statistics.defaultDataRangeType;
if (defaultDateRange < self.allDateRanges.All.type || defaultDateRange >= self.allDateRanges.Custom.type) {
defaultDateRange = statisticsConstants.defaultDataRangeType;
}
let defaultSortType = self.$settings.getStatisticsSortingType();
let defaultSortType = self.settingsStore.appSettings.statistics.defaultSortingType;
if (defaultSortType < self.allSortingTypes.Amount.type || defaultSortType > self.allSortingTypes.Name.type) {
defaultSortType = statisticsConstants.defaultSortingType;
@@ -463,8 +464,8 @@ export default {
endTime: dateRange ? dateRange.maxTime : undefined,
chartType: defaultChartType,
chartDataType: defaultChartDataType,
filterAccountIds: self.$settings.getStatisticsDefaultAccountFilter() || {},
filterCategoryIds: self.$settings.getStatisticsDefaultTransactionCategoryFilter() || {},
filterAccountIds: self.settingsStore.appSettings.statistics.defaultAccountFilter || {},
filterCategoryIds: self.settingsStore.appSettings.statistics.defaultTransactionCategoryFilter || {},
sortingType: defaultSortType,
});
+13 -5
View File
@@ -303,7 +303,7 @@
<f7-actions-button v-if="mode !== 'view'" @click="updateGeoLocation(true)">{{ $t('Update Geographic Location') }}</f7-actions-button>
<f7-actions-button v-if="mode !== 'view'" @click="clearGeoLocation">{{ $t('Clear Geographic Location') }}</f7-actions-button>
</f7-actions-group>
<f7-actions-group v-if="$settings.getMapProvider()">
<f7-actions-group v-if="mapProvider">
<f7-actions-button :class="{ 'disabled': !transaction.geoLocation }" @click="showGeoLocationMapSheet = true">{{ $t('Show on the map') }}</f7-actions-button>
</f7-actions-group>
<f7-actions-group>
@@ -331,6 +331,7 @@
<script>
import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/setting.js';
import { useUserStore } from '@/stores/user.js';
import { useAccountsStore } from '@/stores/account.js';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
@@ -367,6 +368,7 @@ import {
getTransactionPrimaryCategoryName,
getTransactionSecondaryCategoryName
} from '@/lib/category.js';
import { getMapProvider } from '@/lib/server_settings.js';
export default {
props: [
@@ -375,9 +377,10 @@ export default {
],
data() {
const self = this;
const settingsStore = useSettingsStore();
const query = self.f7route.query;
const now = getCurrentUnixTime();
const currentTimezone = self.$locale.getTimezone();
const currentTimezone = settingsStore.appSettings.timeZone;
let defaultType = transactionConstants.allTransactionTypes.Expense;
@@ -412,7 +415,6 @@ export default {
geoLocationStatus: null,
submitting: false,
isSupportGeoLocation: !!navigator.geolocation,
showAccountBalance: self.$settings.isShowAccountBalance(),
showGeoLocationActionSheet: false,
showMoreActionSheet: false,
showSourceAmountSheet: false,
@@ -426,7 +428,7 @@ export default {
};
},
computed: {
...mapStores(useUserStore, useAccountsStore, useTransactionCategoriesStore, useTransactionTagsStore, useTransactionsStore, useExchangeRatesStore),
...mapStores(useSettingsStore, useUserStore, useAccountsStore, useTransactionCategoriesStore, useTransactionTagsStore, useTransactionsStore, useExchangeRatesStore),
title() {
if (this.mode === 'add') {
return 'Add Transaction';
@@ -672,6 +674,12 @@ export default {
allowedMaxAmount() {
return transactionConstants.maxAmount;
},
showAccountBalance() {
return this.settingsStore.appSettings.showAccountBalance;
},
mapProvider() {
return getMapProvider();
},
inputIsEmpty() {
return !!this.inputEmptyProblemMessage;
},
@@ -898,7 +906,7 @@ export default {
onPageAfterIn() {
this.$routeBackOnError(this.f7router, 'loadingError');
if (this.$settings.isAutoGetCurrentGeoLocation() && this.mode === 'add'
if (this.settingsStore.appSettings.autoGetCurrentGeoLocation && this.mode === 'add'
&& !this.geoLocationStatus && !this.transaction.geoLocation) {
this.updateGeoLocation(false);
}
+5 -4
View File
@@ -413,6 +413,7 @@
<script>
import { mapStores } from 'pinia';
import { useSettingsStore } from '@/stores/setting.js';
import { useUserStore } from '@/stores/user.js';
import { useAccountsStore } from '@/stores/account.js';
import { useTransactionCategoriesStore } from '@/stores/transactionCategory.js';
@@ -441,14 +442,11 @@ export default {
'f7router'
],
data() {
const self = this;
return {
loading: true,
loadingError: null,
loadingMore: false,
transactionToDelete: null,
showTotalAmountInTransactionListPage: self.$settings.isShowTotalAmountInTransactionListPage(),
showDatePopover: false,
showTypePopover: false,
showCategoryPopover: false,
@@ -458,7 +456,7 @@ export default {
};
},
computed: {
...mapStores(useUserStore, useAccountsStore, useTransactionCategoriesStore, useTransactionsStore),
...mapStores(useSettingsStore, useUserStore, useAccountsStore, useTransactionCategoriesStore, useTransactionsStore),
defaultCurrency() {
if (this.query.accountId && this.query.accountId !== '0') {
const account = this.allAccounts[this.query.accountId];
@@ -551,6 +549,9 @@ export default {
},
allDateRanges() {
return datetimeConstants.allDateRanges;
},
showTotalAmountInTransactionListPage() {
return this.settingsStore.appSettings.showTotalAmountInTransactionListPage;
}
},
created() {
@@ -61,6 +61,7 @@ import { useRootStore } from '@/stores/index.js';
import { useUserStore } from '@/stores/user.js';
import { appendThousandsSeparator } from '@/lib/common.js';
import { isDataExportingEnabled } from '@/lib/server_settings.js';
export default {
props: [
@@ -96,7 +97,7 @@ export default {
};
},
isDataExportingEnabled() {
return this.$settings.isDataExportingEnabled();
return isDataExportingEnabled();
},
exportFileName() {
const nickname = this.userStore.currentUserNickname;