- const hasProperties = _.isArray(property.properties) && property.properties.length;
- const isMissingDescriptorMeta = !hasProperties && !Property.isLeaf(property);
-
- // ensure value is not undefined for non-leaf property types
- if (isObject) {
- if (typeof value !== 'object') {
- value = isArray ? [] : {};
- }
- }
- const valueAsArray = _.isArray(value) ? value : isLeafList && typeof value === 'undefined' ? [] : [value];
-
- const isMetaField = property.name === 'meta';
- const isCVNFD = property.name === 'constituent-vnfd';
- const isSimpleListView = Property.isSimpleList(property);
-
- valueAsArray.forEach((value, index) => {
-
- let field;
- const key = fieldKey.slice();
- const valuePath = path.slice();
-
- if (isArray) {
- valuePath.push(index);
- key.push(index);
- }
-
- if (isMetaField) {
- if (typeof value === 'object') {
- value = JSON.stringify(value, undefined, 12);
- } else if (typeof value !== 'string') {
- value = '{}';
- }
- }
-
- if (isMissingDescriptorMeta) {
- field = <span key={key.concat('warning').join(':')} className="warning">No Descriptor Meta for {property.name}</span>;
- } else if (property.type === 'choice') {
- field = buildChoice(container, property, valuePath, value, key.join(':'));
- } else if (isSimpleListView) {
- field = buildSimpleListItem(container, property, valuePath, value, key, index);
- } else if (isLeafList) {
- field = buildLeafListItem(container, property, valuePath, value, key, index);
- } else if (hasProperties) {
- field = buildElement(container, property, valuePath, value, key.join(':'))
- } else {
- field = buildField(container, property, valuePath, value, key.join(':'));
- }
-
- function onClickLeaf(property, path, value, event) {
- if (event.isDefaultPrevented()) {
- return;
- }
- event.preventDefault();
- event.stopPropagation();
- this.getRoot().uiState.focusedPropertyPath = path.join('.');
- console.log('property selected', path.join('.'));
- ComposerAppActions.propertySelected([path.join('.')]);
- }
-
- const clickHandler = isLeaf ? onClickLeaf : () => {};
- const isContainerList = isArray && !(isSimpleListView || isLeafList);
-
- fields.push(
- <div key={fieldKey.concat(['property-content', index]).join(':')}
- className={ClassNames('property-content', {'simple-list': isSimpleListView})}
- onClick={clickHandler.bind(container, property, valuePath, value)}>
- {isContainerList ? buildRemoveListItem(container, property, valuePath, fieldKey, index) : null}
- {field}
- </div>
+ if (property.type === 'leaf') {
+ return buildField(property, path, value, uniqueId);
+ } else if (property.type === 'leaf_list') {
+ return buildLeafList(property, path, value, uniqueId);
+ } else if (property.type === 'list') {
+ return Property.isSimpleList(property) ?
+ buildSimpleList(property, path, value, uniqueId)
+ :
+ buildList(property, path, value, uniqueId);
+ } else if (property.type === 'container') {
+ return buildContainer(property, path, value, uniqueId);
+ } else if (property.type === 'choice') {
+ return buildChoice(property, path, value, uniqueId);
+ } else {
+ return (
+ <span key={fieldId} className="warning">No Descriptor Meta for {property.name}</span>