diff options
author | Tom Willemse | 2013-06-20 22:51:56 +0200 |
---|---|---|
committer | Tom Willemse | 2013-06-20 22:51:56 +0200 |
commit | 5885f98eabadcac17130183e1df7fe76f2025473 (patch) | |
tree | a7754187d6cf35476ef890e571ca2ff9481c0b57 /js/main.js | |
parent | e529f38b59cdf6fa7155de754ec9857f2b5e2dc6 (diff) | |
download | scrumelo-5885f98eabadcac17130183e1df7fe76f2025473.tar.gz scrumelo-5885f98eabadcac17130183e1df7fe76f2025473.zip |
Add changing order of stories
Diffstat (limited to 'js/main.js')
-rw-r--r-- | js/main.js | 35 |
1 files changed, 33 insertions, 2 deletions
@@ -34,6 +34,10 @@ var StoryRow = React.createClass({ return ( <tr> <td> + <i class="icon-arrow-up" onClick={this.moveUp}></i> + <i class="icon-arrow-down" onClick={this.moveDown}></i> + </td> + <td> <span onClick={this.changeState}> <StateIcon state={this.state.state} /> {state} @@ -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 <StoryRow story={story} />; - }); + return <StoryRow story={story} onMoved={this.handleMoved} />; + }.bind(this)); return ( <table class="table table-striped"> {storyNodes} |