diff --git a/src/scripts/tutti/10_tasks.js b/src/scripts/tutti/10_tasks.js index a0b509d..6bdc4e5 100644 --- a/src/scripts/tutti/10_tasks.js +++ b/src/scripts/tutti/10_tasks.js @@ -117,35 +117,46 @@ function shot_create(project_url) } /** - * Adds the task item to the shots/tasks list + * Adds the task item to the shots/tasks list. + * + * 'shot_id' can be undefined if the task isn't attached to a shot. */ function task_add(shot_id, task_id, task_type) { - if (shot_id === undefined || task_id === undefined || task_type === undefined) { + if (task_id === undefined || task_type === undefined) { throw new ReferenceError("task_add(" + shot_id + ", " + task_id + ", " + task_type + ") called."); } var project_url = ProjectUtils.projectUrl(); var url = '/attract/' + project_url + '/tasks/' + task_id; + var context = ProjectUtils.context(); - if (ProjectUtils.context() == 'task'){ + if (context == 'task') { + /* WARNING: This is a copy of an element of attract/tasks/for_project #task-list.col-list + * If that changes, change this too. */ $('#task-list').append('\ - \ \ - New Task\ - none\ + -save your task first-\ + -\ \ '); - } else if (ProjectUtils.context() == 'shot'){ + } else if (context == 'shot') { + if (shot_id === undefined) { + throw new ReferenceError("task_add(" + shot_id + ", " + task_id + ", " + task_type + ") called in shot context."); + } + var $shot_cell = $('#shot-' + shot_id + ' .table-cell.task-type.' + task_type); var url = '/attract/' + project_url + '/shots/with-task/' + task_id; + /* WARNING: This is a copy of an element of attract/shots/for_project #task-list.col-list + * If that changes, change this too. */ $shot_cell.append('\ - \ @@ -177,10 +188,10 @@ function task_create(shot_id, task_type) }; if (has_shot_id) data.parent = shot_id; - $.post(url, data, function(task_data) { + if (console) console.log('Task created:', task_data); task_open(task_data.task_id); - if (has_shot_id) task_add(shot_id, task_data.task_id, task_type); + task_add(shot_id, task_data.task_id, task_type); }) .fail(function(xhr) { if (console) { diff --git a/src/templates/attract/tasks/for_project.jade b/src/templates/attract/tasks/for_project.jade index e2b00e6..2ce4810 100644 --- a/src/templates/attract/tasks/for_project.jade +++ b/src/templates/attract/tasks/for_project.jade @@ -11,7 +11,7 @@ #task-list.col-list | {% for task in tasks %} - //- NOTE: this is tightly linked to the JS in tasks.js. + //- NOTE: this is tightly linked to the JS in tasks.js, function task_add() a.col-list-item.task-list-item( id="task-{{task._id}}", data-task-id="{{task._id}}",