feat: convert nodule to table
This commit is contained in:
		
							parent
							
								
									7a541cf09a
								
							
						
					
					
						commit
						ec68f09169
					
				@ -1,9 +1,22 @@
 | 
				
			|||||||
import Nodules from '../Models/Nodules'
 | 
					import Nodules from '../Models/Nodules'
 | 
				
			||||||
 | 
					import Tables from '../Models/Tables'
 | 
				
			||||||
 | 
					import FocusTable from '../Models/FocusTable'
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class NoduleistController {
 | 
					class NoduleistController {
 | 
				
			||||||
  constructor() {
 | 
					  constructor() {
 | 
				
			||||||
    this.nodules = new Nodules()
 | 
					    this.nodules = new Nodules()
 | 
				
			||||||
 | 
					    this.tables = new Tables()
 | 
				
			||||||
 | 
					    this.focusTable = new FocusTable()
 | 
				
			||||||
    this.updatedNodulesEvent = new Event('updateNodules')
 | 
					    this.updatedNodulesEvent = new Event('updateNodules')
 | 
				
			||||||
 | 
					    this.updatedTablesEvent = new Event('updateTables')
 | 
				
			||||||
 | 
					    this.setSelectedTableEvent = new Event('setSelectedTable')
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  convertNoduleToTable = id => {
 | 
				
			||||||
 | 
					    const nodule = this.nodules.getNoduleById(id)
 | 
				
			||||||
 | 
					    const table = nodule.asTable()
 | 
				
			||||||
 | 
					    this.tables.addNewTable(table)
 | 
				
			||||||
 | 
					    document.dispatchEvent(this.updatedTablesEvent)
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  deleteNodule = id => {
 | 
					  deleteNodule = id => {
 | 
				
			||||||
@ -11,9 +24,10 @@ class NoduleistController {
 | 
				
			|||||||
    document.dispatchEvent(this.updatedNodulesEvent)
 | 
					    document.dispatchEvent(this.updatedNodulesEvent)
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  logExportById = id => {
 | 
					  selectTableToView = id => {    
 | 
				
			||||||
    const nodule = this.nodules.getNoduleById(id)
 | 
					    const nodule = this.nodules.getNoduleById(id)
 | 
				
			||||||
    console.log(nodule.export())
 | 
					    this.focusTable.table = nodule
 | 
				
			||||||
 | 
					    document.dispatchEvent(this.setSelectedTableEvent)
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
				
			|||||||
@ -31,6 +31,8 @@ class Tables {
 | 
				
			|||||||
  getCollectionProps = () => this.collection.map(table => table.getProperties())
 | 
					  getCollectionProps = () => this.collection.map(table => table.getProperties())
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  getById = id => this.collection.find(t => id === t.id)
 | 
					  getById = id => this.collection.find(t => id === t.id)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  getTableByLabel = label => this.collection.find(t => label === t.label)
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
export default Tables
 | 
					export default Tables
 | 
				
			||||||
 | 
				
			|||||||
@ -25,10 +25,15 @@ class NoduleListItem extends Component {
 | 
				
			|||||||
            Delete <Icon name='trash' />
 | 
					            Delete <Icon name='trash' />
 | 
				
			||||||
          </span>
 | 
					          </span>
 | 
				
			||||||
          <span 
 | 
					          <span 
 | 
				
			||||||
          onClick={() => { this.controller.logExportById(nodule.id) }}
 | 
					          onClick={() => { this.controller.selectTableToView(nodule.id) }}
 | 
				
			||||||
          style={{ cursor: 'pointer' }}>
 | 
					          style={{ cursor: 'pointer' }}>
 | 
				
			||||||
            View <Icon name='table' />
 | 
					            View <Icon name='table' />
 | 
				
			||||||
          </span>
 | 
					          </span>
 | 
				
			||||||
 | 
					          <span 
 | 
				
			||||||
 | 
					          onClick={() => { this.controller.convertNoduleToTable(nodule.id) }}
 | 
				
			||||||
 | 
					          style={{ cursor: 'pointer' }}>
 | 
				
			||||||
 | 
					            To Table <Icon name='clone' />
 | 
				
			||||||
 | 
					          </span>
 | 
				
			||||||
        </Card.Content>
 | 
					        </Card.Content>
 | 
				
			||||||
      </Card>
 | 
					      </Card>
 | 
				
			||||||
    )
 | 
					    )
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user