X-Git-Url: https://osm.etsi.org/gitweb/?p=osm%2FUI.git;a=blobdiff_plain;f=skyquake%2Fplugins%2Fadmin%2Fsrc%2Fcomponents%2FContainerColumn.jsx;fp=skyquake%2Fplugins%2Fadmin%2Fsrc%2Fcomponents%2FContainerColumn.jsx;h=99abb784936a1b8a26769afb1c4d9b2cf6ce393f;hp=0000000000000000000000000000000000000000;hb=03156e335275de1dafbc2a816e98006afdf249bf;hpb=f2dc2462571800e62cba969964de621dca09299c diff --git a/skyquake/plugins/admin/src/components/ContainerColumn.jsx b/skyquake/plugins/admin/src/components/ContainerColumn.jsx new file mode 100644 index 000000000..99abb7849 --- /dev/null +++ b/skyquake/plugins/admin/src/components/ContainerColumn.jsx @@ -0,0 +1,63 @@ +import React from 'react' +import LeafGroup from './LeafGroup' +import ListStack from './ListStack' +import ExplorerColumn from './ExplorerColumn' +import yang from '../yang/leaf-utils' + +export default class extends React.Component { + constructor(props){ + super(props); + this.state = {actions: [], properties: null}; + } + + render() { + try { + const { model, path, isLast, selected, isReadonly, openElement, editElement, columnCloser } = this.props; + const element = model.getElement(path) + const name = element.name; + console.debug(`ContainerColumn: ${name}`); + const data = element.value; + const leaves = []; + const choices = []; + const containers = []; + const lists = []; + const loading = []; + const dataDivided = { + leaf: leaves, + leaf_list: leaves, + container: containers, + list: lists, + choice: choices, + loading: loading + }; + const properties = this.state.properties || element.schema.properties; + properties.forEach((property, index) => { + const list = dataDivided[property.type] + list && list.push(property) + !list && console.debug(`ContainerColumn - unhandled property : ${path}/${property.name} - ${property.type}`) + }); + choices.forEach(choice => choice.properties.forEach(c => c.properties.forEach(p => leaves.push(p)))); + const items = []; + leaves.length && items.push(); + containers.length && items.push(); + lists.length && items.push(); + loading.length && items.push(); + const actions = this.state.actions.slice(); + !isLast || isReadonly || !leaves.length || leaves.every(p => yang.isKey(p)) || actions.push('update'); + function invokeAction(action) { + editElement(path, action); + } + return ( + +
+
+ {items} +
+
+
+ ) + } catch (e) { + console.error("component render", e); + } + } +}