diff --git a/src/scripts/tutti/10_tasks.js b/src/scripts/tutti/10_tasks.js
index 017e4ce..5b37397 100644
--- a/src/scripts/tutti/10_tasks.js
+++ b/src/scripts/tutti/10_tasks.js
@@ -81,6 +81,7 @@ window.onpopstate = function(event)
/**
* Create a task and show it in the #item-details div.
+ * NOTE: Not used at the moment, we're creating shots via Blender's VSE
*/
function shot_create(project_url)
{
@@ -105,14 +106,50 @@ function shot_create(project_url)
});
}
+/**
+ * Adds the task item to the shots/tasks list
+ */
+function task_add(shot_id, task_id, project_url, task_type){
+
+ var url = '/attract/' + project_url + '/tasks/' + task_id;
+
+ if (ProjectUtils.context() == 'task'){
+ $('#task-list').append('\
+ \
+ \
+ New Task\
+ none\
+ \
+ ');
+ } else if (ProjectUtils.context() == 'shot'){
+ var $shot_cell = $('#shot-' + shot_id + ' .table-cell.task-type.' + task_type);
+ var url = '/attract/' + project_url + '/shots/with-task/' + task_id;
+
+ $shot_cell.append('\
+ \
+ \
+ ');
+
+ $shot_cell.find('.task-add.task-add-link').addClass('hidden');
+ }
+}
+
/**
* Create a task and show it in the #item-details div.
*/
function task_create(shot_id, project_url, task_type)
{
- if (shot_id === undefined || project_url === undefined || task_type === undefined) {
- throw new ReferenceError("task_create(" + shot_id + ", " + project_url+ ", " + task_type + ") called.");
+ if (project_url === undefined || task_type === undefined) {
+ throw new ReferenceError("task_create(" + project_url+ ", " + task_type + ") called.");
}
+
var url = '/attract/' + project_url + '/tasks/create';
data = {
@@ -122,6 +159,7 @@ function task_create(shot_id, project_url, task_type)
$.post(url, data, function(task_data) {
task_open(task_data.task_id, project_url);
+ task_add(shot_id, task_data.task_id, project_url, task_type);
})
.fail(function(xhr) {
if (console) {
@@ -129,10 +167,12 @@ function task_create(shot_id, project_url, task_type)
console.log('XHR:', xhr);
}
$('#item-details').html(xhr.responseText);
+ })
+ .done(function(){
+ $('#item-details input[name="name"]').focus();
});
}
-
function attract_form_save(form_id, item_id, item_save_url, options={})
{
// Mandatory option.
diff --git a/src/templates/attract/shots/for_project.jade b/src/templates/attract/shots/for_project.jade
index fcc7c4c..9fb92f1 100644
--- a/src/templates/attract/shots/for_project.jade
+++ b/src/templates/attract/shots/for_project.jade
@@ -106,7 +106,6 @@ script.
$('.table-head ' + same_cells).removeClass('highlight');
});
-
$('.table-head .table-cell').mouseenter(function(){
same_cells = '.' + $(this).attr('class').split(' ').join('.');
$('.table-body ' + same_cells).addClass('highlight');
diff --git a/src/templates/attract/tasks/for_project.jade b/src/templates/attract/tasks/for_project.jade
index e3902c8..51277ad 100644
--- a/src/templates/attract/tasks/for_project.jade
+++ b/src/templates/attract/tasks/for_project.jade
@@ -7,7 +7,7 @@
a(href="") Tasks ({{ tasks | count }})
a.task-project(href="{{url_for('projects.view', project_url=project.url)}}") {{ project.name }}
- a#task-add(href="javascript:task_create('{{ project.url }}');") + Create Task
+ a#task-add(href="javascript:task_create(undefined, '{{ project.url }}', 'None');") + Create Task
#task-list.col-list
| {% for task in tasks %}
@@ -31,7 +31,7 @@
#item-details
#task-view
| {{ tasks | count }} tasks so far.
- a(href="javascript:task_create('{{ project.url }}');") Create a new one!
+ a(href="javascript:task_create(undefined, '{{ project.url }}', 'None');") Create a new one!
| {% endblock %}
| {% block footer_scripts %}