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=b3d8afb2bd5003cee44d154dec373365c625fa9f;hp=36e74454824a8a93ba1208f86aede716ca41dd35;hb=7f333680f9c58eed089b17e206528f2e21e2e017;hpb=e29efc315df33d546237e270470916e26df391d6 diff --git a/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js b/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js index 36e744548..b3d8afb2b 100644 --- a/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js +++ b/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js @@ -1,5 +1,5 @@ /* - * + * * Copyright 2016 RIFT.IO Inc * * Licensed under the Apache License, Version 2.0 (the "License"); @@ -39,6 +39,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 +47,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: []}; } @@ -173,15 +174,20 @@ export default function EditDescriptorModelProperties(props) { } function buildField(container, property, path, value, fieldKey) { + let cds = CatalogDataStore; + let catalogs = cds.getTransientCatalogs(); const name = 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 : '' : (isNaN(value) ? undefined : value); if (isEnumeration) { const enumeration = Property.getEnumeration(property, value); const options = enumeration.map((d, i) => { @@ -199,6 +205,51 @@ export default function EditDescriptorModelProperties(props) { return ; } + if (isLeafRef) { + let fullFieldKey = _.isArray(fieldKey) ? fieldKey.join(':') : fieldKey; + let containerRef = container; + while (containerRef.parent) { + fullFieldKey = containerRef.parent.key + ':' + fullFieldKey; + containerRef = containerRef.parent; + } + const leafRefPathValues = Property.getLeafRef(property, path, value, fullFieldKey, 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) { + 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(); + // } + let val = value; + if(typeof(val) == 'number') { + val = value ? "TRUE" : "FALSE" + } + const isValueSet = (val != '' && val) + return ; + } + if (property['preserve-line-breaks']) { return