From 5885f98eabadcac17130183e1df7fe76f2025473 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Thu, 20 Jun 2013 22:51:56 +0200 Subject: Add changing order of stories --- js/main.js | 35 +++++++++++++++++++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) (limited to 'js/main.js') diff --git a/js/main.js b/js/main.js index 4b84401..27643f4 100644 --- a/js/main.js +++ b/js/main.js @@ -33,6 +33,10 @@ var StoryRow = React.createClass({ return ( + + + + @@ -78,6 +82,30 @@ var StoryRow = React.createClass({ this.setState({state: eval(data).state}); }.bind(this) }); + }), + moveUp: React.autoBind(function(event) { + $.ajax({ + url: "/stories/up/", + type: "POST", + data: {'id': this.props.story.id}, + dataType: 'json', + mimeType: 'textPlain', + success: function (data) { + this.props.onMoved(1); + }.bind(this) + }); + }), + moveDown: React.autoBind(function(event) { + $.ajax({ + url: "/stories/down/", + type: "POST", + data: {'id': this.props.story.id}, + dataType: 'json', + mimeType: 'textPlain', + success: function (data) { + this.props.onMoved(-1); + }.bind(this) + }); }) }); @@ -101,10 +129,13 @@ var StoryTable = React.createClass({ this.props.pollInterval ); }, + handleMoved: React.autoBind(function(direction) { + this.loadStoriesFromServer(); + }), render: function() { var storyNodes = this.state.data.map(function (story) { - return ; - }); + return ; + }.bind(this)); return ( {storyNodes} -- cgit v1.2.3-54-g00ecf