Fix FROM db dropdown

pull/3303/head
Andrew Watkins 2018-04-24 14:49:44 -07:00
parent a375cbe453
commit dd8cabb512
3 changed files with 12 additions and 3 deletions

View File

@ -10,6 +10,7 @@ interface Props {
argKey: string
value: string
bodyID: string
declarationID: string
onChangeArg: OnChangeArg
}
@ -56,12 +57,13 @@ class From extends PureComponent<Props, State> {
}
private handleChooseDatabase = (item: DropdownItem): void => {
const {argKey, funcID, onChangeArg, bodyID} = this.props
const {argKey, funcID, onChangeArg, bodyID, declarationID} = this.props
onChangeArg({
funcID,
key: argKey,
value: item.text,
bodyID,
declarationID,
generate: true,
})
}

View File

@ -42,6 +42,7 @@ class FuncArg extends PureComponent<Props> {
funcID={funcID}
value={this.value}
bodyID={bodyID}
declarationID={declarationID}
onChangeArg={onChangeArg}
/>
)

View File

@ -182,8 +182,14 @@ export class IFQLPage extends PureComponent<Props, State> {
private get bodyToScript(): string {
return this.state.body.reduce((acc, b) => {
if (b.declarations.length) {
const funcs = _.get(b, 'declarations.0.funcs', [])
return `${acc}${this.funcsToScript(funcs)}\n\n`
const declaration = _.get(b, 'declarations.0', false)
if (!declaration) {
return acc
}
return `${acc}${declaration.name} = ${this.funcsToScript(
declaration.funcs
)}\n\n`
}
return `${acc}${this.funcsToScript(b.funcs)}\n\n`