-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DOJOT-74] - add info tooltips and attribute label validation to temp…
…late creation (#204) * add info tooltips and attr label validation to template creation * abstract attribute input label to a component * adjust on the translations of attribute type tooltip * removing unused useState
- Loading branch information
1 parent
ac72719
commit 3ef796b
Showing
13 changed files
with
259 additions
and
133 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
MFE/common/src/components/WizardForms/TemplateCreation/AttributeInputLabel.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import React, { useState } from 'react'; | ||
import { TextField } from '@material-ui/core'; | ||
import PropTypes from 'prop-types'; | ||
import { useStyles } from './style'; | ||
|
||
const AttributeInputLabel = ({ className, value, handleUpdateLabel, placeholder, helperText }) => { | ||
const classes = useStyles(); | ||
const reAttrLabel = /^[0-9a-zA-Z-_]+$/; | ||
|
||
const [attrLabelError, setAttrLabelError] = useState(false); | ||
|
||
const hanleChangeLabel = newLabel => { | ||
handleUpdateLabel(newLabel); | ||
|
||
if (reAttrLabel.test(newLabel)) { | ||
setAttrLabelError(false); | ||
} else { | ||
setAttrLabelError(true); | ||
} | ||
}; | ||
|
||
return ( | ||
<TextField | ||
className={className} | ||
size='small' | ||
value={value} | ||
variant='outlined' | ||
placeholder={placeholder} | ||
onChange={e => hanleChangeLabel(e.target.value)} | ||
error={attrLabelError} | ||
helperText={attrLabelError ? helperText : null} | ||
FormHelperTextProps={{ | ||
classes: { | ||
error: classes.attrLabelHelperText, | ||
}, | ||
}} | ||
/> | ||
); | ||
}; | ||
|
||
AttributeInputLabel.propTypes = { | ||
className: PropTypes.string.isRequired, | ||
value: PropTypes.string.isRequired, | ||
handleUpdateLabel: PropTypes.func.isRequired, | ||
placeholder: PropTypes.string.isRequired, | ||
helperText: PropTypes.string.isRequired, | ||
}; | ||
|
||
export default AttributeInputLabel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.