fix user custom exchange rates update page /dialog could not be opened
This commit is contained in:
@@ -3,7 +3,7 @@ import { computed, watch } from 'vue';
|
|||||||
import { useI18n } from '@/locales/helpers.ts';
|
import { useI18n } from '@/locales/helpers.ts';
|
||||||
import { type CommonNumberInputProps, useCommonNumberInputBase } from '@/components/base/CommonNumberInputBase.ts';
|
import { type CommonNumberInputProps, useCommonNumberInputBase } from '@/components/base/CommonNumberInputBase.ts';
|
||||||
|
|
||||||
import { isNumber, replaceAll, removeAll } from '@/lib/common.ts';
|
import { isDefined, isNumber, replaceAll, removeAll } from '@/lib/common.ts';
|
||||||
import { NumeralSystem } from '@/core/numeral.ts';
|
import { NumeralSystem } from '@/core/numeral.ts';
|
||||||
|
|
||||||
export interface NumberInputProps extends CommonNumberInputProps {
|
export interface NumberInputProps extends CommonNumberInputProps {
|
||||||
@@ -60,11 +60,11 @@ export function useNumberInputBase(props: NumberInputProps, emit: NumberInputEmi
|
|||||||
|
|
||||||
function getValidFormattedValue(value: number, textualValue: string): string {
|
function getValidFormattedValue(value: number, textualValue: string): string {
|
||||||
if (isNumber(props.minValue) && value < props.minValue) {
|
if (isNumber(props.minValue) && value < props.minValue) {
|
||||||
return getFormattedValue(props.minValue);
|
return getFormattedValue(props.minValue, numeralSystem.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNumber(props.maxValue) && value > props.maxValue) {
|
if (isNumber(props.maxValue) && value > props.maxValue) {
|
||||||
return getFormattedValue(props.maxValue);
|
return getFormattedValue(props.maxValue, numeralSystem.value);
|
||||||
}
|
}
|
||||||
|
|
||||||
const decimalSeparator = getCurrentDecimalSeparator();
|
const decimalSeparator = getCurrentDecimalSeparator();
|
||||||
@@ -72,25 +72,29 @@ export function useNumberInputBase(props: NumberInputProps, emit: NumberInputEmi
|
|||||||
return replaceAll(removeAll(textualValue, digitGroupingSymbol), '.', decimalSeparator);
|
return replaceAll(removeAll(textualValue, digitGroupingSymbol), '.', decimalSeparator);
|
||||||
}
|
}
|
||||||
|
|
||||||
function getFormattedValue(value: number): string {
|
function getFormattedValue(value: number, customNumeralSystem?: NumeralSystem): string {
|
||||||
|
if (!isDefined(customNumeralSystem)) {
|
||||||
|
customNumeralSystem = getCurrentNumeralSystemType();
|
||||||
|
}
|
||||||
|
|
||||||
if (!Number.isNaN(value) && Number.isFinite(value)) {
|
if (!Number.isNaN(value) && Number.isFinite(value)) {
|
||||||
const decimalSeparator = getCurrentDecimalSeparator();
|
const decimalSeparator = getCurrentDecimalSeparator();
|
||||||
|
|
||||||
if (isNumber(props.maxDecimalCount) && props.maxDecimalCount >= 0) {
|
if (isNumber(props.maxDecimalCount) && props.maxDecimalCount >= 0) {
|
||||||
return replaceAll(numeralSystem.value.replaceWesternArabicDigitsToLocalizedDigits(value.toFixed(props.maxDecimalCount)), '.', decimalSeparator);
|
return replaceAll(customNumeralSystem.replaceWesternArabicDigitsToLocalizedDigits(value.toFixed(props.maxDecimalCount)), '.', decimalSeparator);
|
||||||
} else {
|
} else {
|
||||||
return replaceAll(numeralSystem.value.replaceWesternArabicDigitsToLocalizedDigits(value.toString(10)), '.', decimalSeparator);
|
return replaceAll(customNumeralSystem.replaceWesternArabicDigitsToLocalizedDigits(value.toString(10)), '.', decimalSeparator);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return numeralSystem.value.digitZero;
|
return customNumeralSystem.digitZero;
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(() => props.modelValue, (newValue) => {
|
watch(() => props.modelValue, (newValue) => {
|
||||||
const numericCurrentValue = parseNumber(currentValue.value);
|
const numericCurrentValue = parseNumber(currentValue.value);
|
||||||
|
|
||||||
if (newValue !== numericCurrentValue) {
|
if (newValue !== numericCurrentValue) {
|
||||||
const newStringValue = getFormattedValue(newValue);
|
const newStringValue = getFormattedValue(newValue, numeralSystem.value);
|
||||||
|
|
||||||
if (!(newStringValue === numeralSystem.value.digitZero && currentValue.value === '')) {
|
if (!(newStringValue === numeralSystem.value.digitZero && currentValue.value === '')) {
|
||||||
currentValue.value = newStringValue;
|
currentValue.value = newStringValue;
|
||||||
|
|||||||
Reference in New Issue
Block a user