From c3f34198b3900b5c51f5ab0a6aaf9dc5045bd862 Mon Sep 17 00:00:00 2001 From: alaskowski <alaskowski@ethz.ch> Date: Tue, 21 May 2024 16:23:51 +0200 Subject: [PATCH] BIS-769: Changed the order of pattern and patternType. Added info boxes for pattern input --- ui-admin/src/js/common/messages.js | 6 ++++ .../EntityTypeFormParametersProperty.jsx | 35 ++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/ui-admin/src/js/common/messages.js b/ui-admin/src/js/common/messages.js index 3dbdd2c8f41..7f0893526d1 100644 --- a/ui-admin/src/js/common/messages.js +++ b/ui-admin/src/js/common/messages.js @@ -233,6 +233,9 @@ const keys = { PROPERTY_IS_USED: 'PROPERTY_IS_USED', PROPERTY_PARAMETERS_CANNOT_BE_CHANGED: 'PROPERTY_PARAMETERS_CANNOT_BE_CHANGED', PROPERTY_TYPES: 'PROPERTY_TYPES', + PROPERTY_TYPE_VALIDATION_PATTERN: 'PROPERTY_TYPE_VALIDATION_PATTERN', + PROPERTY_TYPE_VALIDATION_VALUES: 'PROPERTY_TYPE_VALIDATION_VALUES', + PROPERTY_TYPE_VALIDATION_RANGES: 'PROPERTY_TYPE_VALIDATION_RANGES', PUBLIC: 'PUBLIC', QUERIES: 'QUERIES', QUERY: 'QUERY', @@ -582,6 +585,9 @@ const messages_en = { [keys.PROPERTY_IS_USED]: 'This property assignment is already used by existing entities of "${0}" type. Removing it is also going to remove ${1} existing property value(s) - data will be lost! Are you sure you want to proceed?', [keys.PROPERTY_PARAMETERS_CANNOT_BE_CHANGED]: 'The property parameters cannot be changed.', [keys.PROPERTY_TYPES]: 'Property Types', + [keys.PROPERTY_TYPE_VALIDATION_PATTERN]: 'Regular expression like: [a-z]{3}\\d', + [keys.PROPERTY_TYPE_VALIDATION_VALUES]: 'comma-separated, quoted strings like: "a", "b", "c"', + [keys.PROPERTY_TYPE_VALIDATION_RANGES]: 'comma-separated ranges of integer values. Range is defined by 2 integers separated by "-" sign:\n 1-5, 10-100, (-5)-(-3)', [keys.PUBLIC]: 'Public', [keys.QUERIES]: 'Queries', [keys.QUERY]: 'Query', diff --git a/ui-admin/src/js/components/types/form/entitytype/EntityTypeFormParametersProperty.jsx b/ui-admin/src/js/components/types/form/entitytype/EntityTypeFormParametersProperty.jsx index 0270361329f..d1c4edf0336 100644 --- a/ui-admin/src/js/components/types/form/entitytype/EntityTypeFormParametersProperty.jsx +++ b/ui-admin/src/js/components/types/form/entitytype/EntityTypeFormParametersProperty.jsx @@ -119,8 +119,9 @@ class EntityTypeFormParametersProperty extends React.PureComponent { {this.renderLabel(property)} {this.renderDescription(property)} {this.renderDynamicPlugin(property)} - {this.renderPattern(property)} {this.renderPatternType(property)} + {this.renderPattern(property)} + {this.renderPatternInfoBox(property)} {this.renderInternal(property)} {this.renderVisible(property)} {this.renderMandatory(property)} @@ -784,6 +785,38 @@ class EntityTypeFormParametersProperty extends React.PureComponent { ) } + renderPatternInfoBox(property) { + const { visible, enabled, error, value } = { ...property.patternType } + + if(!visible || value == 'NONE' || !value) { + return null; + } + + const { mode, classes } = this.props + if(mode != 'edit') { + return null; + } + console.log(this.props); + let message = ""; + if(value == 'PATTERN') { + message = messages.get(messages.PROPERTY_TYPE_VALIDATION_PATTERN) + } else if(value == 'VALUES') { + message = messages.get(messages.PROPERTY_TYPE_VALIDATION_VALUES) + } else if(value == 'RANGES') { + message = messages.get(messages.PROPERTY_TYPE_VALIDATION_RANGES) + } else { + return null; + } + return ( + <div className={classes.field}> + <Message type='info'> + {message} + </Message> + </div> + ) + + } + renderPatternType(property) { const { visible, enabled, error, value } = { ...property.patternType } -- GitLab