Design score edit input fields in tournament view
This commit is contained in:
parent
0bbaaa4d3b
commit
8cc2647258
|
|
@ -5,7 +5,7 @@ import {
|
||||||
Card,
|
Card,
|
||||||
CardBody,
|
CardBody,
|
||||||
Col,
|
Col,
|
||||||
Container,
|
Container, Input, InputGroup, InputGroupAddon,
|
||||||
ListGroup,
|
ListGroup,
|
||||||
ListGroupItem,
|
ListGroupItem,
|
||||||
Modal,
|
Modal,
|
||||||
|
|
@ -136,10 +136,12 @@ class Match extends React.Component {
|
||||||
|
|
||||||
function MatchModal(props) {
|
function MatchModal(props) {
|
||||||
let title;
|
let title;
|
||||||
|
let actionButton = '';
|
||||||
//possible states: single_team not_ready not_started in_progress team1_won team2_won undecided
|
//possible states: single_team not_ready not_started in_progress team1_won team2_won undecided
|
||||||
switch (props.match.state) {
|
switch (props.match.state) {
|
||||||
case 'in_progress':
|
case 'in_progress':
|
||||||
title = 'Spiel läuft';
|
title = 'Spiel läuft';
|
||||||
|
actionButton = <Button color='primary' onClick={props.toggle}>Spiel beenden</Button>
|
||||||
break;
|
break;
|
||||||
case 'team1_won':
|
case 'team1_won':
|
||||||
title = 'Spiel beendet';
|
title = 'Spiel beendet';
|
||||||
|
|
@ -155,6 +157,7 @@ function MatchModal(props) {
|
||||||
break;
|
break;
|
||||||
case 'not_started':
|
case 'not_started':
|
||||||
title = 'Spiel kann gestartet werden';
|
title = 'Spiel kann gestartet werden';
|
||||||
|
actionButton = <Button color='primary' onClick={props.toggle}>Spiel starten</Button>;
|
||||||
break;
|
break;
|
||||||
case 'undecided':
|
case 'undecided':
|
||||||
title = 'Spiel beendet';
|
title = 'Spiel beendet';
|
||||||
|
|
@ -164,11 +167,11 @@ function MatchModal(props) {
|
||||||
<Modal isOpen={props.isOpen} toggle={props.toggle}>
|
<Modal isOpen={props.isOpen} toggle={props.toggle}>
|
||||||
<ModalHeader toggle={props.toggle}>{title}</ModalHeader>
|
<ModalHeader toggle={props.toggle}>{title}</ModalHeader>
|
||||||
<ModalBody>
|
<ModalBody>
|
||||||
<MatchTable match={props.match}/>
|
{props.match.state === 'in_progress' ? <EditableMatchTable match={props.match}/> :
|
||||||
|
<MatchTable match={props.match}/>}
|
||||||
</ModalBody>
|
</ModalBody>
|
||||||
<ModalFooter>
|
<ModalFooter>
|
||||||
{props.match.state === 'not_started' ?
|
{actionButton}
|
||||||
<Button color='primary' onClick={props.toggle}>Spiel Starten</Button> : ''}{' '}
|
|
||||||
<Button color='secondary' onClick={props.toggle}>Abbrechen</Button>
|
<Button color='secondary' onClick={props.toggle}>Abbrechen</Button>
|
||||||
</ModalFooter>
|
</ModalFooter>
|
||||||
</Modal>
|
</Modal>
|
||||||
|
|
@ -217,6 +220,57 @@ function MatchTable(props) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function EditableMatchTable(props) {
|
||||||
|
return (
|
||||||
|
<Table className='mb-0'>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td className='scoreInput border-top-0'>
|
||||||
|
<ScoreInput score={props.match.scoreTeam1}/>
|
||||||
|
</td>
|
||||||
|
<td className='align-middle border-top-0'>{props.match.team1}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td className='scoreInput'>
|
||||||
|
<ScoreInput score={props.match.scoreTeam2}/>
|
||||||
|
</td>
|
||||||
|
<td className='align-middle'>{props.match.team2}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</Table>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
class ScoreInput extends React.Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
this.state = {score: this.props.score};
|
||||||
|
this.updateScore = this.updateScore.bind(this);
|
||||||
|
this.increaseScore = this.increaseScore.bind(this);
|
||||||
|
this.decreaseScore = this.decreaseScore.bind(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateScore(event){
|
||||||
|
this.setState({score: event.target.value});
|
||||||
|
}
|
||||||
|
|
||||||
|
increaseScore(){
|
||||||
|
this.setState({score: Number(this.state.score) + 1});
|
||||||
|
}
|
||||||
|
|
||||||
|
decreaseScore(){
|
||||||
|
this.setState({score: Number(this.state.score) - 1});
|
||||||
|
}
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (<InputGroup>
|
||||||
|
<InputGroupAddon addonType="prepend"><Button onClick={this.decreaseScore} color='danger' outline={true}>-1</Button></InputGroupAddon>
|
||||||
|
<Input className='font-weight-bold' value={this.state.score} onChange={this.updateScore} type='number' step='1' placeholder='0'/>
|
||||||
|
<InputGroupAddon addonType="append"><Button onClick={this.increaseScore} color='success'>+1</Button></InputGroupAddon>
|
||||||
|
</InputGroup>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
class Main extends React.Component {
|
class Main extends React.Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
|
|
|
||||||
|
|
@ -21,4 +21,8 @@
|
||||||
.match:hover > div {
|
.match:hover > div {
|
||||||
border-width: 3px !important;
|
border-width: 3px !important;
|
||||||
margin: -2px;
|
margin: -2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.scoreInput {
|
||||||
|
width: 11rem;
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue