Tasks: Clicking task summary opens input for edit
This commit is contained in:
parent
8afeb0fedb
commit
6ba30cb713
2 changed files with 47 additions and 28 deletions
|
@ -12,11 +12,23 @@ OC_JSON::checkLoggedIn();
|
||||||
OC_JSON::checkAppEnabled('tasks');
|
OC_JSON::checkAppEnabled('tasks');
|
||||||
|
|
||||||
$id = $_POST['id'];
|
$id = $_POST['id'];
|
||||||
$checked = $_POST['checked'];
|
$property = $_POST['type'];
|
||||||
$vcalendar = OC_Calendar_App::getVCalendar( $id );
|
$vcalendar = OC_Calendar_App::getVCalendar( $id );
|
||||||
|
|
||||||
$vtodo = $vcalendar->VTODO;
|
$vtodo = $vcalendar->VTODO;
|
||||||
OC_Task_App::setComplete($vtodo, $checked ? '100' : '0', null);
|
switch($property) {
|
||||||
|
case 'summary':
|
||||||
|
$summary = $_POST['summary'];
|
||||||
|
$vtodo->setString('SUMMARY', $summary);
|
||||||
|
break;
|
||||||
|
case 'complete':
|
||||||
|
$checked = $_POST['checked'];
|
||||||
|
OC_Task_App::setComplete($vtodo, $checked ? '100' : '0', null);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
OC_JSON::error(array('data'=>array('message'=>'Unknown type')));
|
||||||
|
exit();
|
||||||
|
}
|
||||||
OC_Calendar_Object::edit($id, $vcalendar->serialize());
|
OC_Calendar_Object::edit($id, $vcalendar->serialize());
|
||||||
|
|
||||||
$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get());
|
$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get());
|
|
@ -12,18 +12,20 @@ OC.Tasks = {
|
||||||
return a.localeCompare(b);
|
return a.localeCompare(b);
|
||||||
},
|
},
|
||||||
create_task_div:function(task) {
|
create_task_div:function(task) {
|
||||||
|
var actions = $('#task_actions_template');
|
||||||
|
var summary_container = $('<p class="summary">')
|
||||||
|
.attr('title', task.description)
|
||||||
|
;
|
||||||
|
OC.Tasks.setSummary(summary_container, task);
|
||||||
var task_container = $('<div>')
|
var task_container = $('<div>')
|
||||||
.addClass('task')
|
.addClass('task')
|
||||||
.data('task', task)
|
.data('task', task)
|
||||||
.data('show_count', 0)
|
.data('show_count', 0)
|
||||||
.attr('data-id', task.id)
|
.attr('data-id', task.id)
|
||||||
.append($('<p>')
|
.append(summary_container)
|
||||||
.html('<a href="index.php?id='+task.id+'">'+task.summary+'</a>')
|
|
||||||
.addClass('summary')
|
|
||||||
.attr('title', task.description)
|
|
||||||
)
|
|
||||||
//.append(actions.clone().removeAttr('id'))
|
//.append(actions.clone().removeAttr('id'))
|
||||||
;
|
;
|
||||||
|
task_container.find('.summary a').click(OC.Tasks.summaryClickHandler);
|
||||||
var checkbox = $('<input type="checkbox">')
|
var checkbox = $('<input type="checkbox">')
|
||||||
.click(OC.Tasks.complete_task);
|
.click(OC.Tasks.complete_task);
|
||||||
if (task.completed) {
|
if (task.completed) {
|
||||||
|
@ -121,11 +123,36 @@ OC.Tasks = {
|
||||||
container.append(this);
|
container.append(this);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
setSummary:function(summary_container, task){
|
||||||
|
var summary = $('<a href="index.php?id='+task.id+'">'+task.summary+'</a>')
|
||||||
|
.click(OC.Tasks.summaryClickHandler);
|
||||||
|
summary_container.html(summary);
|
||||||
|
},
|
||||||
|
summaryClickHandler:function(event){
|
||||||
|
event.preventDefault();
|
||||||
|
//event.stopPropagation();
|
||||||
|
var task = $(this).closest('.task').data('task');
|
||||||
|
var summary_container = $(this).parent();
|
||||||
|
var input = $('<input>').val($(this).text()).blur(function(){
|
||||||
|
var old_summary = task.summary;
|
||||||
|
task.summary = $(this).val();
|
||||||
|
OC.Tasks.setSummary(summary_container, task);
|
||||||
|
$.post('ajax/update_property.php', {id:task.id, type:'summary', summary:task.summary}, function(jsondata){
|
||||||
|
if(jsondata.status != 'success') {
|
||||||
|
task.summary = old_summary;
|
||||||
|
OC.Tasks.setSummary(summary_container, task);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
summary_container.empty().append(input);
|
||||||
|
input.focus();
|
||||||
|
return false;
|
||||||
|
},
|
||||||
complete_task:function() {
|
complete_task:function() {
|
||||||
var $task = $(this).closest('.task'),
|
var $task = $(this).closest('.task'),
|
||||||
task = $task.data('task'),
|
task = $task.data('task'),
|
||||||
checked = $(this).is(':checked');
|
checked = $(this).is(':checked');
|
||||||
$.post('ajax/complete.php', {id:task.id, checked:checked?1:0}, function(jsondata){
|
$.post('ajax/update_property.php', {id:task.id, type:'complete', checked:checked?1:0}, function(jsondata){
|
||||||
if(jsondata.status == 'success') {
|
if(jsondata.status == 'success') {
|
||||||
task = jsondata.data;
|
task = jsondata.data;
|
||||||
$task.data('task', task)
|
$task.data('task', task)
|
||||||
|
@ -163,7 +190,6 @@ $(document).ready(function(){
|
||||||
*-----------------------------------------------------------------------*/
|
*-----------------------------------------------------------------------*/
|
||||||
$.getJSON(OC.filePath('tasks', 'ajax', 'gettasks.php'), function(jsondata) {
|
$.getJSON(OC.filePath('tasks', 'ajax', 'gettasks.php'), function(jsondata) {
|
||||||
var tasks = $('#tasks_list').empty().data('show_count', 0);
|
var tasks = $('#tasks_list').empty().data('show_count', 0);
|
||||||
var actions = $('#task_actions_template');
|
|
||||||
$(jsondata).each(function(i, task) {
|
$(jsondata).each(function(i, task) {
|
||||||
tasks.append(OC.Tasks.create_task_div(task));
|
tasks.append(OC.Tasks.create_task_div(task));
|
||||||
});
|
});
|
||||||
|
@ -188,25 +214,6 @@ $(document).ready(function(){
|
||||||
/*-------------------------------------------------------------------------
|
/*-------------------------------------------------------------------------
|
||||||
* Event handlers
|
* Event handlers
|
||||||
*-----------------------------------------------------------------------*/
|
*-----------------------------------------------------------------------*/
|
||||||
$('#tasks div.task .summary').live('click',function(){
|
|
||||||
var id = $(this).parent('div.task').data('id');
|
|
||||||
var oldid = $('#task_details').data('id');
|
|
||||||
if(oldid != 0){
|
|
||||||
$('#tasks li[data-id="'+oldid+'"]').removeClass('active');
|
|
||||||
}
|
|
||||||
$.getJSON('ajax/getdetails.php',{'id':id},function(jsondata){
|
|
||||||
if(jsondata.status == 'success'){
|
|
||||||
$('#task_details').data('id',jsondata.data.id);
|
|
||||||
$('#task_details').html(jsondata.data.page);
|
|
||||||
$('#tasks li[data-id="'+jsondata.data.id+'"]').addClass('active');
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
alert(jsondata.data.message);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
|
|
||||||
$('#tasks div.categories .tag').live('click',function(){
|
$('#tasks div.categories .tag').live('click',function(){
|
||||||
OC.Tasks.filter(this, 'div.categories .tag');
|
OC.Tasks.filter(this, 'div.categories .tag');
|
||||||
var tag_text = $(this).text();
|
var tag_text = $(this).text();
|
||||||
|
|
Loading…
Reference in a new issue