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=4dc4b28f59925dc82d3b3f2a0ae3d4fcb391c80a;hb=a74726581355bf8dfa748f340e0632993e2328ed;hpb=3313f43da5ff25569f4d4115240bad1b457a05b9 diff --git a/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js b/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js index 4dc4b28f5..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' @@ -39,6 +41,7 @@ import SelectionManager from '../libraries/SelectionManager' import DeletionManager from '../libraries/DeletionManager' import DescriptorModelIconFactory from '../libraries/model/IconFactory' import getEventPath from '../libraries/getEventPath' +import CatalogDataStore from '../stores/CatalogDataStore' import imgAdd from '../../../node_modules/open-iconic/svg/plus.svg' import imgRemove from '../../../node_modules/open-iconic/svg/trash.svg' @@ -46,12 +49,12 @@ import imgRemove from '../../../node_modules/open-iconic/svg/trash.svg' import '../styles/EditDescriptorModelProperties.scss' function getDescriptorMetaBasicForType(type) { - const basicPropertiesFilter = d => _.contains(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 => !_.contains(DESCRIPTOR_MODEL_FIELDS[type], d.name); + const advPropertiesFilter = d => !_includes(DESCRIPTOR_MODEL_FIELDS[type], d.name); return DescriptorModelMetaFactory.getModelMetaForType(type, advPropertiesFilter) || {properties: []}; } @@ -172,17 +175,21 @@ 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); const onChange = onFormFieldValueChanged.bind(container); const isEnumeration = Property.isEnumeration(property); + const isLeafRef = Property.isLeafRef(property); 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) => { @@ -190,36 +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 fullPathString = container.key + ':' + path.join(':'); + let containerRef = container; + while (containerRef.parent) { + fullPathString = containerRef.parent.key + ':' + fullPathString; + containerRef = containerRef.parent; + } + const leafRefPathValues = Property.getLeafRef(property, path, value, fullPathString, catalogs, container); + + const options = leafRefPathValues && leafRefPathValues.map((d, i) => { + return ; + }); + const isValueSet = leafRefPathValues.filter(d => d.isSelected).length > 0; + if (!isValueSet || property.cardinality === '0..1') { + const noValueDisplayText = changeCase.title(property.name); + options.unshift(); + } + return ( + + ); + } + + if (isBoolean) { + const options = [ + , + + ] + + // if (!isValueSet) { + const noValueDisplayText = changeCase.title(property.name); + options.unshift(); + // } + let val = value; + if(typeof(val) == 'number') { + val = value ? "TRUE" : "FALSE" + } + const isValueSet = (val != '' && val) + return ( + + ); } if (property['preserve-line-breaks']) { - return