Hardware
- Beachte, dass die Reihenfolge des Auswählens maßgebend ist.
- {this.props.error.steps[this.props.index].hardware ? Wähle mindestens eine Hardware aus. : null}
+ Beachte, dass die Reihenfolge des Auswählens maßgebend ist.
+ {this.props.error ? Wähle mindestens eine Hardware aus. : null}
{hardware.map((picture,i) => (
this.onChange(picture.id)} classes={{tile: this.props.value.filter(value => value === picture.id).length > 0 ? this.props.classes.active : this.props.classes.border}}>
diff --git a/src/components/Tutorial/Builder/Id.js b/src/components/Tutorial/Builder/Id.js
index eb9742e..bb4ebde 100644
--- a/src/components/Tutorial/Builder/Id.js
+++ b/src/components/Tutorial/Builder/Id.js
@@ -25,7 +25,7 @@ class Id extends Component {
var value = parseInt(e.target.value);
if(Number.isInteger(value) && value > 0){
this.props.tutorialId(value);
- if(this.props.error.id){
+ if(this.props.error){
this.props.deleteError(undefined, 'id');
}
}
@@ -39,7 +39,7 @@ class Id extends Component {
if(this.props.value+step < 1){
this.props.setError(undefined,'id');
}
- else if(this.props.error.id){
+ else if(this.props.error){
this.props.deleteError(undefined, 'id');
}
if(!this.props.value){
@@ -57,7 +57,7 @@ class Id extends Component {
ID
}
/>
- {this.props.error.id ? Gib eine positive ganzzahlige Zahl ein. : null}
+ {this.props.error ? Gib eine positive ganzzahlige Zahl ein. : null}
Beachte, dass die ID eindeutig sein muss. Sie muss sich also zu den anderen Tutorials unterscheiden.
diff --git a/src/components/Tutorial/Builder/Step.js b/src/components/Tutorial/Builder/Step.js
index 707dac7..ac5bde6 100644
--- a/src/components/Tutorial/Builder/Step.js
+++ b/src/components/Tutorial/Builder/Step.js
@@ -85,15 +85,15 @@ class Step extends Component {
-
-
+
+
{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));