mirror of
https://github.com/ENSL/ensl_gathers.git
synced 2024-11-23 04:52:00 +00:00
Implement gather reset buttons
This commit is contained in:
parent
5ed772192b
commit
e9120868fb
3 changed files with 37 additions and 11 deletions
|
@ -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({
|
const AdminPanel = exports.AdminPanel = React.createClass({
|
||||||
mixins: [MenubarMixin],
|
mixins: [MenubarMixin],
|
||||||
|
|
||||||
propTypes: {
|
propTypes: {
|
||||||
socket: React.PropTypes.object.isRequired
|
socket: React.PropTypes.object.isRequired,
|
||||||
},
|
gatherPool: React.PropTypes.object.isRequired
|
||||||
|
|
||||||
handleGatherReset() {
|
|
||||||
this.props.socket.emit("gather:reset");
|
|
||||||
},
|
},
|
||||||
|
|
||||||
render() {
|
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 (
|
return (
|
||||||
<li className={this.componentClass()}>
|
<li className={this.componentClass()}>
|
||||||
<a href="#" onClick={this.toggleShow}>
|
<a href="#" onClick={this.toggleShow}>
|
||||||
|
@ -76,10 +104,7 @@ const AdminPanel = exports.AdminPanel = React.createClass({
|
||||||
<UserLogin socket={this.props.socket} />
|
<UserLogin socket={this.props.socket} />
|
||||||
<h5>Gather Options</h5>
|
<h5>Gather Options</h5>
|
||||||
<div>
|
<div>
|
||||||
<button
|
{resetButtons}
|
||||||
className="btn btn-danger max-width"
|
|
||||||
onClick={this.handleGatherReset}>
|
|
||||||
Reset Gather</button>
|
|
||||||
</div>
|
</div>
|
||||||
</ul>
|
</ul>
|
||||||
</ul>
|
</ul>
|
||||||
|
|
|
@ -416,7 +416,8 @@ const GatherPage = React.createClass({
|
||||||
}
|
}
|
||||||
|
|
||||||
let adminPanel;
|
let adminPanel;
|
||||||
if (user && user.admin) adminPanel = <AdminPanel socket={socket} />;
|
if (user && user.admin) adminPanel = <AdminPanel socket={socket}
|
||||||
|
gatherPool={this.state.gatherPool} />;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={appClass.join(" ")}>
|
<div className={appClass.join(" ")}>
|
||||||
|
|
|
@ -243,7 +243,7 @@ module.exports = function (namespace) {
|
||||||
const gatherManager = GatherPool.get(data.type);
|
const gatherManager = GatherPool.get(data.type);
|
||||||
if (!gatherManager) return;
|
if (!gatherManager) return;
|
||||||
if (socket._user.isGatherAdmin()) {
|
if (socket._user.isGatherAdmin()) {
|
||||||
GatherManager.reset();
|
gatherManager.reset();
|
||||||
refreshGather(data.type);
|
refreshGather(data.type);
|
||||||
Event.adminRegather(socket._user);
|
Event.adminRegather(socket._user);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue