2 * ============LICENSE_START========================================================================
3 * ONAP : ccsdk feature sdnr wt odlux
4 * =================================================================================================
5 * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6 * =================================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8 * in compliance with the License. You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software distributed under the License
13 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14 * or implied. See the License for the specific language governing permissions and limitations under
16 * ============LICENSE_END==========================================================================
19 import { ViewElementBase } from "models/uiModels";
20 import { TextField, InputAdornment, Input, Tooltip, Divider, IconButton, InputBase, Paper, makeStyles, Theme, createStyles, FormControl, InputLabel, FormHelperText } from "@material-ui/core";
21 import * as React from 'react';
22 import { faAdjust } from "@fortawesome/free-solid-svg-icons";
23 import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
24 import { InputProps } from "@material-ui/core/Input";
26 const useStyles = makeStyles((theme: Theme) =>
41 type ifwhenProps = { element: ViewElementBase, id: any, label: any, style: any, helperText: string, error: boolean, toogleTooltip(value: boolean): void, [x: string]: any };
43 export const IfWhenTextInput = (props: ifwhenProps) => {
45 const { element, toogleTooltip, id, label, helperText: errorText, error, style, ...otherProps } = props;
46 const classes = useStyles();
49 const ifFeature = element.ifFeature ? <Tooltip onMouseMove={e => props.toogleTooltip(false)} onMouseOut={e => props.toogleTooltip(true)} title={element.ifFeature}><InputAdornment position="start"><FontAwesomeIcon icon={faAdjust} className={classes.iconDark}></FontAwesomeIcon></InputAdornment></Tooltip> : null;
50 const whenFeature = element.when ? (<Tooltip className={classes.padding} onMouseMove={e => props.toogleTooltip(false)} onMouseOut={e => props.toogleTooltip(true)} title={element.when}>
51 <InputAdornment className={classes.padding} position="end"><FontAwesomeIcon icon={faAdjust} className={classes.iconLight}></FontAwesomeIcon></InputAdornment></Tooltip>) : null;
54 <FormControl error={error} style={style}>
55 <InputLabel htmlFor={id} >{label}</InputLabel>
56 <Input {...otherProps} id={id} endAdornment={<div>{ifFeature}{whenFeature}</div>} />
57 <FormHelperText>{errorText}</FormHelperText>