Added etag checking when saving tasks & shots. Still a bit rough.
Needs nicer user interface stuff for explaining what's going on.
This commit is contained in:
@@ -92,6 +92,7 @@ class ShotManager(object):
|
||||
api = pillar_api()
|
||||
shot = pillarsdk.Node.find(shot_id, api=api)
|
||||
|
||||
shot._etag = fields.pop('_etag')
|
||||
shot.name = fields.pop('name')
|
||||
shot.description = fields.pop('description')
|
||||
shot.properties.status = fields.pop('status')
|
||||
|
@@ -133,13 +133,16 @@ function attract_form_save(form_id, item_id, item_save_url, options={})
|
||||
if (console) console.log('Done saving', saved_item);
|
||||
$('#status-bar')
|
||||
.text('Saved ' + options.type + '. ' + saved_item._updated);
|
||||
$form.find("input[name='_etag']").val(saved_item._etag);
|
||||
|
||||
if (options.done) options.done($item, saved_item);
|
||||
})
|
||||
.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);
|
||||
$('#status-bar').text('Failed saving. ' + xhr_or_response_data.responseText);
|
||||
|
||||
$button.removeClass('btn-default').addClass('btn-danger');
|
||||
$('#status-bar').text('Failed saving. ' + xhr_or_response_data.status);
|
||||
|
||||
if (options.fail) options.fail($item, xhr_or_response_data);
|
||||
})
|
||||
@@ -171,7 +174,12 @@ function task_save(task_id, task_url) {
|
||||
;
|
||||
},
|
||||
fail: function($item, xhr_or_response_data) {
|
||||
$('#task-details').html(xhr_or_response_data.responseText);
|
||||
if (xhr_or_response_data.status == 412) {
|
||||
// TODO: implement something nice here. Just make sure we don't throw
|
||||
// away the user's edits. It's up to the user to handle this.
|
||||
} else {
|
||||
$('#task-details').html(xhr_or_response_data.responseText);
|
||||
}
|
||||
},
|
||||
type: 'task'
|
||||
});
|
||||
@@ -189,7 +197,12 @@ function shot_save(shot_id, shot_url) {
|
||||
;
|
||||
},
|
||||
fail: function($item, xhr_or_response_data) {
|
||||
$('#task-details').html(xhr_or_response_data.responseText);
|
||||
if (xhr_or_response_data.status == 412) {
|
||||
// TODO: implement something nice here. Just make sure we don't throw
|
||||
// away the user's edits. It's up to the user to handle this.
|
||||
} else {
|
||||
$('#task-details').html(xhr_or_response_data.responseText);
|
||||
}
|
||||
},
|
||||
type: 'shot'
|
||||
});
|
||||
|
@@ -66,6 +66,7 @@ class TaskManager(object):
|
||||
api = pillar_api()
|
||||
task = pillarsdk.Node.find(task_id, api=api)
|
||||
|
||||
task._etag = fields.pop('_etag')
|
||||
task.name = fields.pop('name')
|
||||
task.description = fields.pop('description')
|
||||
task.properties.status = fields.pop('status')
|
||||
|
Reference in New Issue
Block a user