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=4afa3ff59fb9a633ba496e38e6bd1920c5cfd0df;hp=c923ede7f8b7e85278c9fef63fe3d9c45421006c;hb=6fc3e77438cd4e53c5d5f21512ee8ca260469ca8;hpb=4ac4733357decb8be9bc9b1db90b255cfaffc1b7 diff --git a/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js b/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js index c923ede7f..4afa3ff59 100644 --- a/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js +++ b/skyquake/plugins/composer/src/src/components/EditDescriptorModelProperties.js @@ -90,6 +90,8 @@ function getTitle(model = {}) { export default function EditDescriptorModelProperties(props) { const container = props.container; + const readonly = props.readonly; + const isEditable = !readonly; //true if (!(DescriptorModelFactory.isContainer(container))) { return @@ -160,6 +162,9 @@ export default function EditDescriptorModelProperties(props) { } CatalogItemsActions.catalogItemDescriptorChanged(this.getRoot()); } + if(readonly) { + return null; + } return ( ); @@ -177,6 +182,9 @@ export default function EditDescriptorModelProperties(props) { } CatalogItemsActions.catalogItemDescriptorChanged(this.getRoot()); } + if(readonly) { + return null; + } return ( ); @@ -187,7 +195,6 @@ export default function EditDescriptorModelProperties(props) { let catalogs = cds.getTransientCatalogs(); const pathToProperty = path.join('.'); - const isEditable = true; const isGuid = Property.isGuid(property); const isBoolean = Property.isBoolean(property); const isEnumeration = Property.isEnumeration(property); @@ -218,7 +225,7 @@ export default function EditDescriptorModelProperties(props) { processFieldValueChange.bind(container, pathToProperty), 2000, {maxWait: 5000})); // max wait for short-name // create an onChange event handler for a select field for the specified field path const onSelectChange = changeHandler.bind(null, processFieldValueChange.bind(container, pathToProperty)); - + if (isEnumeration) { const enumeration = Property.getEnumeration(property, value); const options = enumeration.map((d, i) => { @@ -234,18 +241,18 @@ export default function EditDescriptorModelProperties(props) { options.unshift({noValueDisplayText}); } return ( - + className={ClassNames({'-value-not-set': !isValueSet})} + defaultValue={value} + title={pathToProperty} + onChange={onSelectChange} + onFocus={onFocus} + onBlur={endEditing} + onMouseDown={startEditing} + onMouseOver={startEditing} + disabled={!isEditable}> {options} ); @@ -269,18 +276,18 @@ export default function EditDescriptorModelProperties(props) { options.unshift({noValueDisplayText}); } return ( - + {options} ); @@ -302,28 +309,28 @@ export default function EditDescriptorModelProperties(props) { } const isValueSet = (val != '' && val) return ( - + {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 isEmptyLeafPresent = (value === EMPTY_LEAF_PRESENT || value === null); let present = isEmptyLeafPresent ? EMPTY_LEAF_PRESENT : ""; const options = [ Enabled, @@ -331,18 +338,18 @@ export default function EditDescriptorModelProperties(props) { ] return ( - + {options} ); @@ -350,25 +357,25 @@ export default function EditDescriptorModelProperties(props) { if (property['preserve-line-breaks']) { return ( - + ); } return ( - ); @@ -454,7 +461,7 @@ export default function EditDescriptorModelProperties(props) { // write the current choice value into the state let choiceObject = utils.resolvePath(this.model, [name, selected].join('.')); let isTopCase = false; - if (!choiceObject) { + if (choiceObject) { isTopCase = true; choiceObject = utils.resolvePath(this.model, [selected].join('.')); } @@ -538,7 +545,7 @@ export default function EditDescriptorModelProperties(props) { selectedOptionValue = utils.resolvePath(container.model, ['uiState.choice', pathToChoice, 'selected'].join('.')); } else { property.properties.map(function(p) { - let pname = p.properties[0].name; + let pname = p.properties[0] && p.properties[0].name; if(container.model.hasOwnProperty(pname)) { utils.assignPathValue(container.model, ['uiState.choice', pathToChoice, 'selected'].join('.'), [p.name, pname].join('.')); } @@ -575,17 +582,18 @@ export default function EditDescriptorModelProperties(props) { return ( - {options} @@ -682,7 +690,7 @@ export default function EditDescriptorModelProperties(props) { let field; const valuePath = path.slice(); // create a unique field Id for use as react component keys and html element ids - // notes: + // notes: // keys only need to be unique on components in the same array // html element ids should be unique with the document (or form) let fieldId = uniqueId; @@ -747,7 +755,7 @@ export default function EditDescriptorModelProperties(props) { value = utils.resolvePath(container.model, ['uiState.choice'].concat(path, 'selected').join('.')); if(!value) { property.properties.map(function(p) { - let pname = p.properties[0].name; + let pname = p.properties[0] && p.properties[0].name; if(container.model.hasOwnProperty(pname)) { value = container.model[pname]; } @@ -843,4 +851,3 @@ export default function EditDescriptorModelProperties(props) { ); }; -