diff --git a/attract/static/js/tasks.js b/attract/static/js/tasks.js index fc9f753..bd2283f 100644 --- a/attract/static/js/tasks.js +++ b/attract/static/js/tasks.js @@ -36,8 +36,7 @@ */ function task_open(task_id, project_url) { if (task_id === undefined || project_url === undefined) { - if (console) console.log("task_open(", task_id, project_url, ") called."); - return; + throw new ReferenceError("task_open(" + task_id + ", " + project_url + ") called."); } $('#col_right .col_header span.header_text').text('Task details'); @@ -63,8 +62,7 @@ function task_open(task_id, project_url) { */ function shot_open(shot_id, project_url) { if (shot_id === undefined || project_url === undefined) { - if (console) console.log("shot_open(", shot_id, project_url, ") called."); - return; + throw new ReferenceError("shot_open(" + shot_id + ", " + project_url + ") called."); } $('#col_right .col_header span.header_text').text('Shot details'); @@ -91,8 +89,7 @@ function shot_open(shot_id, project_url) { */ function task_create(shot_id, project_url, task_type) { if (shot_id === undefined || project_url === undefined || task_type === undefined) { - if (console) console.log("task_create(", shot_id, project_url, task_type, ") called."); - return; + throw "task_create(" + shot_id + ", " + project_url+ ", " + task_type + ") called."; } var url = '/attract/' + project_url + '/tasks/create'; @@ -116,6 +113,11 @@ function task_create(shot_id, project_url, task_type) { function attract_form_save(form_id, item_id, item_save_url, options={}) { + // Mandatory option. + if (typeof options.type === 'undefined') { + throw 'attract_form_save(): options.type is mandatory.'; + } + var $form = $('#' + form_id); var $button = $form.find("button[type='submit']"); @@ -139,7 +141,7 @@ function attract_form_save(form_id, item_id, item_save_url, options={}) }) .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); + 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);