import React, { Component } from 'react' import { Card, Icon, CardContent } from 'semantic-ui-react' import './NoduleList.css' import Nodule from '../../Collections/Nodules' import NoduleListController from '../../Controllers/NoduleListController' class NoduleList extends Component { constructor () { super() this.nodules = new Nodule() this.controller = new NoduleListController() this.state = { nodules: this.nodules.getCollectionProps() } document.addEventListener('updateNodules', this.updateNoduleList) } updateNoduleList = () => { this.setState({nodules: this.nodules.getCollectionProps()}) } renderTableListElements = () => { const { nodules } = this.state const noduleListElements = nodules.map(n => { n.label } {`${n.tables.length} tables`} { this.controller.deleteNodule(n.id) }} style={{ cursor: 'pointer' }} > Delete ) return noduleListElements } render = () => { return (
{ this.renderTableListElements() }
) } } export default NoduleList