/*** @jsx React.DOM */ var card_management = createReactClass({ 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 ; }, sortNumber: function(a, b) { return a.number.localeCompare(b.number); }, renderOwner: function(card) { if (card.owner) { return ( { card.owner } ); } else { return ( anonymous account ); } }, sortOwner: function(a, b) { var aown = a.owner ? a.owner : ''; var bown = b.owner ? b.owner : ''; return aown.localeCompare(bown); }, renderEditButton: function(card) { return ( <> ); }, render: function() { return (

All cards

Add Card

Card Number Owner
); }, }); ReactDOM.render( React.createElement(card_management, null), document.getElementById('content') );