From d285fd1f821f3edc23759656a9b9fc32aac000d1 Mon Sep 17 00:00:00 2001 From: Bridget Bailey Date: Fri, 20 Dec 2019 09:41:24 -0800 Subject: [PATCH] Game list input for tables --- src/App.css | 8 +++++ src/Components/DataEntry.jsx | 18 +++++++----- src/Components/Results.jsx | 3 +- src/Components/Subcomponents/SingleInput.jsx | 2 +- src/Components/Tables.jsx | 31 ++++++++++++++++++-- 5 files changed, 49 insertions(+), 13 deletions(-) diff --git a/src/App.css b/src/App.css index 8f4d2d9..47870bf 100644 --- a/src/App.css +++ b/src/App.css @@ -43,6 +43,14 @@ width: 4rem; } +.form-input[type='number'] { + width: 2rem; +} + +.game-input { + width: 8rem; +} + .tables { display: flex; flex-direction: column; diff --git a/src/Components/DataEntry.jsx b/src/Components/DataEntry.jsx index c2b7c14..d350e94 100644 --- a/src/Components/DataEntry.jsx +++ b/src/Components/DataEntry.jsx @@ -25,22 +25,26 @@ class DataEntry extends Component { { id: 1, name: 'Table 1', - size: 2 + size: 2, + games: [] }, { id: 2, name: 'Table 2', - size: 2 + size: 2, + games: [] }, { id: 3, name: 'Table 3', - size: 3 + size: 3, + games: [] }, { id: 4, name: 'Table 4', - size: 3 + size: 3, + games: [] }, ], result: {} @@ -106,7 +110,6 @@ class DataEntry extends Component { totalKids: this.state.options.includes('kidsTable') ? this.state.totalKids : 0, numTables: this.state.tables.length, tables: this.state.tables - }; console.log('Send this in a POST request:', formPayload); @@ -148,10 +151,9 @@ class DataEntry extends Component { ); } } -//TODO on form submit, convert options to booleans + //TODO render tables without isKidsTable option for now -//TODO consider mimicing excel and optimizing after randomness not during picking -/*TODO add Configuration and Constraints middle pane or bottom section: +/*TODO add Configuration and Constraints middle pane or bottom/top section: * Runtime options: run once, get the best of x number of times, or maybe run until the conditions are met (with a max/timeout returning the best so far?) * Constraints: conditions to define best (e.g. no playedWithCount over 3, minimize all playedWithCounts, no stayAtTableCount over 2) */ diff --git a/src/Components/Results.jsx b/src/Components/Results.jsx index 9b7caca..c581407 100644 --- a/src/Components/Results.jsx +++ b/src/Components/Results.jsx @@ -26,7 +26,8 @@ class Results extends Component { let tableData = ""; player.assignedTables.forEach((tableId, index) => { const tableDetails = this.props.tables.find(t => t.id === tableId); - tableData += `Round ${index+1}: ${tableDetails.name}\n`; + const tableGame = tableDetails.games[index] && tableDetails.games[index].trim(); + tableData += `Round ${index+1}: ${tableDetails.name}${tableGame ? ` - ${tableGame}` : ''}\n`; }); formattedData += `${playerTitle}\n${tableData}\n\n`; }); diff --git a/src/Components/Subcomponents/SingleInput.jsx b/src/Components/Subcomponents/SingleInput.jsx index 182b8ee..bc4a1a7 100644 --- a/src/Components/Subcomponents/SingleInput.jsx +++ b/src/Components/Subcomponents/SingleInput.jsx @@ -5,7 +5,7 @@ const SingleInput = (props) => (
{ + if(table.id === changedTableId) { + return {...table, games: newGameList}; + } + return table; + }); handleTablesChange(newTables); } @@ -55,7 +70,8 @@ class Tables extends Component { const newTables = tables.concat({ id: newTableNum, name: tableName, - size: 4 + size: 4, + games: [] }) handleTablesChange(newTables); } @@ -86,6 +102,14 @@ class Tables extends Component { controlFunc={this.handleTableSizeChange} content={table.size} /> + ); @@ -95,6 +119,7 @@ class Tables extends Component { return (

Tables

+
Please enter a comma-separated list of games, with the same number of games as rounds
{this.renderTableRows()}