Add new input, which increases the group advance exponentially
This commit is contained in:
parent
8c6304fac7
commit
e58cfdc288
|
|
@ -3,9 +3,8 @@ import React from 'react';
|
||||||
import {notify} from 'react-notify-toast';
|
import {notify} from 'react-notify-toast';
|
||||||
import {connect} from 'react-redux';
|
import {connect} from 'react-redux';
|
||||||
import posed from 'react-pose';
|
import posed from 'react-pose';
|
||||||
|
import {Button, Card, CardBody, Container, CustomInput, Form, FormGroup,
|
||||||
import {Button, Card, CardBody, Container, CustomInput, Form, FormGroup, Input, Label} from 'reactstrap';
|
Input, InputGroup, InputGroupAddon, Label} from 'reactstrap';
|
||||||
|
|
||||||
import {TurniereNavigation} from '../js/components/Navigation';
|
import {TurniereNavigation} from '../js/components/Navigation';
|
||||||
import {Footer} from '../js/components/Footer';
|
import {Footer} from '../js/components/Footer';
|
||||||
import EditableStringList from '../js/components/EditableStringList';
|
import EditableStringList from '../js/components/EditableStringList';
|
||||||
|
|
@ -75,7 +74,8 @@ class CreateTournamentForm extends React.Component {
|
||||||
this.handleDescriptionInput = this.handleDescriptionInput.bind(this);
|
this.handleDescriptionInput = this.handleDescriptionInput.bind(this);
|
||||||
this.handlePublicInput = this.handlePublicInput.bind(this);
|
this.handlePublicInput = this.handlePublicInput.bind(this);
|
||||||
this.handleGroupSizeInput = this.handleGroupSizeInput.bind(this);
|
this.handleGroupSizeInput = this.handleGroupSizeInput.bind(this);
|
||||||
this.handleGroupAdvanceInput = this.handleGroupAdvanceInput.bind(this);
|
this.increaseGroupAdvance = this.increaseGroupAdvance.bind(this);
|
||||||
|
this.decreaseGroupAdvance = this.decreaseGroupAdvance.bind(this);
|
||||||
this.generateTournamentCreationObject = this.generateTournamentCreationObject.bind(this);
|
this.generateTournamentCreationObject = this.generateTournamentCreationObject.bind(this);
|
||||||
|
|
||||||
this.create = this.create.bind(this);
|
this.create = this.create.bind(this);
|
||||||
|
|
@ -113,8 +113,20 @@ class CreateTournamentForm extends React.Component {
|
||||||
<FormGroup>
|
<FormGroup>
|
||||||
<Label for="teams-group-to-playoff">Wie viele Teams sollen nach der Gruppenphase
|
<Label for="teams-group-to-playoff">Wie viele Teams sollen nach der Gruppenphase
|
||||||
weiterkommen?</Label>
|
weiterkommen?</Label>
|
||||||
<Input type="number" name="teams-group-to-playoff" min="1" max={this.state.groupSize - 1}
|
<InputGroup>
|
||||||
value={this.state.groupAdvance} onChange={this.handleGroupAdvanceInput}/>
|
<InputGroupAddon addonType="prepend">
|
||||||
|
<Button onClick={this.decreaseGroupAdvance} color='primary' outline>
|
||||||
|
<img src="../static/icons/chevron-left.svg"/>
|
||||||
|
</Button>
|
||||||
|
</InputGroupAddon>
|
||||||
|
<Input className='font-weight-bold' value={this.state.groupAdvance}
|
||||||
|
disabled type='number' step='1' placeholder='0'/>
|
||||||
|
<InputGroupAddon addonType="append">
|
||||||
|
<Button onClick={this.increaseGroupAdvance} color='primary' outline>
|
||||||
|
<img src="../static/icons/chevron-right.svg"/>
|
||||||
|
</Button>
|
||||||
|
</InputGroupAddon>
|
||||||
|
</InputGroup>
|
||||||
</FormGroup>
|
</FormGroup>
|
||||||
</GroupphaseFader>
|
</GroupphaseFader>
|
||||||
</Form>
|
</Form>
|
||||||
|
|
@ -143,6 +155,26 @@ class CreateTournamentForm extends React.Component {
|
||||||
this.setState({groups: list});
|
this.setState({groups: list});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
increaseGroupAdvance() {
|
||||||
|
const newGroupAdvance = this.state.groupAdvance * 2;
|
||||||
|
|
||||||
|
if (newGroupAdvance <= this.state.groupSize) {
|
||||||
|
this.setState({
|
||||||
|
groupAdvance: newGroupAdvance
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
decreaseGroupAdvance() {
|
||||||
|
const newGroupAdvance = Math.floor(this.state.groupAdvance / 2);
|
||||||
|
|
||||||
|
if (newGroupAdvance >= 1) {
|
||||||
|
this.setState({
|
||||||
|
groupAdvance: newGroupAdvance
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
handleGroupSizeInput(input) {
|
handleGroupSizeInput(input) {
|
||||||
const newSize = input.target.value;
|
const newSize = input.target.value;
|
||||||
|
|
||||||
|
|
@ -150,26 +182,15 @@ class CreateTournamentForm extends React.Component {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newSize <= this.state.groupAdvance) {
|
if (newSize < this.state.groupAdvance) {
|
||||||
this.setState({
|
this.setState({
|
||||||
groupSize: newSize, groupAdvance: newSize - 1
|
groupSize: newSize, groupAdvance: Math.floor(this.state.groupAdvance / 2)
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
this.setState({groupSize: newSize});
|
this.setState({groupSize: newSize});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
handleGroupAdvanceInput(input) {
|
|
||||||
const newAdvance = input.target.value;
|
|
||||||
|
|
||||||
if (newAdvance === undefined || newAdvance <= 0 ||
|
|
||||||
newAdvance >= this.state.groupSize) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setState({groupAdvance: newAdvance});
|
|
||||||
}
|
|
||||||
|
|
||||||
handleGroupPhaseEnabledInput(input) {
|
handleGroupPhaseEnabledInput(input) {
|
||||||
this.setState({groupPhaseEnabled: input.target.checked});
|
this.setState({groupPhaseEnabled: input.target.checked});
|
||||||
}
|
}
|
||||||
|
|
@ -195,7 +216,7 @@ class CreateTournamentForm extends React.Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
generateTournamentCreationObject() {
|
generateTournamentCreationObject() {
|
||||||
let tournament = {
|
const tournament = {
|
||||||
'name': this.state.name,
|
'name': this.state.name,
|
||||||
'description': this.state.description,
|
'description': this.state.description,
|
||||||
'public': this.state.public,
|
'public': this.state.public,
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,3 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
|
||||||
|
<path d="M4 0l-4 4 4 4 1.5-1.5-2.5-2.5 2.5-2.5-1.5-1.5z" transform="translate(1)" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 173 B |
|
|
@ -0,0 +1,3 @@
|
||||||
|
<svg xmlns="http://www.w3.org/2000/svg" width="8" height="8" viewBox="0 0 8 8">
|
||||||
|
<path d="M1.5 0l-1.5 1.5 2.5 2.5-2.5 2.5 1.5 1.5 4-4-4-4z" transform="translate(1)" />
|
||||||
|
</svg>
|
||||||
|
After Width: | Height: | Size: 175 B |
Loading…
Reference in New Issue