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 === ''){ |   if(builder.id === undefined || builder.title === ''){ | ||||||
|     dispatch(setError(undefined, 'title')); |     dispatch(setError(undefined, 'title')); | ||||||
|   } |   } | ||||||
|   builder.steps.map((step, i) => { |   var type = builder.steps.map((step, i) => { | ||||||
|     step.id = i+1; |     step.id = i+1; | ||||||
|     if(i === 0){ |     if(i === 0){ | ||||||
|       if(step.requirements && step.requirements.length > 0){ |       if(step.requirements && step.requirements.length > 0){ | ||||||
| @ -195,15 +195,18 @@ export const setSubmitError = () => (dispatch, getState) => { | |||||||
|     if(step.text === undefined || step.text === ''){ |     if(step.text === undefined || step.text === ''){ | ||||||
|       dispatch(setError(i, '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) => { | export const checkError = () => (dispatch, getState) => { | ||||||
|   dispatch(setSubmitError()); |   dispatch(setSubmitError()); | ||||||
|   var error = getState().builder.error; |   var error = getState().builder.error; | ||||||
|   if(error.id || error.title){ |   if(error.id || error.title || error.type){ | ||||||
|     return true; |     return true; | ||||||
|   } |   } | ||||||
|   for(var i = 0; i < error.steps.length; i++){ |   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 Backdrop from '@material-ui/core/Backdrop'; | ||||||
| import CircularProgress from '@material-ui/core/CircularProgress'; | import CircularProgress from '@material-ui/core/CircularProgress'; | ||||||
| import Divider from '@material-ui/core/Divider'; | import Divider from '@material-ui/core/Divider'; | ||||||
|  | import FormHelperText from '@material-ui/core/FormHelperText'; | ||||||
| 
 | 
 | ||||||
| const styles = (theme) => ({ | const styles = (theme) => ({ | ||||||
|   backdrop: { |   backdrop: { | ||||||
|     zIndex: theme.zIndex.drawer + 1, |     zIndex: theme.zIndex.drawer + 1, | ||||||
|     color: '#fff', |     color: '#fff', | ||||||
|  |   }, | ||||||
|  |   errorColor: { | ||||||
|  |     color: theme.palette.error.dark | ||||||
|   } |   } | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| @ -138,9 +142,12 @@ class Builder extends Component { | |||||||
|           </label> |           </label> | ||||||
|           <Button style={{marginRight: '10px', marginBottom: '10px'}} variant='contained' color='primary' onClick={() => this.uploadJsonString()}>String laden</Button> |           <Button style={{marginRight: '10px', marginBottom: '10px'}} variant='contained' color='primary' onClick={() => this.uploadJsonString()}>String laden</Button> | ||||||
|         </div> |         </div> | ||||||
|         <Divider variant='fullWidth' style={{margin: '10px 0 30px 0'}}/> |         <Divider variant='fullWidth' style={{margin: '10px 0 15px 0'}}/> | ||||||
| 
 | 
 | ||||||
|         {/*Tutorial-Builder-Form*/} |         {/*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}/> |         <Id error={this.props.error.id} value={this.props.id}/> | ||||||
|         <Textfield value={this.props.title} property={'title'} label={'Titel'} error={this.props.error.title}/> |         <Textfield value={this.props.title} property={'title'} label={'Titel'} error={this.props.error.title}/> | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -58,7 +58,7 @@ class Id extends Component { | |||||||
| 
 | 
 | ||||||
|   render() { |   render() { | ||||||
|     return ( |     return ( | ||||||
|       <div style={{display: 'inline-flex'}}> |       <div style={{display: 'inline-flex', marginTop: '15px'}}> | ||||||
|       <FormControl variant="outlined" style={{marginBottom: '10px', width: '250px'}}> |       <FormControl variant="outlined" style={{marginBottom: '10px', width: '250px'}}> | ||||||
|         <InputLabel |         <InputLabel | ||||||
|           htmlFor="id" |           htmlFor="id" | ||||||
|  | |||||||
| @ -1,7 +1,7 @@ | |||||||
| import React, { Component } from 'react'; | import React, { Component } from 'react'; | ||||||
| import PropTypes from 'prop-types'; | import PropTypes from 'prop-types'; | ||||||
| import { connect } from 'react-redux'; | 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 Radio from '@material-ui/core/Radio'; | ||||||
| import RadioGroup from '@material-ui/core/RadioGroup'; | import RadioGroup from '@material-ui/core/RadioGroup'; | ||||||
| @ -13,6 +13,9 @@ class StepType extends Component { | |||||||
|     this.props.changeContent(this.props.index, 'type', value); |     this.props.changeContent(this.props.index, 'type', value); | ||||||
|     // delete property 'xml', so that all used blocks are reset
 |     // delete property 'xml', so that all used blocks are reset
 | ||||||
|     this.props.deleteProperty(this.props.index, 'xml'); |     this.props.deleteProperty(this.props.index, 'xml'); | ||||||
|  |     if(value === 'task'){ | ||||||
|  |       this.props.deleteError(undefined, 'type'); | ||||||
|  |     } | ||||||
|   } |   } | ||||||
| 
 | 
 | ||||||
|   render() { |   render() { | ||||||
| @ -38,7 +41,8 @@ class StepType extends Component { | |||||||
| 
 | 
 | ||||||
| StepType.propTypes = { | StepType.propTypes = { | ||||||
|   changeContent: PropTypes.func.isRequired, |   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