Implement gather reset buttons

This commit is contained in:
Chris Blanchard 2016-03-19 23:37:28 +00:00
parent 5ed772192b
commit e9120868fb
3 changed files with 37 additions and 11 deletions

View file

@ -52,18 +52,46 @@ const UserLogin = React.createClass({
}
});
const ResetGatherButton = exports.ResetGatherButton = React.createClass({
propTypes: {
socket: React.PropTypes.object.isRequired,
gather: React.PropTypes.string.isRequired
},
handleGatherReset() {
this.props.socket.emit("gather:reset", {
type: this.props.gather.type
});
},
render() {
return (
<button
className="btn btn-danger max-width"
onClick={this.handleGatherReset}>
Reset {this.props.gather.name}</button>
);
}
});
const AdminPanel = exports.AdminPanel = React.createClass({
mixins: [MenubarMixin],
propTypes: {
socket: React.PropTypes.object.isRequired
},
handleGatherReset() {
this.props.socket.emit("gather:reset");
socket: React.PropTypes.object.isRequired,
gatherPool: React.PropTypes.object.isRequired
},
render() {
const gatherPool = this.props.gatherPool;
const resetButtons = [];
for (let attr in gatherPool) {
let gather = gatherPool[attr];
resetButtons.push(
<ResetGatherButton socket={this.props.socket}
gather={gather} key={gather.type} />
);
}
return (
<li className={this.componentClass()}>
<a href="#" onClick={this.toggleShow}>
@ -76,10 +104,7 @@ const AdminPanel = exports.AdminPanel = React.createClass({
<UserLogin socket={this.props.socket} />
<h5>Gather Options</h5>
<div>
<button
className="btn btn-danger max-width"
onClick={this.handleGatherReset}>
Reset Gather</button>
{resetButtons}
</div>
</ul>
</ul>

View file

@ -416,7 +416,8 @@ const GatherPage = React.createClass({
}
let adminPanel;
if (user && user.admin) adminPanel = <AdminPanel socket={socket} />;
if (user && user.admin) adminPanel = <AdminPanel socket={socket}
gatherPool={this.state.gatherPool} />;
return (
<div className={appClass.join(" ")}>

View file

@ -243,7 +243,7 @@ module.exports = function (namespace) {
const gatherManager = GatherPool.get(data.type);
if (!gatherManager) return;
if (socket._user.isGatherAdmin()) {
GatherManager.reset();
gatherManager.reset();
refreshGather(data.type);
Event.adminRegather(socket._user);
}