From d3eaa60b630b21f1291b96a3b6e995a56ce6aae4 Mon Sep 17 00:00:00 2001 From: Tom Willemse Date: Sun, 11 Aug 2013 14:21:39 +0200 Subject: Use a modal dialog to create tasks This fixes the issue where focus and input would be lost from the input field when the story would reload its tasks. This also makes it a little more uniform with the other forms. --- static/js/main.js | 75 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 27 deletions(-) diff --git a/static/js/main.js b/static/js/main.js index 1db43e0..f60531d 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -123,38 +123,44 @@ var StoryTaskForm = React.createClass({ handleSubmit: React.autoBind(function() { var text = this.refs.text.getDOMNode().value.trim(); - this.props.onTaskSubmit({description: text}); + this.props.onTaskSubmit({description: text, + storyId: this.state.storyId}); + $(".taskModal").modal('hide'); this.refs.text.getDOMNode().value = ''; return false; }), + getInitialState: function() { + return {storyId: null}; + }, + setStoryId: React.autoBind(function(id) { + this.setState({storyId: id}); + }), render: function() { return ( -
-
- New task -
- - -
-
-
+ ); } }); var StoryData = React.createClass({ - handleTaskSubmit: React.autoBind(function (task) { - task.storyId = this.state.data.id; - $.post(baseUrl + "stories/tasks/new", task) - .done(function(data) { - if (data.status == "ok") - this.loadStoryFromServer(); - }.bind(this)); - }), loadStoryFromServer: function() { $.get(baseUrl + "stories/" + this.state.data.id) .done(this.setData.bind(this)); @@ -178,14 +184,19 @@ var StoryData = React.createClass({ render: function() { if (this.state.data) { return (
-

{this.state.data.title}

+

+ + {this.state.data.title} +

{this.state.data.content}
-
); } @@ -299,11 +310,11 @@ var AssignmentForm = React.createClass({ render: function() { return (