/*** @jsx React.DOM */
var card_management = createReactClass({
getInitialState: function(props) {
return {
new_arcade: {
name: '',
description: '',
region: window.default_region,
area: window.default_area,
paseli_enabled: window.paseli_enabled,
paseli_infinite: window.paseli_infinite,
mask_services_url: window.mask_services_url,
owners: [null],
},
arcades: window.arcades,
usernames: window.usernames,
editing_arcade: null,
};
},
componentDidUpdate: function() {
if (this.focus_element && this.focus_element != this.already_focused) {
this.focus_element.focus();
this.already_focused = this.focus_element;
}
},
addNewArcade: function(event) {
AJAX.post(
Link.get('addarcade'),
{arcade: this.state.new_arcade},
function(response) {
this.setState({
arcades: response.arcades,
new_arcade: {
name: '',
description: '',
region: window.default_region,
area: window.default_area,
paseli_enabled: window.paseli_enabled,
paseli_infinite: window.paseli_infinite,
mask_services_url: window.mask_services_url,
owners: [null],
},
});
}.bind(this)
);
event.preventDefault();
},
saveArcade: function(event) {
AJAX.post(
Link.get('updatearcade'),
{arcade: this.state.editing_arcade},
function(response) {
this.setState({
arcades: response.arcades,
editing_arcade: null,
});
}.bind(this)
);
event.preventDefault();
},
deleteExistingArcade: function(event, arcadeid) {
$.confirm({
escapeKey: 'Cancel',
animation: 'none',
closeAnimation: 'none',
title: 'Delete Arcade',
content: 'Are you sure you want to delete this arcade from the network?',
buttons: {
Delete: {
btnClass: 'delete',
action: function() {
AJAX.post(
Link.get('removearcade'),
{arcadeid: arcadeid},
function(response) {
this.setState({
arcades: response.arcades,
});
}.bind(this)
);
}.bind(this),
},
Cancel: function() {
},
}
});
event.preventDefault();
},
renderEditButton: function(arcade) {
if(this.state.editing_arcade) {
if (this.state.editing_arcade.id == arcade.id) {
return (
<>
>
);
} else {
return null;
}
} else {
return (
<>