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=0e1746dda78f4af8ecf757e55d0cbe8b8b35e0f0;hp=41e87b3bced4ef2d63c3a3e7390550fc954a25ae;hb=bc5076404f6dfea979b370f29b1db2e0a1505349;hpb=bd0ec3d0d995e2846800297475272def540e18d4 diff --git a/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js b/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js index 41e87b3bc..0e1746dda 100644 --- a/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js +++ b/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js @@ -25,6 +25,10 @@ import _includes from 'lodash/includes' import _isArray from 'lodash/isArray' import _cloneDeep from 'lodash/cloneDeep' import _debounce from 'lodash/debounce'; +import _uniqueId from 'lodash/uniqueId'; +import _set from 'lodash/set'; +import _get from 'lodash/get'; +import _has from 'lodash/has'; import utils from '../libraries/utils' import React from 'react' import ClassNames from 'classnames' @@ -48,6 +52,16 @@ import imgRemove from '../../../node_modules/open-iconic/svg/trash.svg' import '../styles/EditDescriptorModelProperties.scss' +const EMPTY_LEAF_PRESENT = '--empty-leaf-set--'; + +function resolveReactKey(value) { + const keyPath = ['uiState', 'fieldKey']; + if (!_has(value, keyPath)) { + _set(value, keyPath, _uniqueId()); + } + return _get(value, keyPath); +} + function getDescriptorMetaBasicForType(type) { const basicPropertiesFilter = d => _includes(DESCRIPTOR_MODEL_FIELDS[type], d.name); return DescriptorModelMetaFactory.getModelMetaForType(type, basicPropertiesFilter) || {properties: []}; @@ -292,7 +306,37 @@ export default function EditDescriptorModelProperties(props) { key={fieldKey} id={fieldKey} className={ClassNames({'-value-not-set': !isValueSet})} - defaultValue={val && val.toUpperCase()} title={pathToProperty} + defaultValue={val && val.toUpperCase()} + title={pathToProperty} + onChange={onSelectChange} + onFocus={onFocus} + onBlur={endEditing} + onMouseDown={startEditing} + onMouseOver={startEditing} + readOnly={!isEditable}> + {options} + + ); + } + + if (Property.isLeafEmpty(property)) { + // A null value indicates the leaf exists (as opposed to undefined). + // We stick in a string when the user actually sets it to simplify things + // but the correct thing happens when we serialize to user data + let isEmptyLeafPresent = (value === EMPTY_LEAF_PRESENT || value === null); + let present = isEmptyLeafPresent ? EMPTY_LEAF_PRESENT : ""; + const options = [ + , + + ] + + return ( +