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>
@ -495,7 +501,9 @@ var Gather = React.createClass({
{gatherTeams}
{voting}
<GatherActions {...this.props} />
</div>
</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,28 +616,38 @@ 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",
{ className: "panel panel-default" },
null,
React.createElement(
"div",
{ className: "panel-heading" },
{ className: "panel panel-default" },
React.createElement(
"strong",
null,
"Current Gather"
"div",
{ className: "panel-heading" },
React.createElement(
"strong",
null,
"Current Gather"
),
React.createElement(
"span",
{ className: "badge add-left" },
this.props.gather.gatherers.length
)
),
React.createElement(
"span",
{ className: "badge add-left" },
this.props.gather.gatherers.length
)
React.createElement(GatherProgress, this.props),
React.createElement(Gatherers, this.props),
gatherTeams,
voting,
React.createElement(GatherActions, this.props)
),
React.createElement(GatherProgress, this.props),
React.createElement(Gatherers, this.props),
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 }),