Skip to content

Commit

Permalink
Unique validation: added info text
Browse files Browse the repository at this point in the history
  • Loading branch information
SteRiccio committed Oct 23, 2024
1 parent b72a04d commit ee27a2a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
8 changes: 8 additions & 0 deletions core/i18n/resources/en/common.js
Original file line number Diff line number Diff line change
Expand Up @@ -1378,6 +1378,14 @@ E.g. this.region = region_attribute_name
nodeDefintionsHaveErrors: 'These node definitions have errors: {{nodeDefNames}}. Please fix them.',
filterVariable: 'Variable to filter items',
filterVariableForLevel: 'Variable for {{levelName}}',
unique: {
label: 'Unique',
info: `When an attribute is marked as **Unique**, its value must be unique inside the closest multiple entity (an error will be shown otherwise).
---
E.g. in a structure like *cluster -> plot -> tree*, if you have an attribute *tree_species* marked as **Unique**, you can have only one tree per species inside the same *plot*.`,
},
},

languagesEditor: {
Expand Down
4 changes: 3 additions & 1 deletion webapp/components/form/Input/FormItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export const FormItem = (props) => {
children,
className = '',
info = null,
isInfoMarkdown = false,
label: labelProp = null,
labelParams = null,
onInfoClick = null,
Expand All @@ -28,7 +29,7 @@ export const FormItem = (props) => {
<div className="form-label-wrapper">
{label}
{required ? ' *' : ''}
{info && <ButtonIconInfo onClick={onInfoClick} title={info} />}
{info && <ButtonIconInfo onClick={onInfoClick} title={info} isTitleMarkdown={isInfoMarkdown} />}
</div>
</div>
{children}
Expand All @@ -40,6 +41,7 @@ FormItem.propTypes = {
className: PropTypes.string,
children: PropTypes.oneOfType([PropTypes.string, PropTypes.element, PropTypes.arrayOf(PropTypes.element)]).isRequired,
info: PropTypes.string,
isInfoMarkdown: PropTypes.bool,
label: PropTypes.oneOfType([PropTypes.string, PropTypes.element]),
labelParams: PropTypes.object,
onInfoClick: PropTypes.func,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ const ValidationsProps = (props) => {
{NodeDef.isAttribute(nodeDef) &&
!NodeDef.isKey(nodeDef) &&
(NodeDef.isRoot(nodeDefParent) || NodeDef.isMultiple(nodeDefParent) || NodeDef.isMultiple(nodeDef)) && (
<FormItem label="common.unique">
<FormItem isInfoMarkdown info="nodeDefEdit.unique.info" label="nodeDefEdit.unique.label">
<Checkbox
id={TestId.nodeDefDetails.nodeDefUnique}
checked={NodeDefValidations.isUnique(nodeDefValidations)}
Expand Down

0 comments on commit ee27a2a

Please sign in to comment.