From 29514c02f25947b35b0827093f2bb915b78d750c Mon Sep 17 00:00:00 2001 From: pkupczyk <piotr.kupczyk@id.ethz.ch> Date: Sun, 19 May 2019 15:05:23 +0200 Subject: [PATCH] SSDM-7569 NEW openBIS UI - General Template/Infrastructure for Forms - Visualisation/Creation/Edit - fix validation + properly handle propertyType == null case --- .../components/types/objectType/ObjectType.jsx | 2 +- .../types/objectType/ObjectTypePropertyRow.jsx | 17 ++++++++++------- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/openbis_ng_ui/src/components/types/objectType/ObjectType.jsx b/openbis_ng_ui/src/components/types/objectType/ObjectType.jsx index 1c2def49803..edafa1d119e 100644 --- a/openbis_ng_ui/src/components/types/objectType/ObjectType.jsx +++ b/openbis_ng_ui/src/components/types/objectType/ObjectType.jsx @@ -212,7 +212,7 @@ class ObjectType extends React.Component { let newProperties = this.state.objectType.properties.map(property => { let errors = {} - if(!_.trim(property.type)){ + if(!property.propertyType){ errors['propertyType'] = 'Cannot be empty' } diff --git a/openbis_ng_ui/src/components/types/objectType/ObjectTypePropertyRow.jsx b/openbis_ng_ui/src/components/types/objectType/ObjectTypePropertyRow.jsx index a2e582d2ec1..d1ce770022a 100644 --- a/openbis_ng_ui/src/components/types/objectType/ObjectTypePropertyRow.jsx +++ b/openbis_ng_ui/src/components/types/objectType/ObjectTypePropertyRow.jsx @@ -132,13 +132,16 @@ class ObjectTypeTableRow extends React.Component { renderPreview(){ const {property, propertyTypes} = this.props - const propertyType = _.find(propertyTypes, propertyType => { - return propertyType.code === property.propertyType.code - }) - - return ( - <ObjectTypePropertyPreview property={property} propertyType={propertyType} /> - ) + if(property.propertyType){ + const propertyType = _.find(propertyTypes, propertyType => { + return propertyType.code === property.propertyType.code + }) + return ( + <ObjectTypePropertyPreview property={property} propertyType={propertyType} /> + ) + }else{ + return (<div></div>) + } } renderPropertyType(){ -- GitLab