/*** @jsx React.DOM */
var card_management = React.createClass({
getInitialState: function(props) {
return {
cards: window.cards,
usernames: window.usernames,
new_card: {
number: '',
owner: null,
},
};
},
addNewCard: function(event) {
if (!this.state.new_card.owner) {
Messages.error('You must select an owner for new cards!');
} else {
AJAX.post(
Link.get('addcard'),
{card: this.state.new_card},
function(response) {
this.setState({
cards: response.cards,
new_card: {
number: '',
owner: null,
},
});
}.bind(this)
);
}
event.preventDefault();
},
deleteExistingCard: function(card) {
$.confirm({
escapeKey: 'Cancel',
animation: 'none',
closeAnimation: 'none',
title: 'Delete Card',
content: 'Are you sure you want to delete this card?',
buttons: {
Delete: {
btnClass: 'delete',
action: function() {
AJAX.post(
Link.get('removecard'),
{card: card},
function(response) {
this.setState({
cards: response.cards,
});
}.bind(this)
);
}.bind(this),
},
Cancel: function() {
},
}
});
},
renderNumber: function(card) {
return