forked from ddrilling/asb_cloud_front
Возможность enum.
Подстановка текста из словаря по ключевому значению.
This commit is contained in:
parent
f384981d7b
commit
3a15744a7a
@ -7,7 +7,7 @@ export const formatNumber = (value, format) =>
|
|||||||
? (+value).toFixed(format)
|
? (+value).toFixed(format)
|
||||||
: (+value).toPrecision(4)
|
: (+value).toPrecision(4)
|
||||||
|
|
||||||
export const ValueDisplay = ({prefix, value, suffix, isArrowVisible, format}) =>{
|
export const ValueDisplay = ({prefix, value, suffix, isArrowVisible, format, enumeration}) => {
|
||||||
const [val, setVal] = useState('---')
|
const [val, setVal] = useState('---')
|
||||||
const [arrowState, setArrowState] = useState({
|
const [arrowState, setArrowState] = useState({
|
||||||
preVal: NaN,
|
preVal: NaN,
|
||||||
@ -21,6 +21,11 @@ export const ValueDisplay = ({prefix, value, suffix, isArrowVisible, format}) =>
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(enumeration && enumeration[value]){
|
||||||
|
setVal(enumeration[value])
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
if(Number.isFinite(+value)){
|
if(Number.isFinite(+value)){
|
||||||
if ((isArrowVisible) && (arrowState.preTimestamp + 1000 < Date.now()))
|
if ((isArrowVisible) && (arrowState.preTimestamp + 1000 < Date.now()))
|
||||||
{
|
{
|
||||||
@ -50,7 +55,7 @@ export const ValueDisplay = ({prefix, value, suffix, isArrowVisible, format}) =>
|
|||||||
}
|
}
|
||||||
|
|
||||||
setVal(value)
|
setVal(value)
|
||||||
},[value, isArrowVisible, arrowState, format])
|
},[value, isArrowVisible, arrowState, format, enumeration])
|
||||||
|
|
||||||
let arrow = null
|
let arrow = null
|
||||||
if(isArrowVisible)
|
if(isArrowVisible)
|
||||||
|
Loading…
Reference in New Issue
Block a user