summaryrefslogtreecommitdiffstats
path: root/apps/tasks
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2012-04-17 17:32:21 +0200
committerBart Visscher <bartv@thisnet.nl>2012-04-17 17:32:21 +0200
commit6ba30cb713b4abd0500fb692f6227284f620e74a (patch)
tree55985bae41445fa04ebc91518ddcee4e9d6b81b2 /apps/tasks
parent8afeb0fedbeadfee7beca9997817cb75eff6e29f (diff)
downloadnextcloud-server-6ba30cb713b4abd0500fb692f6227284f620e74a.tar.gz
nextcloud-server-6ba30cb713b4abd0500fb692f6227284f620e74a.zip
Tasks: Clicking task summary opens input for edit
Diffstat (limited to 'apps/tasks')
-rw-r--r--apps/tasks/ajax/update_property.php (renamed from apps/tasks/ajax/complete.php)16
-rw-r--r--apps/tasks/js/tasks.js59
2 files changed, 47 insertions, 28 deletions
diff --git a/apps/tasks/ajax/complete.php b/apps/tasks/ajax/update_property.php
index 22c65c0bc83..1916a2eb7b1 100644
--- a/apps/tasks/ajax/complete.php
+++ b/apps/tasks/ajax/update_property.php
@@ -12,11 +12,23 @@ OC_JSON::checkLoggedIn();
OC_JSON::checkAppEnabled('tasks');
$id = $_POST['id'];
-$checked = $_POST['checked'];
+$property = $_POST['type'];
$vcalendar = OC_Calendar_App::getVCalendar( $id );
$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());
$user_timezone = OC_Preferences::getValue(OC_USER::getUser(), 'calendar', 'timezone', date_default_timezone_get());
diff --git a/apps/tasks/js/tasks.js b/apps/tasks/js/tasks.js
index fac1708b5ee..c6b99ac408d 100644
--- a/apps/tasks/js/tasks.js
+++ b/apps/tasks/js/tasks.js
@@ -12,18 +12,20 @@ OC.Tasks = {
return a.localeCompare(b);
},
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>')
.addClass('task')
.data('task', task)
.data('show_count', 0)
.attr('data-id', task.id)
- .append($('<p>')
- .html('<a href="index.php?id='+task.id+'">'+task.summary+'</a>')
- .addClass('summary')
- .attr('title', task.description)
- )
+ .append(summary_container)
//.append(actions.clone().removeAttr('id'))
;
+ task_container.find('.summary a').click(OC.Tasks.summaryClickHandler);
var checkbox = $('<input type="checkbox">')
.click(OC.Tasks.complete_task);
if (task.completed) {
@@ -121,11 +123,36 @@ OC.Tasks = {
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() {
var $task = $(this).closest('.task'),
task = $task.data('task'),
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') {
task = jsondata.data;
$task.data('task', task)
@@ -163,7 +190,6 @@ $(document).ready(function(){
*-----------------------------------------------------------------------*/
$.getJSON(OC.filePath('tasks', 'ajax', 'gettasks.php'), function(jsondata) {
var tasks = $('#tasks_list').empty().data('show_count', 0);
- var actions = $('#task_actions_template');
$(jsondata).each(function(i, task) {
tasks.append(OC.Tasks.create_task_div(task));
});
@@ -188,25 +214,6 @@ $(document).ready(function(){
/*-------------------------------------------------------------------------
* 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(){
OC.Tasks.filter(this, 'div.categories .tag');
var tag_text = $(this).text();