diff --git a/src/actions/tutorialBuilderActions.js b/src/actions/tutorialBuilderActions.js index e7f2c7a..f200cf0 100644 --- a/src/actions/tutorialBuilderActions.js +++ b/src/actions/tutorialBuilderActions.js @@ -169,7 +169,7 @@ export const setSubmitError = () => (dispatch, getState) => { if(builder.id === undefined || builder.title === ''){ dispatch(setError(undefined, 'title')); } - builder.steps.map((step, i) => { + var type = builder.steps.map((step, i) => { step.id = i+1; if(i === 0){ if(step.requirements && step.requirements.length > 0){ @@ -195,15 +195,18 @@ export const setSubmitError = () => (dispatch, getState) => { if(step.text === undefined || step.text === ''){ dispatch(setError(i, 'text')); } - return null; + return step.type; }); + if(!(type.filter(item => item === 'task').length > 0 && type.filter(item => item === 'instruction').length > 0)){ + dispatch(setError(undefined, 'type')); + } }; export const checkError = () => (dispatch, getState) => { dispatch(setSubmitError()); var error = getState().builder.error; - if(error.id || error.title){ + if(error.id || error.title || error.type){ return true; } for(var i = 0; i < error.steps.length; i++){ diff --git a/src/components/Tutorial/Builder/Builder.js b/src/components/Tutorial/Builder/Builder.js index 35f435a..1c6c819 100644 --- a/src/components/Tutorial/Builder/Builder.js +++ b/src/components/Tutorial/Builder/Builder.js @@ -19,11 +19,15 @@ import Button from '@material-ui/core/Button'; import Backdrop from '@material-ui/core/Backdrop'; import CircularProgress from '@material-ui/core/CircularProgress'; import Divider from '@material-ui/core/Divider'; +import FormHelperText from '@material-ui/core/FormHelperText'; const styles = (theme) => ({ backdrop: { zIndex: theme.zIndex.drawer + 1, color: '#fff', + }, + errorColor: { + color: theme.palette.error.dark } }); @@ -138,9 +142,12 @@ class Builder extends Component { - + {/*Tutorial-Builder-Form*/} + {this.props.error.type ? + {`Ein Tutorial muss mindestens jeweils eine Instruktion und eine Aufgabe enthalten.`} + : null} diff --git a/src/components/Tutorial/Builder/Id.js b/src/components/Tutorial/Builder/Id.js index f36bc70..08d8aab 100644 --- a/src/components/Tutorial/Builder/Id.js +++ b/src/components/Tutorial/Builder/Id.js @@ -58,7 +58,7 @@ class Id extends Component { render() { return ( -
+