move currency display type to user settings
This commit is contained in:
+3
-2
@@ -2,14 +2,14 @@ package cmd
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
||||
"github.com/mayswind/ezbookkeeping/pkg/models"
|
||||
"os"
|
||||
|
||||
"github.com/urfave/cli/v2"
|
||||
|
||||
clis "github.com/mayswind/ezbookkeeping/pkg/cli"
|
||||
"github.com/mayswind/ezbookkeeping/pkg/errs"
|
||||
"github.com/mayswind/ezbookkeeping/pkg/log"
|
||||
"github.com/mayswind/ezbookkeeping/pkg/models"
|
||||
"github.com/mayswind/ezbookkeeping/pkg/utils"
|
||||
)
|
||||
|
||||
@@ -621,6 +621,7 @@ func printUserInfo(user *models.User) {
|
||||
fmt.Printf("[DecimalSeparator] %s (%d)\n", user.DecimalSeparator, user.DecimalSeparator)
|
||||
fmt.Printf("[DigitGroupingSymbol] %s (%d)\n", user.DigitGroupingSymbol, user.DigitGroupingSymbol)
|
||||
fmt.Printf("[DigitGrouping] %s (%d)\n", user.DigitGrouping, user.DigitGrouping)
|
||||
fmt.Printf("[CurrencyDisplayType] %s (%d)\n", user.CurrencyDisplayType, user.CurrencyDisplayType)
|
||||
fmt.Printf("[Deleted] %t\n", user.Deleted)
|
||||
fmt.Printf("[EmailVerified] %t\n", user.EmailVerified)
|
||||
fmt.Printf("[CreatedAt] %s (%d)\n", utils.FormatUnixTimeToLongDateTimeInServerTimezone(user.CreatedUnixTime), user.CreatedUnixTime)
|
||||
|
||||
@@ -361,6 +361,14 @@ func (a *UsersApi) UserUpdateProfileHandler(c *core.Context) (any, *errs.Error)
|
||||
userNew.DigitGrouping = models.DIGIT_GROUPING_TYPE_INVALID
|
||||
}
|
||||
|
||||
if userUpdateReq.CurrencyDisplayType != nil && *userUpdateReq.CurrencyDisplayType != user.CurrencyDisplayType {
|
||||
user.CurrencyDisplayType = *userUpdateReq.CurrencyDisplayType
|
||||
userNew.CurrencyDisplayType = *userUpdateReq.CurrencyDisplayType
|
||||
anythingUpdate = true
|
||||
} else {
|
||||
userNew.CurrencyDisplayType = models.CURRENCY_DISPLAY_TYPE_INVALID
|
||||
}
|
||||
|
||||
if modifyUserLanguage || userNew.DecimalSeparator != models.DECIMAL_SEPARATOR_INVALID || userNew.DigitGroupingSymbol != models.DIGIT_GROUPING_SYMBOL_INVALID {
|
||||
decimalSeparator := userNew.DecimalSeparator
|
||||
digitGroupingSymbol := userNew.DigitGroupingSymbol
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package models
|
||||
|
||||
import "fmt"
|
||||
|
||||
// CurrencyDisplayType represents the display type of amount with currency
|
||||
type CurrencyDisplayType byte
|
||||
|
||||
// Currency Display Type
|
||||
const (
|
||||
CURRENCY_DISPLAY_TYPE_DEFAULT CurrencyDisplayType = 0
|
||||
CURRENCY_DISPLAY_TYPE_NONE CurrencyDisplayType = 1
|
||||
CURRENCY_DISPLAY_TYPE_SYMBOL_BEFORE_AMOUNT CurrencyDisplayType = 2
|
||||
CURRENCY_DISPLAY_TYPE_SYMBOL_AFTER_AMOUNT CurrencyDisplayType = 3
|
||||
CURRENCY_DISPLAY_TYPE_CODE_BEFORE_AMOUNT CurrencyDisplayType = 4
|
||||
CURRENCY_DISPLAY_TYPE_CODE_AFTER_AMOUNT CurrencyDisplayType = 5
|
||||
CURRENCY_DISPLAY_TYPE_NAME_BEFORE_AMOUNT CurrencyDisplayType = 6
|
||||
CURRENCY_DISPLAY_TYPE_NAME_AFTER_AMOUNT CurrencyDisplayType = 7
|
||||
CURRENCY_DISPLAY_TYPE_INVALID CurrencyDisplayType = 255
|
||||
)
|
||||
|
||||
// String returns a textual representation of the currency display type enum
|
||||
func (d CurrencyDisplayType) String() string {
|
||||
switch d {
|
||||
case CURRENCY_DISPLAY_TYPE_DEFAULT:
|
||||
return "Default"
|
||||
case CURRENCY_DISPLAY_TYPE_NONE:
|
||||
return "None"
|
||||
case CURRENCY_DISPLAY_TYPE_SYMBOL_BEFORE_AMOUNT:
|
||||
return "Symbol Before Amount"
|
||||
case CURRENCY_DISPLAY_TYPE_SYMBOL_AFTER_AMOUNT:
|
||||
return "Symbol After Amount"
|
||||
case CURRENCY_DISPLAY_TYPE_CODE_BEFORE_AMOUNT:
|
||||
return "Code Before Amount"
|
||||
case CURRENCY_DISPLAY_TYPE_CODE_AFTER_AMOUNT:
|
||||
return "Code After Amount"
|
||||
case CURRENCY_DISPLAY_TYPE_NAME_BEFORE_AMOUNT:
|
||||
return "Name Before Amount"
|
||||
case CURRENCY_DISPLAY_TYPE_NAME_AFTER_AMOUNT:
|
||||
return "Name After Amount"
|
||||
case CURRENCY_DISPLAY_TYPE_INVALID:
|
||||
return "Invalid"
|
||||
default:
|
||||
return fmt.Sprintf("Invalid(%d)", int(d))
|
||||
}
|
||||
}
|
||||
@@ -67,6 +67,7 @@ type User struct {
|
||||
DecimalSeparator DecimalSeparator `xorm:"TINYINT"`
|
||||
DigitGroupingSymbol DigitGroupingSymbol `xorm:"TINYINT"`
|
||||
DigitGrouping DigitGroupingType `xorm:"TINYINT"`
|
||||
CurrencyDisplayType CurrencyDisplayType `xorm:"TINYINT"`
|
||||
Disabled bool
|
||||
Deleted bool `xorm:"NOT NULL"`
|
||||
EmailVerified bool `xorm:"NOT NULL"`
|
||||
@@ -95,6 +96,7 @@ type UserBasicInfo struct {
|
||||
DecimalSeparator DecimalSeparator `json:"decimalSeparator"`
|
||||
DigitGroupingSymbol DigitGroupingSymbol `json:"digitGroupingSymbol"`
|
||||
DigitGrouping DigitGroupingType `json:"digitGrouping"`
|
||||
CurrencyDisplayType CurrencyDisplayType `json:"currencyDisplayType"`
|
||||
EmailVerified bool `json:"emailVerified"`
|
||||
}
|
||||
|
||||
@@ -151,6 +153,7 @@ type UserProfileUpdateRequest struct {
|
||||
DecimalSeparator *DecimalSeparator `json:"decimalSeparator" binding:"omitempty,min=0,max=3"`
|
||||
DigitGroupingSymbol *DigitGroupingSymbol `json:"digitGroupingSymbol" binding:"omitempty,min=0,max=4"`
|
||||
DigitGrouping *DigitGroupingType `json:"digitGrouping" binding:"omitempty,min=0,max=2"`
|
||||
CurrencyDisplayType *CurrencyDisplayType `json:"currencyDisplayType" binding:"omitempty,min=0,max=7"`
|
||||
}
|
||||
|
||||
// UserProfileUpdateResponse represents the data returns to frontend after updating profile
|
||||
@@ -178,6 +181,7 @@ type UserProfileResponse struct {
|
||||
DecimalSeparator DecimalSeparator `json:"decimalSeparator"`
|
||||
DigitGroupingSymbol DigitGroupingSymbol `json:"digitGroupingSymbol"`
|
||||
DigitGrouping DigitGroupingType `json:"digitGrouping"`
|
||||
CurrencyDisplayType CurrencyDisplayType `json:"currencyDisplayType"`
|
||||
EmailVerified bool `json:"emailVerified"`
|
||||
LastLoginAt int64 `json:"lastLoginAt"`
|
||||
}
|
||||
@@ -244,6 +248,7 @@ func (u *User) ToUserBasicInfo() *UserBasicInfo {
|
||||
DecimalSeparator: u.DecimalSeparator,
|
||||
DigitGroupingSymbol: u.DigitGroupingSymbol,
|
||||
DigitGrouping: u.DigitGrouping,
|
||||
CurrencyDisplayType: u.CurrencyDisplayType,
|
||||
EmailVerified: u.EmailVerified,
|
||||
}
|
||||
}
|
||||
@@ -268,6 +273,7 @@ func (u *User) ToUserProfileResponse() *UserProfileResponse {
|
||||
DecimalSeparator: u.DecimalSeparator,
|
||||
DigitGroupingSymbol: u.DigitGroupingSymbol,
|
||||
DigitGrouping: u.DigitGrouping,
|
||||
CurrencyDisplayType: u.CurrencyDisplayType,
|
||||
EmailVerified: u.EmailVerified,
|
||||
LastLoginAt: u.LastLoginUnixTime,
|
||||
}
|
||||
|
||||
@@ -260,6 +260,10 @@ func (s *UserService) UpdateUser(c *core.Context, user *models.User, modifyUserL
|
||||
updateCols = append(updateCols, "digit_grouping")
|
||||
}
|
||||
|
||||
if models.CURRENCY_DISPLAY_TYPE_DEFAULT <= user.CurrencyDisplayType && user.CurrencyDisplayType <= models.CURRENCY_DISPLAY_TYPE_NAME_AFTER_AMOUNT {
|
||||
updateCols = append(updateCols, "currency_display_type")
|
||||
}
|
||||
|
||||
user.UpdatedUnixTime = now
|
||||
updateCols = append(updateCols, "updated_unix_time")
|
||||
|
||||
|
||||
+86
-4
@@ -641,21 +641,103 @@ const allCurrencies = {
|
||||
}
|
||||
};
|
||||
|
||||
const allCurrencyDisplayModes = {
|
||||
const allCurrencyDisplaySymbol = {
|
||||
None: 0,
|
||||
Symbol: 1,
|
||||
Code: 2,
|
||||
Name: 3
|
||||
};
|
||||
|
||||
const allCurrencyDisplayLocation = {
|
||||
BeforeAmount: 0,
|
||||
AfterAmount: 1
|
||||
};
|
||||
|
||||
const allCurrencyDisplayType = {
|
||||
None: {
|
||||
type: 1,
|
||||
name: 'None',
|
||||
symbol: allCurrencyDisplaySymbol.None,
|
||||
separator: ''
|
||||
},
|
||||
SymbolBeforeAmount: {
|
||||
type: 2,
|
||||
name: 'Currency Symbol',
|
||||
symbol: allCurrencyDisplaySymbol.Symbol,
|
||||
location: allCurrencyDisplayLocation.BeforeAmount,
|
||||
separator: ' '
|
||||
},
|
||||
SymbolAfterAmount: {
|
||||
type: 3,
|
||||
name: 'Currency Symbol',
|
||||
symbol: allCurrencyDisplaySymbol.Symbol,
|
||||
location: allCurrencyDisplayLocation.AfterAmount,
|
||||
separator: ' '
|
||||
},
|
||||
CodeBeforeAmount: {
|
||||
type: 4,
|
||||
name: 'Currency Code',
|
||||
symbol: allCurrencyDisplaySymbol.Code,
|
||||
location: allCurrencyDisplayLocation.BeforeAmount,
|
||||
separator: ' '
|
||||
},
|
||||
CodeAfterAmount: {
|
||||
type: 5,
|
||||
name: 'Currency Code',
|
||||
symbol: allCurrencyDisplaySymbol.Code,
|
||||
location: allCurrencyDisplayLocation.AfterAmount,
|
||||
separator: ' '
|
||||
},
|
||||
NameBeforeAmount: {
|
||||
type: 6,
|
||||
name: 'Currency Name',
|
||||
symbol: allCurrencyDisplaySymbol.Name,
|
||||
location: allCurrencyDisplayLocation.BeforeAmount,
|
||||
separator: ' '
|
||||
},
|
||||
NameAfterAmount: {
|
||||
type: 7,
|
||||
name: 'Currency Name',
|
||||
symbol: allCurrencyDisplaySymbol.Name,
|
||||
location: allCurrencyDisplayLocation.AfterAmount,
|
||||
separator: ' '
|
||||
}
|
||||
};
|
||||
|
||||
const allCurrencyDisplayTypeArray = [
|
||||
allCurrencyDisplayType.None,
|
||||
allCurrencyDisplayType.SymbolBeforeAmount,
|
||||
allCurrencyDisplayType.SymbolAfterAmount,
|
||||
allCurrencyDisplayType.CodeBeforeAmount,
|
||||
allCurrencyDisplayType.CodeAfterAmount,
|
||||
allCurrencyDisplayType.NameBeforeAmount,
|
||||
allCurrencyDisplayType.NameAfterAmount
|
||||
];
|
||||
|
||||
const allCurrencyDisplayTypeMap = {
|
||||
[allCurrencyDisplayType.None.type]: allCurrencyDisplayType.None,
|
||||
[allCurrencyDisplayType.SymbolBeforeAmount.type]: allCurrencyDisplayType.SymbolBeforeAmount,
|
||||
[allCurrencyDisplayType.SymbolAfterAmount.type]: allCurrencyDisplayType.SymbolAfterAmount,
|
||||
[allCurrencyDisplayType.CodeBeforeAmount.type]: allCurrencyDisplayType.CodeBeforeAmount,
|
||||
[allCurrencyDisplayType.CodeAfterAmount.type]: allCurrencyDisplayType.CodeAfterAmount,
|
||||
[allCurrencyDisplayType.NameBeforeAmount.type]: allCurrencyDisplayType.NameBeforeAmount,
|
||||
[allCurrencyDisplayType.NameAfterAmount.type]: allCurrencyDisplayType.NameAfterAmount
|
||||
};
|
||||
|
||||
const defaultCurrency = allCurrencies.USD.code;
|
||||
const defaultCurrencyDisplayMode = allCurrencyDisplayModes.Symbol;
|
||||
const defaultCurrencyDisplayType = allCurrencyDisplayType.SymbolBeforeAmount;
|
||||
const defaultCurrencyDisplayTypeValue = 0;
|
||||
|
||||
export default {
|
||||
parentAccountCurrencyPlaceholder: parentAccountCurrencyPlaceholder,
|
||||
defaultCurrencySymbol: defaultCurrencySymbol,
|
||||
all: allCurrencies,
|
||||
defaultCurrency: defaultCurrency,
|
||||
allCurrencyDisplayModes: allCurrencyDisplayModes,
|
||||
defaultCurrencyDisplayMode: defaultCurrencyDisplayMode
|
||||
allCurrencyDisplaySymbol: allCurrencyDisplaySymbol,
|
||||
allCurrencyDisplayLocation: allCurrencyDisplayLocation,
|
||||
allCurrencyDisplayType: allCurrencyDisplayType,
|
||||
allCurrencyDisplayTypeArray: allCurrencyDisplayTypeArray,
|
||||
allCurrencyDisplayTypeMap: allCurrencyDisplayTypeMap,
|
||||
defaultCurrencyDisplayType: defaultCurrencyDisplayType,
|
||||
defaultCurrencyDisplayTypeValue: defaultCurrencyDisplayTypeValue
|
||||
};
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
import currencyConstants from '@/consts/currency.js';
|
||||
|
||||
import { isString, isNumber } from './common.js';
|
||||
|
||||
export function appendCurrencySymbol(value, currencyDisplayType, currencyCode, currencyName) {
|
||||
if (!currencyDisplayType) {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (isNumber(value)) {
|
||||
value = value.toString();
|
||||
}
|
||||
|
||||
if (!isString(value)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
let symbol = '';
|
||||
let separator = currencyDisplayType.separator || '';
|
||||
|
||||
if (currencyDisplayType.symbol === currencyConstants.allCurrencyDisplaySymbol.Symbol) {
|
||||
const currencyInfo = currencyConstants.all[currencyCode];
|
||||
|
||||
if (currencyInfo && currencyInfo.symbol) {
|
||||
symbol = currencyInfo.symbol;
|
||||
} else if (currencyInfo && currencyInfo.code) {
|
||||
symbol = currencyInfo.code;
|
||||
}
|
||||
|
||||
if (!symbol) {
|
||||
symbol = currencyConstants.defaultCurrencySymbol;
|
||||
}
|
||||
} else if (currencyDisplayType.symbol === currencyConstants.allCurrencyDisplaySymbol.Code) {
|
||||
symbol = currencyCode;
|
||||
}else if (currencyDisplayType.symbol === currencyConstants.allCurrencyDisplaySymbol.Name) {
|
||||
symbol = currencyName;
|
||||
}
|
||||
|
||||
if (currencyDisplayType.location === currencyConstants.allCurrencyDisplayLocation.BeforeAmount) {
|
||||
return `${symbol}${separator}${value}`;
|
||||
} else if (currencyDisplayType.location === currencyConstants.allCurrencyDisplayLocation.AfterAmount) {
|
||||
return `${value}${separator}${symbol}`;
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
+59
-23
@@ -45,6 +45,10 @@ import {
|
||||
getAdaptiveDisplayAmountRate
|
||||
} from './numeral.js';
|
||||
|
||||
import {
|
||||
appendCurrencySymbol
|
||||
} from './currency.js';
|
||||
|
||||
import {
|
||||
getCategorizedAccounts,
|
||||
getAllFilteredAccountsBalance
|
||||
@@ -852,6 +856,42 @@ function getAllDigitGroupingTypes(translateFn) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
function getAllCurrencyDisplayTypes(userStore, settingsStore, translateFn) {
|
||||
const defaultCurrencyDisplayTypeName = translateFn('default.currencyDisplayType');
|
||||
let defaultCurrencyDisplayType = currency.allCurrencyDisplayType[defaultCurrencyDisplayTypeName];
|
||||
|
||||
if (!defaultCurrencyDisplayType) {
|
||||
defaultCurrencyDisplayType = currency.defaultCurrencyDisplayType;
|
||||
}
|
||||
|
||||
const defaultCurrency = userStore.currentUserDefaultCurrency;
|
||||
|
||||
const ret = [];
|
||||
const defaultSampleValue = getFormatedAmountWithCurrency(12345, defaultCurrency, translateFn, userStore, settingsStore, false, defaultCurrencyDisplayType);
|
||||
|
||||
ret.push({
|
||||
type: currency.defaultCurrencyDisplayTypeValue,
|
||||
displayName: `${translateFn('Language Default')} (${defaultSampleValue})`
|
||||
});
|
||||
|
||||
for (let i = 0; i < currency.allCurrencyDisplayTypeArray.length; i++) {
|
||||
const type = currency.allCurrencyDisplayTypeArray[i];
|
||||
let displayName = translateFn(type.name);
|
||||
|
||||
if (type.symbol !== currency.allCurrencyDisplaySymbol.None) {
|
||||
const sampleValue = getFormatedAmountWithCurrency(12345, defaultCurrency, translateFn, userStore, settingsStore, false, type);
|
||||
displayName = `${displayName} (${sampleValue})`
|
||||
}
|
||||
|
||||
ret.push({
|
||||
type: type.type,
|
||||
displayName: displayName
|
||||
});
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
function getCurrentDecimalSeparator(translateFn, decimalSeparator) {
|
||||
let decimalSeparatorType = numeral.allDecimalSeparatorMap[decimalSeparator];
|
||||
|
||||
@@ -920,7 +960,7 @@ function getFormatedAmount(value, translateFn, userStore) {
|
||||
return formatAmount(value, numberFormatOptions);
|
||||
}
|
||||
|
||||
function getFormatedAmountWithCurrency(value, currencyCode, translateFn, userStore, settingsStore, notConvertValue) {
|
||||
function getFormatedAmountWithCurrency(value, currencyCode, translateFn, userStore, settingsStore, notConvertValue, currencyDisplayType) {
|
||||
if (!isNumber(value) && !isString(value)) {
|
||||
return value;
|
||||
}
|
||||
@@ -950,30 +990,25 @@ function getFormatedAmountWithCurrency(value, currencyCode, translateFn, userSto
|
||||
currencyCode = '';
|
||||
}
|
||||
|
||||
const currencyDisplayMode = settingsStore.appSettings.currencyDisplayMode;
|
||||
|
||||
if (currencyCode && currencyDisplayMode === currency.allCurrencyDisplayModes.Symbol) {
|
||||
const currencyInfo = currency.all[currencyCode];
|
||||
let currencySymbol = currency.defaultCurrencySymbol;
|
||||
|
||||
if (currencyInfo && currencyInfo.symbol) {
|
||||
currencySymbol = currencyInfo.symbol;
|
||||
} else if (currencyInfo && currencyInfo.code) {
|
||||
currencySymbol = currencyInfo.code;
|
||||
}
|
||||
|
||||
return translateFn('format.currency.symbol', {
|
||||
amount: value,
|
||||
symbol: currencySymbol
|
||||
});
|
||||
} else if (currencyCode && currencyDisplayMode === currency.allCurrencyDisplayModes.Code) {
|
||||
return `${value} ${currencyCode}`;
|
||||
} else if (currencyCode && currencyDisplayMode === currency.allCurrencyDisplayModes.Name) {
|
||||
const currencyName = getCurrencyName(currencyCode, translateFn);
|
||||
return `${value} ${currencyName}`;
|
||||
} else {
|
||||
if (!currencyCode) {
|
||||
return value;
|
||||
}
|
||||
|
||||
if (!currencyDisplayType) {
|
||||
currencyDisplayType = currency.allCurrencyDisplayTypeMap[userStore.currentUserCurrencyDisplayType];
|
||||
|
||||
if (!currencyDisplayType) {
|
||||
const defaultCurrencyDisplayTypeName = translateFn('default.currencyDisplayType');
|
||||
currencyDisplayType = currency.allCurrencyDisplayType[defaultCurrencyDisplayTypeName];
|
||||
}
|
||||
|
||||
if (!currencyDisplayType) {
|
||||
currencyDisplayType = currency.defaultCurrencyDisplayType;
|
||||
}
|
||||
}
|
||||
|
||||
const currencyName = getCurrencyName(currencyCode, translateFn);
|
||||
return appendCurrencySymbol(value, currencyDisplayType, currencyCode, currencyName);
|
||||
}
|
||||
|
||||
function getFormatedExchangeRateAmount(value, translateFn, userStore) {
|
||||
@@ -1534,6 +1569,7 @@ export function i18nFunctions(i18nGlobal) {
|
||||
getAllDecimalSeparators: () => getAllDecimalSeparators(i18nGlobal.t),
|
||||
getAllDigitGroupingSymbols: () => getAllDigitGroupingSymbols(i18nGlobal.t),
|
||||
getAllDigitGroupingTypes: () => getAllDigitGroupingTypes(i18nGlobal.t),
|
||||
getAllCurrencyDisplayTypes: (settingsStore, userStore) => getAllCurrencyDisplayTypes(userStore, settingsStore, i18nGlobal.t),
|
||||
getCurrentDecimalSeparator: (userStore) => getCurrentDecimalSeparator(i18nGlobal.t, userStore.currentUserDecimalSeparator),
|
||||
getCurrentDigitGroupingSymbol: (userStore) => getCurrentDigitGroupingSymbol(i18nGlobal.t, userStore.currentUserDigitGroupingSymbol),
|
||||
getCurrentDigitGroupingType: (userStore) => getCurrentDigitGroupingType(i18nGlobal.t, userStore.currentUserDigitGrouping),
|
||||
|
||||
+3
-2
@@ -169,7 +169,7 @@ export default {
|
||||
getProfile: () => {
|
||||
return axios.get('v1/users/profile/get.json');
|
||||
},
|
||||
updateProfile: ({ email, nickname, password, oldPassword, defaultAccountId, transactionEditScope, language, defaultCurrency, firstDayOfWeek, longDateFormat, shortDateFormat, longTimeFormat, shortTimeFormat, decimalSeparator, digitGroupingSymbol, digitGrouping }) => {
|
||||
updateProfile: ({ email, nickname, password, oldPassword, defaultAccountId, transactionEditScope, language, defaultCurrency, firstDayOfWeek, longDateFormat, shortDateFormat, longTimeFormat, shortTimeFormat, decimalSeparator, digitGroupingSymbol, digitGrouping, currencyDisplayType }) => {
|
||||
return axios.post('v1/users/profile/update.json', {
|
||||
email,
|
||||
nickname,
|
||||
@@ -186,7 +186,8 @@ export default {
|
||||
shortTimeFormat,
|
||||
decimalSeparator,
|
||||
digitGroupingSymbol,
|
||||
digitGrouping
|
||||
digitGrouping,
|
||||
currencyDisplayType
|
||||
});
|
||||
},
|
||||
resendVerifyEmailByLoginedUser: () => {
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
import currencyConstants from '@/consts/currency.js';
|
||||
import timezoneConstants from '@/consts/timezone.js';
|
||||
import statisticsConstants from '@/consts/statistics.js';
|
||||
|
||||
@@ -13,7 +12,6 @@ const defaultSettings = {
|
||||
applicationLockWebAuthn: false,
|
||||
autoUpdateExchangeRatesData: true,
|
||||
autoGetCurrentGeoLocation: false,
|
||||
currencyDisplayMode: currencyConstants.defaultCurrencyDisplayMode,
|
||||
showAmountInHomePage: true,
|
||||
timezoneUsedForStatisticsInHomePage: timezoneConstants.defaultTimezoneTypesUsedForStatistics,
|
||||
itemsCountInTransactionListPage: 15,
|
||||
@@ -166,14 +164,6 @@ export function setAutoGetCurrentGeoLocation(value) {
|
||||
setOption('autoGetCurrentGeoLocation', value);
|
||||
}
|
||||
|
||||
export function getCurrencyDisplayMode() {
|
||||
return getOption('currencyDisplayMode');
|
||||
}
|
||||
|
||||
export function setCurrencyDisplayMode(value) {
|
||||
setOption('currencyDisplayMode', value);
|
||||
}
|
||||
|
||||
export function isShowAmountInHomePage() {
|
||||
return getOption('showAmountInHomePage');
|
||||
}
|
||||
|
||||
+2
-4
@@ -13,7 +13,8 @@ export default {
|
||||
'shortTimeFormat': 'HHMMA',
|
||||
'decimalSeparator': 'Dot',
|
||||
'digitGroupingSymbol': 'Comma',
|
||||
'digitGrouping': 'ThousandsSeparator'
|
||||
'digitGrouping': 'ThousandsSeparator',
|
||||
'currencyDisplayType': 'SymbolBeforeAmount' // see allCurrencyDisplayType @ currency.js
|
||||
},
|
||||
'format': { // The type of date or time format is moment format, ref: https://momentjs.com/docs/#/displaying/
|
||||
'longDate': {
|
||||
@@ -66,9 +67,6 @@ export default {
|
||||
'a_hh_mm': 'A hh:mm',
|
||||
'hh_mm_a': 'hh:mm A'
|
||||
},
|
||||
'currency': {
|
||||
'symbol': '{symbol} {amount}'
|
||||
},
|
||||
'misc': {
|
||||
'multiTextJoinSeparator': ', ',
|
||||
'hoursBehindDefaultTimezone': '{hours} hour(s) behind default timezone',
|
||||
|
||||
@@ -13,7 +13,8 @@ export default {
|
||||
'shortTimeFormat': 'HHMM',
|
||||
'decimalSeparator': 'Dot',
|
||||
'digitGroupingSymbol': 'Comma',
|
||||
'digitGrouping': 'ThousandsSeparator'
|
||||
'digitGrouping': 'ThousandsSeparator',
|
||||
'currencyDisplayType': 'SymbolBeforeAmount'
|
||||
},
|
||||
'format': {
|
||||
'longDate': {
|
||||
@@ -66,9 +67,6 @@ export default {
|
||||
'a_hh_mm': 'A hh:mm',
|
||||
'hh_mm_a': 'hh:mm A'
|
||||
},
|
||||
'currency': {
|
||||
'symbol': '{symbol} {amount}'
|
||||
},
|
||||
'misc': {
|
||||
'multiTextJoinSeparator': '、',
|
||||
'hoursBehindDefaultTimezone': '比默认时区晚{hours}小时',
|
||||
|
||||
+2
-1
@@ -383,7 +383,8 @@ export const useRootStore = defineStore('root', {
|
||||
shortTimeFormat: profile.shortTimeFormat,
|
||||
decimalSeparator: profile.decimalSeparator,
|
||||
digitGroupingSymbol: profile.digitGroupingSymbol,
|
||||
digitGrouping: profile.digitGrouping
|
||||
digitGrouping: profile.digitGrouping,
|
||||
currencyDisplayType: profile.currencyDisplayType
|
||||
}).then(response => {
|
||||
const data = response.data;
|
||||
|
||||
|
||||
@@ -14,7 +14,6 @@ export const useSettingsStore = defineStore('settings', {
|
||||
applicationLockWebAuthn: settings.isEnableApplicationLockWebAuthn(),
|
||||
autoUpdateExchangeRatesData: settings.isAutoUpdateExchangeRatesData(),
|
||||
autoGetCurrentGeoLocation: settings.isAutoGetCurrentGeoLocation(),
|
||||
currencyDisplayMode: settings.getCurrencyDisplayMode(),
|
||||
showAmountInHomePage: settings.isShowAmountInHomePage(),
|
||||
timezoneUsedForStatisticsInHomePage: settings.getTimezoneUsedForStatisticsInHomePage(),
|
||||
itemsCountInTransactionListPage: settings.getItemsCountInTransactionListPage(),
|
||||
@@ -67,10 +66,6 @@ export const useSettingsStore = defineStore('settings', {
|
||||
settings.setAutoGetCurrentGeoLocation(value);
|
||||
this.appSettings.autoGetCurrentGeoLocation = value;
|
||||
},
|
||||
setCurrencyDisplayMode(value) {
|
||||
settings.setCurrencyDisplayMode(value);
|
||||
this.appSettings.currencyDisplayMode = value;
|
||||
},
|
||||
setShowAmountInHomePage(value) {
|
||||
settings.setShowAmountInHomePage(value);
|
||||
this.appSettings.showAmountInHomePage = value;
|
||||
|
||||
@@ -65,6 +65,10 @@ export const useUserStore = defineStore('user', {
|
||||
currentUserDigitGrouping(state) {
|
||||
const userInfo = state.currentUserInfo || {};
|
||||
return userInfo.digitGrouping;
|
||||
},
|
||||
currentUserCurrencyDisplayType(state) {
|
||||
const userInfo = state.currentUserInfo || {};
|
||||
return userInfo.currencyDisplayType;
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
|
||||
@@ -47,23 +47,6 @@
|
||||
/>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" md="6">
|
||||
<v-select
|
||||
item-title="displayName"
|
||||
item-value="value"
|
||||
persistent-placeholder
|
||||
:label="$t('Currency Display Mode')"
|
||||
:placeholder="$t('Currency Display Mode')"
|
||||
:items="[
|
||||
{ value: allCurrencyDisplayModes.None, displayName: $t('None') },
|
||||
{ value: allCurrencyDisplayModes.Symbol, displayName: $t('Currency Symbol') },
|
||||
{ value: allCurrencyDisplayModes.Code, displayName: $t('Currency Code') },
|
||||
{ value: allCurrencyDisplayModes.Name, displayName: $t('Currency Name') }
|
||||
]"
|
||||
v-model="currencyDisplayMode"
|
||||
/>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" md="6">
|
||||
<v-select
|
||||
item-title="displayName"
|
||||
@@ -182,7 +165,6 @@ import { useOverviewStore } from '@/stores/overview.js';
|
||||
import { useStatisticsStore } from '@/stores/statistics.js';
|
||||
import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
|
||||
|
||||
import currencyConstants from '@/consts/currency.js';
|
||||
import { getSystemTheme } from '@/lib/ui.js';
|
||||
|
||||
export default {
|
||||
@@ -194,9 +176,6 @@ export default {
|
||||
allTimezones() {
|
||||
return this.$locale.getAllTimezones(true);
|
||||
},
|
||||
allCurrencyDisplayModes() {
|
||||
return currencyConstants.allCurrencyDisplayModes;
|
||||
},
|
||||
allTimezoneTypesUsedForStatistics() {
|
||||
return this.$locale.getAllTimezoneTypesUsedForStatistics(this.timeZone);
|
||||
},
|
||||
@@ -236,14 +215,6 @@ export default {
|
||||
this.settingsStore.setAutoUpdateExchangeRatesData(value);
|
||||
}
|
||||
},
|
||||
currencyDisplayMode: {
|
||||
get: function () {
|
||||
return this.settingsStore.appSettings.currencyDisplayMode;
|
||||
},
|
||||
set: function (value) {
|
||||
this.settingsStore.setCurrencyDisplayMode(value);
|
||||
}
|
||||
},
|
||||
showAccountBalance: {
|
||||
get: function () {
|
||||
return this.settingsStore.appSettings.showAccountBalance;
|
||||
|
||||
@@ -244,6 +244,19 @@
|
||||
v-model="newProfile.digitGrouping"
|
||||
/>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" md="6">
|
||||
<v-select
|
||||
item-title="displayName"
|
||||
item-value="type"
|
||||
persistent-placeholder
|
||||
:disabled="loading || saving"
|
||||
:label="$t('Currency Display Mode')"
|
||||
:placeholder="$t('Currency Display Mode')"
|
||||
:items="allCurrencyDisplayTypes"
|
||||
v-model="newProfile.currencyDisplayType"
|
||||
/>
|
||||
</v-col>
|
||||
</v-row>
|
||||
</v-card-text>
|
||||
|
||||
@@ -303,7 +316,8 @@ export default {
|
||||
shortTimeFormat: 0,
|
||||
decimalSeparator: 0,
|
||||
digitGroupingSymbol: 0,
|
||||
digitGrouping: 0
|
||||
digitGrouping: 0,
|
||||
currencyDisplayType: 0
|
||||
},
|
||||
oldProfile: {
|
||||
email: '',
|
||||
@@ -319,7 +333,8 @@ export default {
|
||||
shortTimeFormat: 0,
|
||||
decimalSeparator: 0,
|
||||
digitGroupingSymbol: 0,
|
||||
digitGrouping: 0
|
||||
digitGrouping: 0,
|
||||
currencyDisplayType: 0
|
||||
},
|
||||
emailVerified: false,
|
||||
loading: true,
|
||||
@@ -371,6 +386,9 @@ export default {
|
||||
allDigitGroupingTypes() {
|
||||
return this.$locale.getAllDigitGroupingTypes();
|
||||
},
|
||||
allCurrencyDisplayTypes() {
|
||||
return this.$locale.getAllCurrencyDisplayTypes(this.settingsStore, this.userStore);
|
||||
},
|
||||
allTransactionEditScopeTypes() {
|
||||
return this.$locale.getAllTransactionEditScopeTypes();
|
||||
},
|
||||
@@ -405,7 +423,8 @@ export default {
|
||||
this.newProfile.shortTimeFormat === this.oldProfile.shortTimeFormat &&
|
||||
this.newProfile.decimalSeparator === this.oldProfile.decimalSeparator &&
|
||||
this.newProfile.digitGroupingSymbol === this.oldProfile.digitGroupingSymbol &&
|
||||
this.newProfile.digitGrouping === this.oldProfile.digitGrouping) {
|
||||
this.newProfile.digitGrouping === this.oldProfile.digitGrouping &&
|
||||
this.newProfile.currencyDisplayType === this.oldProfile.currencyDisplayType) {
|
||||
return 'Nothing has been modified';
|
||||
} else {
|
||||
return null;
|
||||
@@ -535,6 +554,7 @@ export default {
|
||||
this.oldProfile.decimalSeparator = profile.decimalSeparator;
|
||||
this.oldProfile.digitGroupingSymbol = profile.digitGroupingSymbol;
|
||||
this.oldProfile.digitGrouping = profile.digitGrouping;
|
||||
this.oldProfile.currencyDisplayType = profile.currencyDisplayType;
|
||||
|
||||
this.newProfile.email = this.oldProfile.email
|
||||
this.newProfile.nickname = this.oldProfile.nickname;
|
||||
@@ -550,6 +570,7 @@ export default {
|
||||
this.newProfile.decimalSeparator = this.oldProfile.decimalSeparator;
|
||||
this.newProfile.digitGroupingSymbol = this.oldProfile.digitGroupingSymbol;
|
||||
this.newProfile.digitGrouping = this.oldProfile.digitGrouping;
|
||||
this.newProfile.currencyDisplayType = this.oldProfile.currencyDisplayType;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
@@ -47,18 +47,6 @@
|
||||
<f7-toggle :checked="isAutoUpdateExchangeRatesData" @toggle:change="isAutoUpdateExchangeRatesData = $event"></f7-toggle>
|
||||
</f7-list-item>
|
||||
|
||||
<f7-list-item
|
||||
:key="currentLocale + '_currency_display'"
|
||||
:title="$t('Currency Display Mode')"
|
||||
smart-select :smart-select-params="{ openIn: 'popup', popupPush: true, closeOnSelect: true, scrollToSelectedItem: true, searchbar: true, searchbarPlaceholder: $t('Currency Display Mode'), searchbarDisableText: $t('Cancel'), appendSearchbarNotFound: $t('No results'), popupCloseLinkText: $t('Done') }">
|
||||
<select v-model="currencyDisplayMode">
|
||||
<option :value="allCurrencyDisplayModes.None">{{ $t('None') }}</option>
|
||||
<option :value="allCurrencyDisplayModes.Symbol">{{ $t('Currency Symbol') }}</option>
|
||||
<option :value="allCurrencyDisplayModes.Code">{{ $t('Currency Code') }}</option>
|
||||
<option :value="allCurrencyDisplayModes.Name">{{ $t('Currency Name') }}</option>
|
||||
</select>
|
||||
</f7-list-item>
|
||||
|
||||
<f7-list-item>
|
||||
<span>{{ $t('Show Account Balance') }}</span>
|
||||
<f7-toggle :checked="showAccountBalance" @toggle:change="showAccountBalance = $event"></f7-toggle>
|
||||
@@ -90,7 +78,6 @@ import { useOverviewStore } from '@/stores/overview.js';
|
||||
import { useStatisticsStore } from '@/stores/statistics.js';
|
||||
import { useExchangeRatesStore } from '@/stores/exchangeRates.js';
|
||||
|
||||
import currencyConstants from '@/consts/currency.js';
|
||||
import { getDesktopVersionPath } from '@/lib/version.js';
|
||||
|
||||
export default {
|
||||
@@ -116,9 +103,6 @@ export default {
|
||||
allTimezones() {
|
||||
return this.$locale.getAllTimezones(true);
|
||||
},
|
||||
allCurrencyDisplayModes() {
|
||||
return currencyConstants.allCurrencyDisplayModes;
|
||||
},
|
||||
currentNickName() {
|
||||
return this.userStore.currentUserNickname || this.$t('User');
|
||||
},
|
||||
@@ -160,14 +144,6 @@ export default {
|
||||
isEnableApplicationLock() {
|
||||
return this.settingsStore.appSettings.applicationLock;
|
||||
},
|
||||
currencyDisplayMode: {
|
||||
get: function () {
|
||||
return this.settingsStore.appSettings.currencyDisplayMode;
|
||||
},
|
||||
set: function (value) {
|
||||
this.settingsStore.setCurrencyDisplayMode(value);
|
||||
}
|
||||
},
|
||||
showAccountBalance: {
|
||||
get: function () {
|
||||
return this.settingsStore.appSettings.showAccountBalance;
|
||||
|
||||
@@ -245,6 +245,19 @@
|
||||
</select>
|
||||
</f7-list-item>
|
||||
|
||||
<f7-list-item
|
||||
class="list-item-with-header-and-title list-item-no-item-after"
|
||||
:header="$t('Currency Display Mode')"
|
||||
:title="getNameByKeyValue(allCurrencyDisplayTypes, newProfile.currencyDisplayType, 'type', 'displayName')"
|
||||
smart-select :smart-select-params="{ openIn: 'popup', popupPush: true, closeOnSelect: true, scrollToSelectedItem: true, searchbar: true, searchbarPlaceholder: $t('Currency Display Mode'), searchbarDisableText: $t('Cancel'), appendSearchbarNotFound: $t('No results'), pageTitle: $t('Currency Display Mode'), popupCloseLinkText: $t('Done') }"
|
||||
>
|
||||
<select v-model="newProfile.currencyDisplayType">
|
||||
<option :value="format.type"
|
||||
:key="format.type"
|
||||
v-for="format in allCurrencyDisplayTypes">{{ format.displayName }}</option>
|
||||
</select>
|
||||
</f7-list-item>
|
||||
|
||||
<f7-list-item class="ebk-list-item-error-info" v-if="langAndRegionInputIsInvalid" :footer="$t(langAndRegionInputInvalidProblemMessage)"></f7-list-item>
|
||||
</f7-list>
|
||||
|
||||
@@ -303,7 +316,8 @@ export default {
|
||||
shortTimeFormat: 0,
|
||||
decimalSeparator: 0,
|
||||
digitGroupingSymbol: 0,
|
||||
digitGrouping: 0
|
||||
digitGrouping: 0,
|
||||
currencyDisplayType: 0
|
||||
},
|
||||
oldProfile: {
|
||||
email: '',
|
||||
@@ -319,7 +333,8 @@ export default {
|
||||
shortTimeFormat: 0,
|
||||
decimalSeparator: 0,
|
||||
digitGroupingSymbol: 0,
|
||||
digitGrouping: 0
|
||||
digitGrouping: 0,
|
||||
currencyDisplayType: 0
|
||||
},
|
||||
emailVerified: false,
|
||||
currentPassword: '',
|
||||
@@ -373,6 +388,9 @@ export default {
|
||||
allDigitGroupingTypes() {
|
||||
return this.$locale.getAllDigitGroupingTypes();
|
||||
},
|
||||
allCurrencyDisplayTypes() {
|
||||
return this.$locale.getAllCurrencyDisplayTypes(this.settingsStore, this.userStore);
|
||||
},
|
||||
allTransactionEditScopeTypes() {
|
||||
return this.$locale.getAllTransactionEditScopeTypes();
|
||||
},
|
||||
@@ -420,7 +438,8 @@ export default {
|
||||
this.newProfile.shortTimeFormat === this.oldProfile.shortTimeFormat &&
|
||||
this.newProfile.decimalSeparator === this.oldProfile.decimalSeparator &&
|
||||
this.newProfile.digitGroupingSymbol === this.oldProfile.digitGroupingSymbol &&
|
||||
this.newProfile.digitGrouping === this.oldProfile.digitGrouping) {
|
||||
this.newProfile.digitGrouping === this.oldProfile.digitGrouping &&
|
||||
this.newProfile.currencyDisplayType === this.oldProfile.currencyDisplayType) {
|
||||
return 'Nothing has been modified';
|
||||
} else if (!this.newProfile.password && this.newProfile.confirmPassword) {
|
||||
return 'Password cannot be blank';
|
||||
@@ -572,6 +591,7 @@ export default {
|
||||
this.oldProfile.decimalSeparator = profile.decimalSeparator;
|
||||
this.oldProfile.digitGroupingSymbol = profile.digitGroupingSymbol;
|
||||
this.oldProfile.digitGrouping = profile.digitGrouping;
|
||||
this.oldProfile.currencyDisplayType = profile.currencyDisplayType;
|
||||
|
||||
this.newProfile.email = this.oldProfile.email
|
||||
this.newProfile.nickname = this.oldProfile.nickname;
|
||||
@@ -587,6 +607,7 @@ export default {
|
||||
this.newProfile.decimalSeparator = this.oldProfile.decimalSeparator;
|
||||
this.newProfile.digitGroupingSymbol = this.oldProfile.digitGroupingSymbol;
|
||||
this.newProfile.digitGrouping = this.oldProfile.digitGrouping;
|
||||
this.newProfile.currencyDisplayType = this.oldProfile.currencyDisplayType;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user