precondition for each tutorial is at least one instruction and one task
This commit is contained in:
		
							parent
							
								
									4a5d24f2d1
								
							
						
					
					
						commit
						8d752e0430
					
				| @ -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++){ | ||||
|  | ||||
| @ -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 { | ||||
|           </label> | ||||
|           <Button style={{marginRight: '10px', marginBottom: '10px'}} variant='contained' color='primary' onClick={() => this.uploadJsonString()}>String laden</Button> | ||||
|         </div> | ||||
|         <Divider variant='fullWidth' style={{margin: '10px 0 30px 0'}}/> | ||||
|         <Divider variant='fullWidth' style={{margin: '10px 0 15px 0'}}/> | ||||
| 
 | ||||
|         {/*Tutorial-Builder-Form*/} | ||||
|         {this.props.error.type ? | ||||
|           <FormHelperText style={{lineHeight: 'initial'}} className={this.props.classes.errorColor}>{`Ein Tutorial muss mindestens jeweils eine Instruktion und eine Aufgabe enthalten.`}</FormHelperText> | ||||
|         : null} | ||||
|         <Id error={this.props.error.id} value={this.props.id}/> | ||||
|         <Textfield value={this.props.title} property={'title'} label={'Titel'} error={this.props.error.title}/> | ||||
| 
 | ||||
|  | ||||
| @ -58,7 +58,7 @@ class Id extends Component { | ||||
| 
 | ||||
|   render() { | ||||
|     return ( | ||||
|       <div style={{display: 'inline-flex'}}> | ||||
|       <div style={{display: 'inline-flex', marginTop: '15px'}}> | ||||
|       <FormControl variant="outlined" style={{marginBottom: '10px', width: '250px'}}> | ||||
|         <InputLabel | ||||
|           htmlFor="id" | ||||
|  | ||||
| @ -1,7 +1,7 @@ | ||||
| import React, { Component } from 'react'; | ||||
| import PropTypes from 'prop-types'; | ||||
| import { connect } from 'react-redux'; | ||||
| import { changeContent, deleteProperty } from '../../../actions/tutorialBuilderActions'; | ||||
| import { changeContent, deleteProperty, deleteError } from '../../../actions/tutorialBuilderActions'; | ||||
| 
 | ||||
| import Radio from '@material-ui/core/Radio'; | ||||
| import RadioGroup from '@material-ui/core/RadioGroup'; | ||||
| @ -13,6 +13,9 @@ class StepType extends Component { | ||||
|     this.props.changeContent(this.props.index, 'type', value); | ||||
|     // delete property 'xml', so that all used blocks are reset
 | ||||
|     this.props.deleteProperty(this.props.index, 'xml'); | ||||
|     if(value === 'task'){ | ||||
|       this.props.deleteError(undefined, 'type'); | ||||
|     } | ||||
|   } | ||||
| 
 | ||||
|   render() { | ||||
| @ -38,7 +41,8 @@ class StepType extends Component { | ||||
| 
 | ||||
| StepType.propTypes = { | ||||
|   changeContent: PropTypes.func.isRequired, | ||||
|   deleteProperty: PropTypes.func.isRequired | ||||
|   deleteProperty: PropTypes.func.isRequired, | ||||
|   deleteError: PropTypes.func.isRequired | ||||
| }; | ||||
| 
 | ||||
| export default connect(null, { changeContent, deleteProperty })(StepType); | ||||
| export default connect(null, { changeContent, deleteProperty, deleteError })(StepType); | ||||
|  | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user