Skip to content

Commit

Permalink
[FIX] Validate generate data input, closes #1 (#892)
Browse files Browse the repository at this point in the history
  • Loading branch information
mproch authored Apr 28, 2020
1 parent c0c0f02 commit 4bacfde
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions ui/client/components/modals/GenerateTestDataDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@ import HttpService from "../../http/HttpService"
import "../../stylesheets/visualization.styl"
import Dialogs from "./Dialogs"
import GenericModalDialog from "./GenericModalDialog"
import {allValid, literalIntegerValueValidator, mandatoryValueValidator} from "../graph/node-modal/editors/Validators"
import ValidationLabels from "./ValidationLabels"

class GenerateTestDataDialog extends React.Component {

constructor(props) {
super(props)
this.initState = {
testSampleSize: 10,
//TODO: current validators work well only for string values
testSampleSize: "10",
}
this.state = this.initState
}
Expand All @@ -21,15 +24,28 @@ class GenerateTestDataDialog extends React.Component {
return HttpService.generateTestData(this.props.processId, this.state.testSampleSize, this.props.processToDisplay)
}

onInputChange = (event) => {
this.setState({testSampleSize: event.target.value})
}

render() {
const validators = [literalIntegerValueValidator, mandatoryValueValidator]
return (
<GenericModalDialog
init={() => this.setState(this.initState)}
confirm={this.confirm}
okBtnConfig={{disabled: !allValid(validators, [this.state.testSampleSize])}}
type={Dialogs.types.generateTestData}
>
<p>Generate test data</p>
<input autoFocus={true} className="add-comment-on-save" value={this.state.testSampleSize} onChange={(e) => { this.setState({testSampleSize: e.target.value}) } }/>
<input
autoFocus={true}
className="add-comment-on-save"
value={this.state.testSampleSize}
onChange={this.onInputChange}
/>
<ValidationLabels validators={validators} values={[this.state.testSampleSize]}/>

</GenericModalDialog>
)
}
Expand Down

0 comments on commit 4bacfde

Please sign in to comment.