Created
July 23, 2013 05:57
-
-
Save tarlepp/6060164 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| body.on('taskAdd', function(event, story) { | |
| jQuery.get('/Task/add', {projectId: story.projectId(), storyId: story.id()}, function(content) { | |
| var title = "Add new task to story '" + ko.toJS(story.title()) + "'"; | |
| var buttons = [ | |
| { | |
| label: "Save", | |
| class: "btn-primary pull-right", | |
| callback: function () { | |
| var form = jQuery('#formTaskNew'); | |
| var formItems = form.serializeJSON(); | |
| // Validate current form items and try to create new task | |
| if (validateForm(formItems)) { | |
| jQuery.ajax({ | |
| type: 'POST', | |
| url: "/task/", | |
| data: formItems, | |
| dataType: 'json' | |
| }) | |
| .done(function(/** models.rest.task */task) { | |
| makeMessage("Task created successfully.", "success", {}); | |
| // Add new task to current story first phase tasks | |
| story.phases()[0].tasks.push(new Task(task)); | |
| modal.modal('hide'); | |
| }) | |
| .fail(function(jqXhr, textStatus, error) { | |
| handleAjaxError(jqXhr, textStatus, error); | |
| }); | |
| } | |
| return false; | |
| } | |
| } | |
| ]; | |
| // Open bootbox modal | |
| var modal = openBootboxDialog(title, content, buttons); | |
| // Make form init when dialog is opened. | |
| modal.on('shown', function() { | |
| initTaskForm(modal, false); | |
| }); | |
| }) | |
| .fail(function(jqXhr, textStatus, error) { | |
| handleAjaxError(jqXhr, textStatus, error); | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment