diff --git a/src/components/fields/FunctionSpecField.jsx b/src/components/fields/FunctionSpecField.jsx index 66461ce..d1e30d3 100644 --- a/src/components/fields/FunctionSpecField.jsx +++ b/src/components/fields/FunctionSpecField.jsx @@ -95,8 +95,9 @@ export default class FunctionSpecProperty extends React.Component { static propTypes = { onChange: PropTypes.func.isRequired, fieldName: PropTypes.string.isRequired, + fieldType: PropTypes.string.isRequired, fieldSpec: PropTypes.object.isRequired, - error: PropTypes.object, + errors: PropTypes.object, value: PropTypes.oneOfType([ PropTypes.object, @@ -225,11 +226,12 @@ export default class FunctionSpecProperty extends React.Component { if (this.state.isExpression) { specField = ( }) diff --git a/src/components/fields/_DataProperty.jsx b/src/components/fields/_DataProperty.jsx index be48ddc..d2bbaba 100644 --- a/src/components/fields/_DataProperty.jsx +++ b/src/components/fields/_DataProperty.jsx @@ -48,7 +48,7 @@ export default class DataProperty extends React.Component { PropTypes.bool, PropTypes.array ]), - error: PropTypes.object, + errors: PropTypes.object, } state = { @@ -145,6 +145,8 @@ export default class DataProperty extends React.Component { } render() { + const {fieldName, fieldType, errors} = this.props; + if (typeof this.props.value.type === "undefined") { this.props.value.type = this.getFieldFunctionType(this.props.fieldSpec) } @@ -182,7 +184,22 @@ export default class DataProperty extends React.Component { } - return + const errorKeyStart = `${fieldType}.${fieldName}.stops[${idx}]`; + const foundErrors = Object.entries(errors).filter(([key, error]) => { + return key.startsWith(errorKeyStart); + }); + + const message = foundErrors.map(([key, error]) => { + return error.message; + }).join(""); + const error = message ? {message} : undefined; + + return {zoomInput}
{dataInput} @@ -201,7 +218,6 @@ export default class DataProperty extends React.Component { return
diff --git a/src/components/fields/_ExpressionProperty.jsx b/src/components/fields/_ExpressionProperty.jsx index 675dc3f..8c5ab96 100644 --- a/src/components/fields/_ExpressionProperty.jsx +++ b/src/components/fields/_ExpressionProperty.jsx @@ -17,18 +17,22 @@ export default class ExpressionProperty extends React.Component { fieldName: PropTypes.string, fieldSpec: PropTypes.object, value: PropTypes.any, - error: PropTypes.object, + errors: PropTypes.object, onChange: PropTypes.func, onUndo: PropTypes.func, canUndo: PropTypes.func, } + static defaultProps = { + errors: {}, + } + constructor (props) { super(); } render() { - const {value, canUndo} = this.props; + const {errors, fieldName, fieldType, value, canUndo} = this.props; const undoDisabled = canUndo ? !canUndo() : true; const deleteStopBtn = ( @@ -53,8 +57,10 @@ export default class ExpressionProperty extends React.Component { ); + const error = errors[fieldType+"."+fieldName]; + return + const error = errors[fieldType+"."+fieldName]; + return { const zoomLevel = stop[0] const key = this.state.refs[idx]; const value = stop[1] const deleteStopBtn= + const errorKeyStart = `${fieldType}.${fieldName}.stops[${idx}]`; + const foundErrors = Object.entries(errors).filter(([key, error]) => { + return key.startsWith(errorKeyStart); + }); + + const message = foundErrors.map(([key, error]) => { + return error.message; + }).join(""); + const error = message ? {message} : undefined; + return