Some task creation fixes

This commit is contained in:
2016-10-04 15:21:59 +02:00
parent de72e6c471
commit 2fd7ae7927
3 changed files with 10 additions and 5 deletions

View File

@@ -158,24 +158,29 @@ function task_add(shot_id, task_id, task_type)
/**
* Create a task and show it in the #item-details div.
*
* 'shot_id' may be undefined, in which case the task will not
* be attached to a shot.
*/
function task_create(shot_id, task_type)
{
if (shot_id === undefined || task_type === undefined) {
if (task_type === undefined) {
throw new ReferenceError("task_create(" + shot_id + ", " + task_type + ") called.");
}
var project_url = ProjectUtils.projectUrl();
var url = '/attract/' + project_url + '/tasks/create';
var has_shot_id = typeof shot_id !== 'undefined';
data = {
task_type: task_type,
parent: shot_id,
};
if (has_shot_id) data.parent = shot_id;
$.post(url, data, function(task_data) {
task_open(task_data.task_id);
task_add(shot_id, task_data.task_id, task_type);
if (has_shot_id) task_add(shot_id, task_data.task_id, task_type);
})
.fail(function(xhr) {
if (console) {

View File

@@ -56,7 +56,7 @@
a.task-add(
title="Add a new '{{ task_type }}' task",
class="task-add-link {% if tasks_for_shots[shot._id][task_type] %}hidden{% endif %}"
href="javascript:task_create('{{ shot._id }}', '{{ project.url }}', '{{ task_type }}');")
href="javascript:task_create('{{ shot._id }}', '{{ task_type }}');")
| + Task
| {% endfor %}
| {% endfor %}

View File

@@ -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(undefined, '{{ project.url }}', 'None');") + Create Task
a#task-add(href="javascript:task_create(undefined, 'generic');") + Create Task
#task-list.col-list
| {% for task in tasks %}