feat: convert nodule to table
This commit is contained in:
		
							parent
							
								
									021f3c7e4b
								
							
						
					
					
						commit
						c82bac9058
					
				@ -1,9 +1,22 @@
 | 
			
		||||
import Nodules from '../Models/Nodules'
 | 
			
		||||
import Tables from '../Models/Tables'
 | 
			
		||||
import FocusTable from '../Models/FocusTable'
 | 
			
		||||
 | 
			
		||||
class NoduleistController {
 | 
			
		||||
  constructor() {
 | 
			
		||||
    this.nodules = new Nodules()
 | 
			
		||||
    this.tables = new Tables()
 | 
			
		||||
    this.focusTable = new FocusTable()
 | 
			
		||||
    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 => {
 | 
			
		||||
@ -11,9 +24,10 @@ class NoduleistController {
 | 
			
		||||
    document.dispatchEvent(this.updatedNodulesEvent)
 | 
			
		||||
  }
 | 
			
		||||
 | 
			
		||||
  logExportById = id => {
 | 
			
		||||
  selectTableToView = 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())
 | 
			
		||||
 | 
			
		||||
  getById = id => this.collection.find(t => id === t.id)
 | 
			
		||||
 | 
			
		||||
  getTableByLabel = label => this.collection.find(t => label === t.label)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
export default Tables
 | 
			
		||||
 | 
			
		||||
@ -25,10 +25,15 @@ class NoduleListItem extends Component {
 | 
			
		||||
            Delete <Icon name='trash' />
 | 
			
		||||
          </span>
 | 
			
		||||
          <span 
 | 
			
		||||
          onClick={() => { this.controller.logExportById(nodule.id) }}
 | 
			
		||||
          onClick={() => { this.controller.selectTableToView(nodule.id) }}
 | 
			
		||||
          style={{ cursor: 'pointer' }}>
 | 
			
		||||
            View <Icon name='table' />
 | 
			
		||||
          </span>
 | 
			
		||||
          <span 
 | 
			
		||||
          onClick={() => { this.controller.convertNoduleToTable(nodule.id) }}
 | 
			
		||||
          style={{ cursor: 'pointer' }}>
 | 
			
		||||
            To Table <Icon name='clone' />
 | 
			
		||||
          </span>
 | 
			
		||||
        </Card.Content>
 | 
			
		||||
      </Card>
 | 
			
		||||
    )
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user