Make tasks appear on the list when added
This commit is contained in:
@@ -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('\
|
||||
<a class="col-list-item task-list-item status-todo task-link"\
|
||||
href="' + url + '"\
|
||||
data-task-id="' + task_id + '"\
|
||||
id="task-' + task_id + '">\
|
||||
<span class="status-indicator"></span>\
|
||||
<span class="name">New Task</span>\
|
||||
<span class="type">none</span>\
|
||||
</a>\
|
||||
');
|
||||
} 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('\
|
||||
<a class="status-todo task-link"\
|
||||
title="New task"\
|
||||
href="' + url + '"\
|
||||
data-task-id="' + task_id + '"\
|
||||
id="task-' + task_id + '">\
|
||||
</a>\
|
||||
');
|
||||
|
||||
$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.
|
||||
|
@@ -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');
|
||||
|
@@ -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 %}
|
||||
|
Reference in New Issue
Block a user