From 7c0d1adb5981f247ae7c19e0ab0a000a607de191 Mon Sep 17 00:00:00 2001 From: Bob Gallagher Date: Tue, 18 Apr 2017 14:45:46 -0400 Subject: [PATCH] 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 --- .../EditDescriptorModelProperties.js | 34 ++- .../model/DescriptorModelMetaFactory.js | 204 +++++++++++++-- .../model/DescriptorModelMetaProperty.js | 5 +- .../model/DescriptorModelSerializer.js | 238 ++---------------- 4 files changed, 236 insertions(+), 245 deletions(-) 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 ( +