From: Bob Gallagher Date: Tue, 18 Apr 2017 18:45:46 +0000 (-0400) Subject: Added support to Composer to support a model leaf of type empty. X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F85%2F1585%2F1;p=osm%2FUI.git Added support to Composer to support a model leaf of type empty. - complete rewrite the the serialization code - the new architecture should allow for more easily adding in validation and default value support - properties are now written out in the order defined by the meta data (it could matter is some definitions) - changed from using utils.resolvePath to use the lodash version - did much manual testing and did test comparison of ping-vnfd sample with new generation Change-Id: Ibd2bbdbdaa436b95ed19016f94425bfab4f85d8e Signed-off-by: Bob Gallagher --- diff --git a/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js b/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js index 41e87b3bc..c1d65be01 100644 --- a/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js +++ b/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js @@ -48,6 +48,8 @@ import imgRemove from '../../../node_modules/open-iconic/svg/trash.svg' import '../styles/EditDescriptorModelProperties.scss' +const EMPTY_LEAF_PRESENT = '--empty-leaf-set--'; + function getDescriptorMetaBasicForType(type) { const basicPropertiesFilter = d => _includes(DESCRIPTOR_MODEL_FIELDS[type], d.name); return DescriptorModelMetaFactory.getModelMetaForType(type, basicPropertiesFilter) || {properties: []}; @@ -292,7 +294,37 @@ export default function EditDescriptorModelProperties(props) { key={fieldKey} id={fieldKey} className={ClassNames({'-value-not-set': !isValueSet})} - defaultValue={val && val.toUpperCase()} title={pathToProperty} + defaultValue={val && val.toUpperCase()} + title={pathToProperty} + onChange={onSelectChange} + onFocus={onFocus} + onBlur={endEditing} + onMouseDown={startEditing} + onMouseOver={startEditing} + readOnly={!isEditable}> + {options} + + ); + } + + if (Property.isLeafEmpty(property)) { + // A null value indicates the leaf exists (as opposed to undefined). + // We stick in a string when the user actually sets it to simplify things + // but the correct thing happens when we serialize to user data + let isEmptyLeafPresent = (value === EMPTY_LEAF_PRESENT || value === null); + let present = isEmptyLeafPresent ? EMPTY_LEAF_PRESENT : ""; + const options = [ + , + + ] + + return ( +