fix: actually adding join nodule

This commit is contained in:
ysandler 2020-07-20 22:41:39 -05:00 committed by Joshua Shoemaker
parent 68a8211971
commit f57b7dcf18
3 changed files with 22 additions and 8 deletions

View File

@ -24,7 +24,7 @@ class CreateNoduleController {
} }
addNewJoinNodule = props => { addNewJoinNodule = props => {
const { label, tablesToImportByLabel, baseTableLabel, joinParams } = props const { label, tablesToImportByLabel, joinBy} = props
const tables = tablesToImportByLabel.map(label => { const tables = tablesToImportByLabel.map(label => {
return this.tables.getTableByLabel(label) return this.tables.getTableByLabel(label)
}) })
@ -32,11 +32,10 @@ class CreateNoduleController {
this.nodules.addNewJoinNodule({ this.nodules.addNewJoinNodule({
label, label,
tables, tables,
joinBy: { joinBy
baseTableLabel,
joinParams
}
}) })
console.log(this.nodules)
document.dispatchEvent(this.updatedNodulesEvent) document.dispatchEvent(this.updatedNodulesEvent)
} }

View File

@ -10,7 +10,7 @@ class CreateJoinNoduleForm extends Component {
this.tables = new Tables() this.tables = new Tables()
this.state = { this.state = {
bastTableLabel: '', baseTableLabel: '',
joinParams: [], joinParams: [],
tables: this.tables.getCollectionProps() tables: this.tables.getCollectionProps()
} }
@ -35,7 +35,7 @@ class CreateJoinNoduleForm extends Component {
} }
handleChange = (e, value) => { handleChange = (e, value) => {
this.setState({ bastTableLabel: value.value }) this.setState({ baseTableLabel: value.value })
} }
getBaseTableDropDownOptions = () => { getBaseTableDropDownOptions = () => {
@ -48,6 +48,11 @@ class CreateJoinNoduleForm extends Component {
return options return options
} }
getJoinProperties = () => {
const { baseTableLabel, joinParams } = this.state
return { baseTableLabel, joinParams }
}
updateTableList = () => { updateTableList = () => {
this.setState({tables: this.tables.getCollectionProps()}) this.setState({tables: this.tables.getCollectionProps()})
} }

View File

@ -5,8 +5,9 @@ import './CreateNodule.css'
import Tables from '../../Collections/Tables' import Tables from '../../Collections/Tables'
import CreateNoduleController from '../../Controllers/CreateNoduleController' import CreateNoduleController from '../../Controllers/CreateNoduleController'
import TableSelect from './TableSelect'
import CreateJoinNoduleForm from './CreateJoinNoduleForm' import CreateJoinNoduleForm from './CreateJoinNoduleForm'
import CreateTransformNoduleForm from './CreateTransformNoduleForm'
import TableSelect from './TableSelect'
class CreateNodule extends Component { class CreateNodule extends Component {
constructor () { constructor () {
@ -47,6 +48,14 @@ class CreateNodule extends Component {
filterParams: filterProperties.filterParams filterParams: filterProperties.filterParams
}) })
} }
else if (noduleType === 'join') {
const joinProperties = this.joinNoduleForm.current.getJoinProperties()
this.controller.addNewJoinNodule({
label: noduleLabel,
tablesToImportByLabel: selectedTableLabels,
joinBy: joinProperties
})
}
} }
updateTableList = () => { updateTableList = () => {
@ -58,6 +67,7 @@ class CreateNodule extends Component {
if (noduleType === 'filter') return <CreateFilterNoduleForm ref={this.filterNoduleForm} /> if (noduleType === 'filter') return <CreateFilterNoduleForm ref={this.filterNoduleForm} />
else if (noduleType === 'join') return <CreateJoinNoduleForm ref={this.joinNoduleForm} tables={tablesToImportByLabel || []}/> else if (noduleType === 'join') return <CreateJoinNoduleForm ref={this.joinNoduleForm} tables={tablesToImportByLabel || []}/>
else if (noduleType === 'transform') return <CreateTransformNoduleForm ref={this.joinNoduleForm} tables={tablesToImportByLabel || []}/>
else return '' else return ''
} }