From e58cfdc288fb897832795c1db3f241ed5b2cb1a6 Mon Sep 17 00:00:00 2001 From: Jonny Date: Wed, 12 Jun 2019 10:58:16 +0200 Subject: [PATCH] Add new input, which increases the group advance exponentially --- pages/create.js | 61 +++++++++++++++++++++++----------- static/icons/chevron-left.svg | 3 ++ static/icons/chevron-right.svg | 3 ++ 3 files changed, 47 insertions(+), 20 deletions(-) create mode 100644 static/icons/chevron-left.svg create mode 100644 static/icons/chevron-right.svg diff --git a/pages/create.js b/pages/create.js index 8fd4e3c..1ef0fd3 100644 --- a/pages/create.js +++ b/pages/create.js @@ -3,9 +3,8 @@ import React from 'react'; import {notify} from 'react-notify-toast'; import {connect} from 'react-redux'; import posed from 'react-pose'; - -import {Button, Card, CardBody, Container, CustomInput, Form, FormGroup, Input, Label} from 'reactstrap'; - +import {Button, Card, CardBody, Container, CustomInput, Form, FormGroup, + Input, InputGroup, InputGroupAddon, Label} from 'reactstrap'; import {TurniereNavigation} from '../js/components/Navigation'; import {Footer} from '../js/components/Footer'; import EditableStringList from '../js/components/EditableStringList'; @@ -75,7 +74,8 @@ class CreateTournamentForm extends React.Component { this.handleDescriptionInput = this.handleDescriptionInput.bind(this); this.handlePublicInput = this.handlePublicInput.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.create = this.create.bind(this); @@ -113,8 +113,20 @@ class CreateTournamentForm extends React.Component { - + + + + + + + + + @@ -143,6 +155,26 @@ class CreateTournamentForm extends React.Component { 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) { const newSize = input.target.value; @@ -150,26 +182,15 @@ class CreateTournamentForm extends React.Component { return; } - if (newSize <= this.state.groupAdvance) { + if (newSize < this.state.groupAdvance) { this.setState({ - groupSize: newSize, groupAdvance: newSize - 1 + groupSize: newSize, groupAdvance: Math.floor(this.state.groupAdvance / 2) }); } else { 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) { this.setState({groupPhaseEnabled: input.target.checked}); } @@ -195,7 +216,7 @@ class CreateTournamentForm extends React.Component { } generateTournamentCreationObject() { - let tournament = { + const tournament = { 'name': this.state.name, 'description': this.state.description, 'public': this.state.public, diff --git a/static/icons/chevron-left.svg b/static/icons/chevron-left.svg new file mode 100644 index 0000000..256902c --- /dev/null +++ b/static/icons/chevron-left.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file diff --git a/static/icons/chevron-right.svg b/static/icons/chevron-right.svg new file mode 100644 index 0000000..2da0760 --- /dev/null +++ b/static/icons/chevron-right.svg @@ -0,0 +1,3 @@ + + + \ No newline at end of file