diff options
author | Aijana Schumann <aijana.schumann@highstreet-technologies.com> | 2020-08-27 09:01:53 +0200 |
---|---|---|
committer | Aijana Schumann <aijana.schumann@highstreet-technologies.com> | 2020-08-27 11:52:38 +0200 |
commit | 4bd84bebdaa0c2d82050fbedd1fa8260eb62146d (patch) | |
tree | 3f26dfc6c7da0f176f31bcde112971b0b8c552ce /sdnr/wt/odlux/apps/configurationApp/src/components/uiElementNumber.tsx | |
parent | 958de10b4c433eb6110b93007f281b07515ed6fe (diff) |
Add link calculation app
Add link calculation app to odlux
Issue-ID: CCSDK-2562
Signed-off-by: Aijana Schumann <aijana.schumann@highstreet-technologies.com>
Change-Id: Ifc0a5b2a8bb974dfd85d70a9f05990b1f11925a3
Signed-off-by: Aijana Schumann <aijana.schumann@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/odlux/apps/configurationApp/src/components/uiElementNumber.tsx')
-rw-r--r-- | sdnr/wt/odlux/apps/configurationApp/src/components/uiElementNumber.tsx | 81 |
1 files changed, 37 insertions, 44 deletions
diff --git a/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementNumber.tsx b/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementNumber.tsx index cf462052e..ac4afc1d9 100644 --- a/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementNumber.tsx +++ b/sdnr/wt/odlux/apps/configurationApp/src/components/uiElementNumber.tsx @@ -19,59 +19,52 @@ import { ViewElementNumber } from "models/uiModels"; import { Tooltip, InputAdornment } from "@material-ui/core"; import * as React from 'react'; -import { baseProps } from "./baseProps"; +import { BaseProps } from "./baseProps"; import { IfWhenTextInput } from "./ifWhenTextInput"; import { checkRange } from "./verifyer"; -type numberInputProps = baseProps; +type numberInputProps = BaseProps<number>; export const UiElementNumber = (props: numberInputProps) => { - const [error, setError] = React.useState(false); - const [helperText, setHelperText] = React.useState(""); - const [isTooltipVisible, setTooltipVisibility] = React.useState(true); + const [error, setError] = React.useState(false); + const [helperText, setHelperText] = React.useState(""); + const [isTooltipVisible, setTooltipVisibility] = React.useState(true); - const element = props.value as ViewElementNumber; + const element = props.value as ViewElementNumber; - const verifyValue = (data: string) => { - - if (data.trim().length > 0) { - const num = Number(data); - if (!isNaN(num)) { - const result = checkRange(element, num); - if (result.length > 0) { - setError(true); - setHelperText(result); - } else { - setError(false); - setHelperText(""); - } - } else { - setError(true); - setHelperText("Input is not a number."); - } - } else { - setError(false); - setHelperText(""); - } - - props.onChange(data); + const verifyValue = (data: string) => { + const num = Number(data); + if (!isNaN(num)) { + const result = checkRange(element, num); + if (result.length > 0) { + setError(true); + setHelperText(result); + } else { + setError(false); + setHelperText(""); + } + } else { + setError(true); + setHelperText("Input is not a number."); } + props.onChange(num); + } - return ( - <Tooltip title={isTooltipVisible ? element.description || '' : ''}> - <IfWhenTextInput element={element} toogleTooltip={(val: boolean) => setTooltipVisibility(val)} - spellCheck={false} autoFocus margin="dense" - id={element.id} label={element.label} type="text" value={props.inputValue} - style={{ width: 485, marginLeft: 20, marginRight: 20 }} - onChange={(e: any) => { verifyValue(e.target.value) }} - error={error} - readOnly={props.readOnly} - disabled={props.disabled} - helperText={helperText} - startAdornment={element.units != null ? <InputAdornment position="start">{element.units}</InputAdornment> : undefined} - /> - </Tooltip> - ); + return ( + <Tooltip title={isTooltipVisible ? element.description || '' : ''}> + <IfWhenTextInput element={element} onChangeTooltipVisuability={setTooltipVisibility} + spellCheck={false} autoFocus margin="dense" + id={element.id} label={element.label} type="text" value={props.inputValue} + style={{ width: 485, marginLeft: 20, marginRight: 20 }} + onChange={(e) => { verifyValue(e.target.value) }} + error={error} + readOnly={props.readOnly} + disabled={props.disabled} + helperText={helperText} + startAdornment={element.units != null ? <InputAdornment position="start">{element.units}</InputAdornment> : undefined} + /> + </Tooltip> + ); }
\ No newline at end of file |