2016-09-23 19:38:57 +02:00
|
|
|
/**
|
2016-11-09 14:57:46 +01:00
|
|
|
* Create a asset and show it in the #item-details div.
|
2016-09-23 19:38:57 +02:00
|
|
|
*/
|
2019-03-13 13:53:40 +01:00
|
|
|
function thenCreateAsset(project_url)
|
2016-09-23 19:38:57 +02:00
|
|
|
{
|
|
|
|
if (project_url === undefined) {
|
2016-11-09 14:57:46 +01:00
|
|
|
throw new ReferenceError("asset_create(" + project_url+ ") called.");
|
2016-09-23 19:38:57 +02:00
|
|
|
}
|
2016-11-09 14:57:46 +01:00
|
|
|
var url = '/attract/' + project_url + '/assets/create';
|
2016-09-23 19:38:57 +02:00
|
|
|
|
|
|
|
data = {
|
|
|
|
project_url: project_url
|
|
|
|
};
|
|
|
|
|
2019-03-13 13:53:40 +01:00
|
|
|
return $.post(url, data, function(asset_data) {
|
2019-02-12 09:08:37 +01:00
|
|
|
pillar.events.Nodes.triggerCreated(asset_data);
|
2019-03-13 13:53:40 +01:00
|
|
|
return asset_data;
|
2016-09-23 19:38:57 +02:00
|
|
|
})
|
|
|
|
.fail(function(xhr) {
|
|
|
|
if (console) {
|
2016-11-09 14:57:46 +01:00
|
|
|
console.log('Error creating asset');
|
2016-09-23 19:38:57 +02:00
|
|
|
console.log('XHR:', xhr);
|
|
|
|
}
|
|
|
|
$('#item-details').html(xhr.responseText);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-09-29 15:36:02 +02:00
|
|
|
|
2016-09-21 19:39:56 +02:00
|
|
|
/**
|
2016-09-23 14:53:03 +02:00
|
|
|
* Create a task and show it in the #item-details div.
|
2016-10-04 15:21:59 +02:00
|
|
|
*
|
|
|
|
* 'shot_id' may be undefined, in which case the task will not
|
|
|
|
* be attached to a shot.
|
2016-09-21 19:39:56 +02:00
|
|
|
*/
|
2019-03-13 13:53:40 +01:00
|
|
|
function thenCreateTask(shot_id, task_type)
|
2016-09-23 14:53:03 +02:00
|
|
|
{
|
2016-10-04 15:21:59 +02:00
|
|
|
if (task_type === undefined) {
|
2016-10-04 14:37:39 +02:00
|
|
|
throw new ReferenceError("task_create(" + shot_id + ", " + task_type + ") called.");
|
2016-09-22 09:27:28 +02:00
|
|
|
}
|
2016-09-29 15:36:02 +02:00
|
|
|
|
2016-10-04 14:37:39 +02:00
|
|
|
var project_url = ProjectUtils.projectUrl();
|
2016-09-22 10:34:51 +02:00
|
|
|
var url = '/attract/' + project_url + '/tasks/create';
|
2016-10-04 15:21:59 +02:00
|
|
|
var has_shot_id = typeof shot_id !== 'undefined';
|
2016-09-21 19:39:56 +02:00
|
|
|
|
2016-09-22 10:34:51 +02:00
|
|
|
data = {
|
|
|
|
task_type: task_type,
|
|
|
|
};
|
2016-10-04 15:21:59 +02:00
|
|
|
if (has_shot_id) data.parent = shot_id;
|
|
|
|
|
2019-03-13 13:53:40 +01:00
|
|
|
return $.post(url, data, function(task_data) {
|
2016-10-04 15:35:42 +02:00
|
|
|
if (console) console.log('Task created:', task_data);
|
2019-02-12 09:08:37 +01:00
|
|
|
pillar.events.Nodes.triggerCreated(task_data);
|
2019-03-13 13:53:40 +01:00
|
|
|
return task_data;
|
2016-09-21 19:39:56 +02:00
|
|
|
})
|
|
|
|
.fail(function(xhr) {
|
|
|
|
if (console) {
|
|
|
|
console.log('Error creating task');
|
|
|
|
console.log('XHR:', xhr);
|
|
|
|
}
|
2016-09-23 14:53:03 +02:00
|
|
|
$('#item-details').html(xhr.responseText);
|
2016-09-23 13:58:14 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2016-11-09 15:26:11 +01:00
|
|
|
var save_on_ctrl_enter = ['shot', 'asset', 'task'];
|
2016-10-20 15:33:44 +02:00
|
|
|
$(document).on('keyup', function(e){
|
2017-02-14 15:57:08 +01:00
|
|
|
if ($.inArray(save_on_ctrl_enter, ProjectUtils.context())) {
|
|
|
|
var active = document.activeElement;
|
|
|
|
|
|
|
|
// Save on Ctrl + Enter anytime except when comment field is on focus
|
|
|
|
if (active.id != 'comment_field'){
|
2016-11-03 15:07:49 +01:00
|
|
|
if ((e.keyCode == 10 || e.keyCode == 13) && e.ctrlKey){
|
|
|
|
$("#item-save").trigger( "click" );
|
|
|
|
}
|
|
|
|
}
|
2016-10-20 15:33:44 +02:00
|
|
|
}
|
|
|
|
});
|