Tasks Index for a Project
Work in progress
This commit is contained in:
@@ -1,30 +1,42 @@
|
||||
function save_task(task_id, task_url) {
|
||||
console.log('Saving task to', task_url);
|
||||
|
||||
var $form = $('.task form');
|
||||
var $form = $('#task-view form');
|
||||
var $button = $form.find("button[type='submit']");
|
||||
var payload = $form.serialize();
|
||||
var task = '#task-' + task_id;
|
||||
|
||||
$button.attr('disabled', true);
|
||||
$(task).addClass('processing');
|
||||
$('#status-bar').text('Saving task...');
|
||||
|
||||
if (console) console.log('Sending:', payload);
|
||||
|
||||
$.post(task_url, payload)
|
||||
.done(function(data) {
|
||||
if (console) console.log('Done saving', data);
|
||||
|
||||
// Update the task list.
|
||||
// NOTE: this is tightly linked to the HTML of the task list in for_project.jade.
|
||||
$('#task-' + task_id).text($form.find("input[name='name']").val());
|
||||
$(task + ' span.name').text($form.find("input[name='name']").val());
|
||||
$(task + ' span.status').text($form.find("select[name='status']").val());
|
||||
$(task + ' span.status-indicator')
|
||||
.removeAttr('class')
|
||||
.addClass('status-indicator ' + $form.find("select[name='status']").val());
|
||||
|
||||
$('#status-bar').text('Saved task. ' + data.time);
|
||||
})
|
||||
.fail(function(xhr_or_response_data) {
|
||||
// jQuery sends the response data (if JSON), or an XHR object (if not JSON).
|
||||
if (console) console.log('Failed saving', xhr_or_response_data);
|
||||
$('#task-details').html(xhr_or_response_data.responseText);
|
||||
$('#status-bar').text('Failed saving. ' + xhr_or_response_data);
|
||||
})
|
||||
.always(function() {
|
||||
$button.attr('disabled', false);
|
||||
$(task).removeClass('processing');
|
||||
})
|
||||
;
|
||||
;
|
||||
|
||||
return false; // prevent synchronous POST to current page.
|
||||
}
|
||||
|
@@ -60,7 +60,7 @@ def save(project, task_id):
|
||||
|
||||
task = current_task_manager.edit_task(task_id, **request.form.to_dict())
|
||||
|
||||
return flask.jsonify({'task_id': task_id, 'etag': task._etag})
|
||||
return flask.jsonify({'task_id': task_id, 'etag': task._etag, 'time': task._updated })
|
||||
|
||||
|
||||
# TODO: remove GET method once Pablo has made a proper button to call this URL with a POST.
|
||||
@@ -75,4 +75,5 @@ def create_task(project, task_type=None):
|
||||
project_url=project['url'],
|
||||
task_id=task['_id'])
|
||||
resp.status_code = 201
|
||||
return resp
|
||||
|
||||
return flask.make_response(flask.jsonify({'task_id': task['_id']}), 201)
|
||||
|
Reference in New Issue
Block a user