Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unique validation: added info text #3615

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading