ModulesList.js 1.5 KB

123456
  1. import React from'react';import ParameterControl from'./ParameterControl';import ExtendableContainer from'../../base/ExtendableContainer';import Logger from'../../../systems/Logger';import Module from'../../Module';Object.defineProperty(Object.prototype,'makeArray',{enumerable:!1,value:a=>{let b=[];for(var c in a)b.push(a[c]);return b}});//import './ModulesList.css';
  2. class ModulesList extends Module{constructor(a){super(a),this.state={modules:[]}}componentWillReceiveProps(){this.refresh()}componentDidMount(){super.componentDidMount(),this.refresh()}parseModules(a){let b=a.map(a=>a.Category+'/'+a.name),c={Unordered:[]};return b.forEach(a=>{let b=a.split('/'),d=c;for(let c=0;c<b.length-1;c++)d[b[c]]||(d[b[c]]={}),d=d[b[c]];d.items||(d.items=[]),d.items.push(b[b.length-1])}),console.log('ModuleStructure: ',c),c}makeFolder(a){let b=[];for(var c in a){if('items'==c){for(var d in a[c])console.log(a[c][d]),b.push(React.createElement(ParameterControl,{className:this.props.controlClassName,module:this.props.list[a[c][d]],name:d,key:d}));continue}b.push(React.createElement(ExtendableContainer,{header:c,key:c,className:this.props.className},this.makeFolder(a[c])))}return b}refresh(){let a=Object.makeArray(this.props.list)||[],b=this.parseModules(a);console.log(b);let c=this.makeFolder(b);// let folders = Object.keys(modules).reduce((a,b) => {
  3. // a[modules[b].Category] = [...(a[modules[b].Category] || []), modules[b]];
  4. // return a;
  5. // }, {});
  6. this.setState({modules:c,folders:[]})}render(){return this.state.modules}}export default ModulesList;