X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FUI.git;a=blobdiff_plain;f=skyquake%2Fplugins%2Fcomposer%2Fsrc%2Fsrc%2Fcomponents%2FEditDescriptorModelProperties.js;h=f3b2c7a73ae400e5f2ea004a0f478d748f768397;hp=a69f3bba2d4cc0a0fbaaaa5191238725321a5216;hb=a8c8851009713670f5c8ecc9b4b011fe43413650;hpb=756a58911e5ab70e42b7793ffef9807738d2f5e1 diff --git a/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js b/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js index a69f3bba2..f3b2c7a73 100644 --- a/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js +++ b/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js @@ -22,7 +22,9 @@ */ 'use strict'; -import _ from 'lodash' +import _includes from 'lodash/includes' +import _isArray from 'lodash/isArray' +import _cloneDeep from 'lodash/cloneDeep' import utils from '../libraries/utils' import React from 'react' import ClassNames from 'classnames' @@ -47,12 +49,12 @@ import imgRemove from '../../../node_modules/open-iconic/svg/trash.svg' import '../styles/EditDescriptorModelProperties.scss' function getDescriptorMetaBasicForType(type) { - const basicPropertiesFilter = d => _.includes(DESCRIPTOR_MODEL_FIELDS[type], d.name); + const basicPropertiesFilter = d => _includes(DESCRIPTOR_MODEL_FIELDS[type], d.name); return DescriptorModelMetaFactory.getModelMetaForType(type, basicPropertiesFilter) || {properties: []}; } function getDescriptorMetaAdvancedForType(type) { - const advPropertiesFilter = d => !_.includes(DESCRIPTOR_MODEL_FIELDS[type], d.name); + const advPropertiesFilter = d => !_includes(DESCRIPTOR_MODEL_FIELDS[type], d.name); return DescriptorModelMetaFactory.getModelMetaForType(type, advPropertiesFilter) || {properties: []}; } @@ -173,11 +175,11 @@ export default function EditDescriptorModelProperties(props) { } } - function buildField(container, property, path, value, fieldKey) { + function buildField(container, property, path, value, fieldId) { let cds = CatalogDataStore; let catalogs = cds.getTransientCatalogs(); - const name = path.join('.'); + const pathToProperty = path.join('.'); const isEditable = true; const isGuid = Property.isGuid(property); const isBoolean = Property.isBoolean(property); @@ -187,7 +189,7 @@ export default function EditDescriptorModelProperties(props) { const onFocus = onFocusPropertyFormInputElement.bind(container, property, path, value); const placeholder = changeCase.title(property.name); const className = ClassNames(property.name + '-input', {'-is-guid': isGuid}); - const fieldValue = value ? (value.constructor.name != "Object") ? value : '' : undefined; + const fieldValue = value ? (value.constructor.name != "Object") ? value : '' : (isNaN(value) ? undefined : value); if (isEnumeration) { const enumeration = Property.getEnumeration(property, value); const options = enumeration.map((d, i) => { @@ -195,81 +197,139 @@ export default function EditDescriptorModelProperties(props) { // so we categorically ignore them // https://trello.com/c/uzEwVx6W/230-bug-enum-should-not-use-index-only-name //return ; - return ; + return ; }); const isValueSet = enumeration.filter(d => d.isSelected).length > 0; if (!isValueSet || property.cardinality === '0..1') { const noValueDisplayText = changeCase.title(property.name); - options.unshift(); + options.unshift(); } - return ; + return ( + + ); } if (isLeafRef) { - let fullFieldKey = _.isArray(fieldKey) ? fieldKey.join(':') : fieldKey; + let fullPathString = container.key + ':' + path.join(':'); let containerRef = container; while (containerRef.parent) { - fullFieldKey = containerRef.parent.key + ':' + fullFieldKey; + fullPathString = containerRef.parent.key + ':' + fullPathString; containerRef = containerRef.parent; } - const leafRefPathValues = Property.getLeafRef(property, path, value, fullFieldKey, catalogs, container); + const leafRefPathValues = Property.getLeafRef(property, path, value, fullPathString, catalogs, container); const options = leafRefPathValues && leafRefPathValues.map((d, i) => { - return ; + return ; }); const isValueSet = leafRefPathValues.filter(d => d.isSelected).length > 0; if (!isValueSet || property.cardinality === '0..1') { const noValueDisplayText = changeCase.title(property.name); - options.unshift(); + options.unshift(); } - return ; + return ( + + ); } if (isBoolean) { - let fullFieldKey = _.isArray(fieldKey) ? fieldKey.join(':') : fieldKey; - let containerRef = container; - while (containerRef.parent) { - fullFieldKey = containerRef.parent.key + ':' + fullFieldKey; - containerRef = containerRef.parent; - } - const options = [ - , - + , + ] // if (!isValueSet) { const noValueDisplayText = changeCase.title(property.name); - options.unshift(); + options.unshift(); // } let val = value; if(typeof(val) == 'number') { val = value ? "TRUE" : "FALSE" } const isValueSet = (val != '' && val) - return ; + return ( + + ); } if (property['preserve-line-breaks']) { - return