diff --git a/src/actions/tutorialBuilderActions.js b/src/actions/tutorialBuilderActions.js index 2f0f7ff..3925e41 100644 --- a/src/actions/tutorialBuilderActions.js +++ b/src/actions/tutorialBuilderActions.js @@ -245,7 +245,9 @@ export const readJSON = (json) => (dispatch, getState) => { dispatch(resetTutorial()); dispatch({ type: BUILDER_ERROR, - payload: {steps: [{},{}]} + payload: { + steps: new Array(json.steps.length).fill({}) + } }); dispatch(tutorialTitle(json.title)); dispatch(tutorialId(json.id)); diff --git a/src/components/Tutorial/Builder/BlocklyExample.js b/src/components/Tutorial/Builder/BlocklyExample.js index 0665c41..2ecfa12 100644 --- a/src/components/Tutorial/Builder/BlocklyExample.js +++ b/src/components/Tutorial/Builder/BlocklyExample.js @@ -45,9 +45,10 @@ class BlocklyExample extends Component { } componentDidMount(){ - if(this.props.task){ - this.props.setError(this.props.index, 'xml'); - } + this.isError(); + // if(this.props.task){ + // this.props.setError(this.props.index, 'xml'); + // } } componentDidUpdate(props, state){ @@ -95,9 +96,9 @@ class BlocklyExample extends Component { } /> : Musterlösung} - {this.state.checked ? !this.props.value || !this.props.error.steps[this.props.index].xml ? - Reiche deine Blöcke ein, indem du auf den rot gefärbten Button klickst. - : Die letzte Einreichung erfolgte um {this.state.input} Uhr. + {this.state.checked ? !this.props.value || this.props.error ? + Reiche deine Blöcke ein, indem du auf den rot gefärbten Button klickst. + : this.state.input ? Die letzte Einreichung erfolgte um {this.state.input} Uhr. : null : null} {this.state.checked ? (() => { var initialXml = this.props.value; @@ -109,19 +110,15 @@ class BlocklyExample extends Component { initialXml = null; 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 ( -
- +
+
- - + + {index === 0 ?
- +
: null} - +
diff --git a/src/components/Tutorial/Builder/Textfield.js b/src/components/Tutorial/Builder/Textfield.js index f2c88a8..46bae8f 100644 --- a/src/components/Tutorial/Builder/Textfield.js +++ b/src/components/Tutorial/Builder/Textfield.js @@ -20,6 +20,12 @@ const styles = theme => ({ class Textfield extends Component { + componentDidMount(){ + if(this.props.error){ + this.props.deleteError(this.props.index, this.props.property); + } + } + handleChange = (e) => { var value = e.target.value; if(this.props.property === 'title'){ @@ -46,7 +52,7 @@ class Textfield extends Component { this.handleChange(e)} /> - {this.props.index !== undefined ? - this.props.error.steps[this.props.index][this.props.property] ? {this.props.errorText} - : null - : this.props.error[this.props.property] ? - this.props.property === 'title' ? Gib einen Titel für das Tutorial ein. - : Gib einen JSON-String ein und bestätige diesen mit einem Klick auf den entsprechenden Button + {this.props.error ? + this.props.property === 'title' ? Gib einen Titel für das Tutorial ein. + : this.props.property === 'json' ? Gib einen JSON-String ein und bestätige diesen mit einem Klick auf den entsprechenden Button + : {this.props.errorText} : null} ); @@ -71,13 +75,6 @@ Textfield.propTypes = { tutorialTitle: PropTypes.func.isRequired, jsonString: PropTypes.func.isRequired, changeContent: PropTypes.func.isRequired, - error: PropTypes.object.isRequired, - change: PropTypes.number.isRequired }; -const mapStateToProps = state => ({ - error: state.builder.error, - change: state.builder.change -}); - -export default connect(mapStateToProps, { tutorialTitle, jsonString, changeContent, setError, deleteError })(withStyles(styles, { withTheme: true })(Textfield)); +export default connect(null, { tutorialTitle, jsonString, changeContent, setError, deleteError })(withStyles(styles, { withTheme: true })(Textfield));