diff --git a/src/scripts/tutti/10_tasks.js b/src/scripts/tutti/10_tasks.js index fe0a2bc..77a2ab3 100644 --- a/src/scripts/tutti/10_tasks.js +++ b/src/scripts/tutti/10_tasks.js @@ -45,17 +45,19 @@ function item_open(item_id, item_type, pushState, project_url) } item_url += '?context=' + ProjectUtils.context(); - $('#status-bar').text('Loading ' + item_type + '…'); + statusBarSet('default', 'Loading ' + item_type + '…'); $.get(item_url, function(item_data) { - $('#status-bar').text(''); + statusBarClear(); $('#item-details').html(item_data); }).fail(function(xhr) { if (console) { console.log('Error fetching task', item_id, 'from', item_url); console.log('XHR:', xhr); } - $('#status-bar').text('Opening ' + item_type + ' failed.'); + + statusBarSet('error', 'Failed to open ' + item_type, 'pi-warning'); + if (xhr.status) { $('#item-details').html(xhr.responseText); } else { @@ -233,15 +235,17 @@ function attract_form_save(form_id, item_id, item_save_url, options) $button.attr('disabled', true); $item.addClass('processing'); - $('#status-bar').text('Saving ' + options.type + '...'); + + statusBarSet('', 'Saving ' + options.type + '…'); if (console) console.log('Sending:', payload); $.post(item_save_url, payload) .done(function(saved_item) { if (console) console.log('Done saving', saved_item); - $('#status-bar') - .text('Saved ' + options.type + '. ' + saved_item._updated); + + statusBarSet('success', 'Saved ' + options.type + '. ' + saved_item._updated, 'pi-check'); + $form.find("input[name='_etag']").val(saved_item._etag); if (options.done) options.done($item, saved_item); @@ -251,7 +255,8 @@ function attract_form_save(form_id, item_id, item_save_url, options) if (console) console.log('Failed saving', options.type, xhr_or_response_data); $button.removeClass('btn-default').addClass('btn-danger'); - $('#status-bar').text('Failed saving. ' + xhr_or_response_data.status); + + statusBarSet('error', 'Failed saving. ' + xhr_or_response_data.status, 'pi-warning'); if (options.fail) options.fail($item, xhr_or_response_data); }) @@ -338,7 +343,9 @@ function task_delete(task_id, task_etag, task_delete_url) { _remove_task_from_list(task_id); }) .fail(function(xhr) { - $('#status-bar').text('Unable to delete task, code ' + xhr.status); + + statusBarSet('error', 'Unable to delete task, code ' + xhr.status, 'pi-warning'); + if (xhr.status == 412) { alert('Someone else edited this task before you deleted it; refresh to try again.'); // TODO: implement something nice here. Just make sure we don't throw @@ -364,7 +371,9 @@ function load_activities(url) console.log('Error fetching activities'); console.log('XHR:', xhr); } - $('#status-bar').text('Opening activity log failed.'); + + statusBarSet('error', 'Opening activity log failed.', 'pi-warning'); + if (xhr.status) { $('#activities').html(xhr.responseText); } else {