fix bug in blockly example

This commit is contained in:
Delucse 2020-09-20 14:15:18 +02:00
parent 812c01d6bc
commit 15a83f56fc

View File

@ -73,7 +73,6 @@ class BlocklyExample extends Component {
onChange = (value) => { onChange = (value) => {
var oldValue = this.state.checked; var oldValue = this.state.checked;
this.setState({checked: value}); this.setState({checked: value});
console.log(!value);
if(oldValue !== value && !value){ if(oldValue !== value && !value){
this.props.deleteProperty(this.props.index, 'xml'); this.props.deleteProperty(this.props.index, 'xml');
} }
@ -96,7 +95,7 @@ class BlocklyExample extends Component {
} }
/> />
: <FormLabel style={{color: 'black'}}>Musterlösung</FormLabel>} : <FormLabel style={{color: 'black'}}>Musterlösung</FormLabel>}
{this.state.checked ? !this.props.value || this.props.error.steps[this.props.index].xml ? {this.state.checked ? !this.props.value || !this.props.error.steps[this.props.index].xml ?
<FormHelperText style={{lineHeight: 'initial', marginBottom: '10px'}} className={this.props.classes.errorColor}>Reiche deine Blöcke ein, indem du auf den rot gefärbten Button klickst.</FormHelperText> <FormHelperText style={{lineHeight: 'initial', marginBottom: '10px'}} className={this.props.classes.errorColor}>Reiche deine Blöcke ein, indem du auf den rot gefärbten Button klickst.</FormHelperText>
: <FormHelperText style={{lineHeight: 'initial', marginBottom: '10px'}}>Die letzte Einreichung erfolgte um {this.state.input} Uhr.</FormHelperText> : <FormHelperText style={{lineHeight: 'initial', marginBottom: '10px'}}>Die letzte Einreichung erfolgte um {this.state.input} Uhr.</FormHelperText>
: null} : null}
@ -110,15 +109,19 @@ class BlocklyExample extends Component {
initialXml = null; initialXml = null;
this.props.setError(this.props.index, 'xml'); this.props.setError(this.props.index, 'xml');
} }
console.log(!this.props.value);
console.log(this.props.value);
console.log(this.props.error.steps[this.props.index].xml);
console.log(!this.props.value || this.props.error.steps[this.props.index].xml);
return ( return (
<div> <div>
<Grid container className={!this.props.value ? this.props.classes.errorBorder : null}> <Grid container className={!this.props.value || !this.props.error.steps[this.props.index].xml ? this.props.classes.errorBorder : null}>
<Grid item xs={12}> <Grid item xs={12}>
<BlocklyWindow initialXml={initialXml}/> <BlocklyWindow initialXml={initialXml}/>
</Grid> </Grid>
</Grid> </Grid>
<Button <Button
className={!this.props.value || this.props.error.steps[this.props.index].xml ? this.props.classes.errorButton : null } className={!this.props.value || !this.props.error.steps[this.props.index].xml ? this.props.classes.errorButton : null }
style={{marginTop: '5px', height: '40px'}} style={{marginTop: '5px', height: '40px'}}
variant='contained' variant='contained'
color='primary' color='primary'