Show vote results at selection stage

This commit is contained in:
Chris Blanchard 2015-09-05 18:37:43 +01:00
parent 54f3ca0ed7
commit 6525b44714

View file

@ -570,16 +570,21 @@ var Gather = React.createClass({
var voting; var voting;
if (this.props.currentGatherer) { if (this.props.currentGatherer) {
voting = ( let state = this.props.gather.state;
<div className="row add-top"> if (state === 'gathering' || state === 'election') {
<div className="col-md-6"> voting = (
<MapVoting {...this.props} /> <div className="row add-top">
<div className="col-md-6">
<MapVoting {...this.props} />
</div>
<div className="col-md-6">
<ServerVoting {...this.props} />
</div>
</div> </div>
<div className="col-md-6"> );
<ServerVoting {...this.props} /> } else {
</div> voting = <GatherVotingResults gather={this.props.gather} servers={this.props.servers} maps={this.props.maps} />;
</div> }
);
} }
var gatherTeams; var gatherTeams;
@ -663,7 +668,7 @@ var Gatherers = React.createClass({
); );
} else { } else {
if (gatherer.team !== "lobby") { if (gatherer.team !== "lobby") {
action = (<span className="label label-success">{gatherer.team}</span>); action = (<span className="label label-primary">{gatherer.team}</span>);
} }
} }
} }
@ -720,6 +725,20 @@ var Gatherers = React.createClass({
}); });
var CompletedGather = React.createClass({ var CompletedGather = React.createClass({
render() {
return (
<div className="panel panel-default">
<div className="panel-heading">
<strong>Previous Gather</strong>
</div>
<GatherTeams gather={this.props.gather} />
<GatherVotingResults gather={this.props.gather} maps={this.props.maps} servers={this.props.servers}/>
</div>
);
}
});
var GatherVotingResults = React.createClass({
countVotes(voteType) { countVotes(voteType) {
return this.props.gather.gatherers.reduce((acc, gatherer) => { return this.props.gather.gatherers.reduce((acc, gatherer) => {
if (gatherer[voteType] !== null) acc.push(gatherer[voteType]); if (gatherer[voteType] !== null) acc.push(gatherer[voteType]);
@ -739,27 +758,21 @@ var CompletedGather = React.createClass({
var maps = this.selectedMaps(); var maps = this.selectedMaps();
var server = this.selectedServer().pop(); var server = this.selectedServer().pop();
return ( return (
<div className="panel panel-default"> <div className="panel-body">
<div className="panel-heading"> <dl className="dl-horizontal">
<strong>Previous Gather</strong> <dt>Maps</dt>
</div> <dd>{maps.map(map => map.name).join(" & ")}</dd>
<GatherTeams gather={this.props.gather} /> <dt>Server</dt>
<div className="panel-body"> <dd>{server.name}</dd>
<dl className="dl-horizontal"> <dt>Address</dt>
<dt>Maps</dt> <dd>{server.ip}:{server.port}</dd>
<dd>{maps.map(map => map.name).join(" & ")}</dd> <dt>Password</dt>
<dt>Server</dt> <dd>{server.password}</dd>
<dd>{server.name}</dd> <br />
<dt>Address</dt> <dt>&nbsp;</dt>
<dd>{server.ip}:{server.port}</dd> <dd><a href={["steam://run/4920/connect", server.ip +":"+server.port, server.password].join("/")}
<dt>Password</dt> className="btn btn-primary">Click to Join</a></dd>
<dd>{server.password}</dd> </dl>
<br />
<dt>&nbsp;</dt>
<dd><a href={["steam://run/4920/connect", server.ip +":"+server.port, server.password].join("/")}
className="btn btn-primary">Click to Join</a></dd>
</dl>
</div>
</div> </div>
); );
} }