diff --git a/openbis_ng_ui/src/js/components/types/objectType/ObjectTypeHandlerSave.js b/openbis_ng_ui/src/js/components/types/objectType/ObjectTypeHandlerSave.js index b302d6e375526833db221940fb3d445101821451..5029a4befd37217fdb6f6f6417282d46dd3c02f4 100644 --- a/openbis_ng_ui/src/js/components/types/objectType/ObjectTypeHandlerSave.js +++ b/openbis_ng_ui/src/js/components/types/objectType/ObjectTypeHandlerSave.js @@ -1,3 +1,4 @@ +import _ from 'lodash' import { dto } from '../../../services/openbis.js' export default class ObjectTypeHandlerSave { @@ -14,6 +15,16 @@ export default class ObjectTypeHandlerSave { this.validateHandler = validateHandler } + prepareValue(value) { + if (value) { + if (_.isString(value)) { + const trimmedValue = value.trim() + return trimmedValue.length > 0 ? trimmedValue : null + } + } + return value + } + prepareType(type) { let code = type.code @@ -21,10 +32,15 @@ export default class ObjectTypeHandlerSave { code = code.toUpperCase() } - return { - ...type, - code - } + const newType = _.mapValues( + { + ...type, + code + }, + this.prepareValue + ) + + return newType } prepareProperties(type, properties, sections) { @@ -49,11 +65,16 @@ export default class ObjectTypeHandlerSave { } } - results.push({ - ...property, - code, - section: section.name - }) + const newProperty = _.mapValues( + { + ...property, + code, + section: section.name + }, + this.prepareValue + ) + + results.push(newProperty) }) })