From: KIRAN KASHALKAR Date: Tue, 27 Dec 2016 02:16:09 +0000 (-0500) Subject: RIFT-14803: UI Composer: References should be dropdowns https://osm.etsi.org/gerrit... X-Git-Tag: v1.1.0~29 X-Git-Url: https://osm.etsi.org/gitweb/?a=commitdiff_plain;h=refs%2Fchanges%2F42%2F842%2F1;p=osm%2FUI.git RIFT-14803: UI Composer: References should be dropdowns https://osm.etsi.org/gerrit/#/c/606/ Signed-off-by: KIRAN KASHALKAR --- diff --git a/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js b/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js index 4dc4b28f5..7965e25a7 100644 --- a/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js +++ b/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js @@ -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' @@ -173,12 +174,15 @@ 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 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}); @@ -200,6 +204,26 @@ export default function EditDescriptorModelProperties(props) { return ; } + if (isLeafRef) { + let fullFieldKey = 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 (property['preserve-line-breaks']) { return