From 75ac2fe1abfb6bc82405a8f7015ce130ceb7265d Mon Sep 17 00:00:00 2001 From: Chris Blanchard Date: Sun, 9 Aug 2015 17:38:57 +0100 Subject: [PATCH] Show previous completed gather and cycle to new one --- lib/gather/controller.js | 12 ++++-------- lib/react/gather.jsx | 12 ++++++++++-- public/js/app.js | 42 +++++++++++++++++++++++++--------------- 3 files changed, 40 insertions(+), 26 deletions(-) diff --git a/lib/gather/controller.js b/lib/gather/controller.js index 935dab3..d5842ab 100644 --- a/lib/gather/controller.js +++ b/lib/gather/controller.js @@ -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(); diff --git a/lib/react/gather.jsx b/lib/react/gather.jsx index be540be..471fff3 100644 --- a/lib/react/gather.jsx +++ b/lib/react/gather.jsx @@ -484,7 +484,13 @@ var Gather = React.createClass({ if (this.props.gather.state === 'selection') { gatherTeams = } + + var previousGather; + if (this.props.previousGather) { + previousGather = (); + } return ( +
Current Gather @@ -495,7 +501,9 @@ var Gather = React.createClass({ {gatherTeams} {voting} -
+
+ {previousGather} +
); } }); @@ -613,7 +621,7 @@ var CompletedGather = React.createClass({ return (
- Gather Details + Previous Gather
diff --git a/public/js/app.js b/public/js/app.js index ba45b1b..72f8f41 100644 --- a/public/js/app.js +++ b/public/js/app.js @@ -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 }),