Show previous completed gather and cycle to new one

This commit is contained in:
Chris Blanchard 2015-08-09 17:38:57 +01:00
parent 132f8019b1
commit 75ac2fe1ab
3 changed files with 40 additions and 26 deletions

View file

@ -23,8 +23,7 @@ var Map = require("./map");
var Server = require("./server");
var Gather = require("./gather");
var gather;
var previousGathers = [];
var previousGather;
module.exports = function (namespace) {
var refreshGather = function () {
@ -33,17 +32,14 @@ module.exports = function (namespace) {
gather: gather.toJson(),
currentGatherer: gather.getGatherer(socket._user),
maps: Map.list,
servers: Server.list
servers: Server.list,
previousGather: previousGather
});
});
namespace.emit("gather:history", {
gatherHistory: previousGathers.slice(0,5).map((gather) => {return gather.toJson()})
});
};
var newGather = function () {
if (gather) previousGathers.push(gather);
if (gather) previousGather = gather;
gather = Gather({
onEvent: function () {
refreshGather();

View file

@ -484,7 +484,13 @@ var Gather = React.createClass({
if (this.props.gather.state === 'selection') {
gatherTeams = <GatherTeams gather={this.props.gather} />
}
var previousGather;
if (this.props.previousGather) {
previousGather = (<CompletedGather {...this.props} gather={this.props.previousGather} />);
}
return (
<div>
<div className="panel panel-default">
<div className="panel-heading">
<strong>Current Gather</strong>
@ -496,6 +502,8 @@ var Gather = React.createClass({
{voting}
<GatherActions {...this.props} />
</div>
{previousGather}
</div>
);
}
});
@ -613,7 +621,7 @@ var CompletedGather = React.createClass({
return (
<div className="panel panel-default">
<div className="panel-heading">
<strong>Gather Details</strong>
<strong>Previous Gather</strong>
</div>
<GatherTeams gather={this.props.gather} />
<div className="panel-body">

View file

@ -616,7 +616,15 @@ var Gather = React.createClass({
if (this.props.gather.state === 'selection') {
gatherTeams = React.createElement(GatherTeams, { gather: this.props.gather });
}
var previousGather;
if (this.props.previousGather) {
previousGather = React.createElement(CompletedGather, _extends({}, this.props, { gather: this.props.previousGather }));
}
return React.createElement(
"div",
null,
React.createElement(
"div",
{ className: "panel panel-default" },
React.createElement(
@ -638,6 +646,8 @@ var Gather = React.createClass({
gatherTeams,
voting,
React.createElement(GatherActions, this.props)
),
previousGather
);
}
});
@ -815,7 +825,7 @@ var CompletedGather = React.createClass({
React.createElement(
"strong",
null,
"Gather Details"
"Previous Gather"
)
),
React.createElement(GatherTeams, { gather: this.props.gather }),