X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FUI.git;a=blobdiff_plain;f=skyquake%2Fplugins%2Fcomposer%2Fsrc%2Fsrc%2Fcomponents%2Fmodel%2FPropertyCrumb.jsx;fp=skyquake%2Fplugins%2Fcomposer%2Fsrc%2Fsrc%2Fcomponents%2Fmodel%2FPropertyCrumb.jsx;h=7e6cdad56827a4359e447ffd65ee79112d45e712;hp=0000000000000000000000000000000000000000;hb=03156e335275de1dafbc2a816e98006afdf249bf;hpb=f2dc2462571800e62cba969964de621dca09299c diff --git a/skyquake/plugins/composer/src/src/components/model/PropertyCrumb.jsx b/skyquake/plugins/composer/src/src/components/model/PropertyCrumb.jsx new file mode 100644 index 000000000..7e6cdad56 --- /dev/null +++ b/skyquake/plugins/composer/src/src/components/model/PropertyCrumb.jsx @@ -0,0 +1,76 @@ +/* + * + * Copyright 2016-2017 RIFT.IO Inc + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +import React from 'react' +import _keys from 'lodash/keys' +import _isObject from 'lodash/isObject' +import DescriptorEditorActions from '../../actions/DescriptorEditorActions' +import SelectionManager from '../../libraries/SelectionManager' + +import '../../styles/EditDescriptorModelProperties.scss' + +function makeId(container, path) { + let idParts = [path]; + idParts.push(container.uid); + while (container.parent) { + container = container.parent; + idParts.push(container.uid); + } + return idParts.reverse().join(':'); +} + +export default function PropertyCrumb(props) { + const { container, errors } = props; + const errorPaths = _keys(errors).reduce((a, k) => { + function pieceOfPath(obj, key) { + if (_isObject(obj[key])) { + const node = obj[key]; + return _keys(node).reduce((a,k) => { + const paths = pieceOfPath(node, k).map(e => key + '.' + e) + return a.concat(paths); + }, []); + } else { + return obj[key] ? [key] : []; + } + } + const paths = pieceOfPath(errors, k); + return a.concat(paths); + }, []); + + function onClickSelectItem(path, event) { + event.preventDefault(); + // DescriptorEditorActions.setFocus({descriptor: container, path}) + const element = document.getElementById(makeId(container, path)); + element && element.scrollIntoView() && setTimeout(() => element.focus(), 1); + + // const root = node.getRoot(); + // if (SelectionManager.select(node)) { + // DescriptorEditorActions.catalogItemMetaDataChanged(root.model); + // } + } + const crumbs = errorPaths.map((path, i) => + + {path} + + ); + return ( +
+

{crumbs}

+
+ ); +}