Fix toggling tasks.
authorGonçalo Queirós <mail@goncaloqueiros.net>
Mon, 3 Aug 2009 09:23:35 +0000 (11:23 +0200)
committerJan Schneider <jan@horde.org>
Mon, 3 Aug 2009 09:24:34 +0000 (11:24 +0200)
kronolith/js/kronolith.js
nag/lib/api.php

index 3e5126b..0201581 100644 (file)
@@ -1458,12 +1458,12 @@ KronolithCore = {
      */
     _toggleCompletionClass: function(taskId)
     {
-        var row = $(taskId);
-        if (row.length == 0) {
+        var row = $$('tr[taskId=' + taskId + ']');
+        if (row.length != 1) {
             // FIXME: Show some error?
             return;
         }
-        var col = row.down('td.kronolithTaskCol', 0), div = col.down('div.kronolithTaskCheckbox', 0);
+        var col = row[0].down('td.kronolithTaskCol', 0), div = col.down('div.kronolithTaskCheckbox', 0);
 
         col.toggleClassName('kronolithTask');
         col.toggleClassName('kronolithTaskCompleted');
@@ -1943,7 +1943,7 @@ KronolithCore = {
                 e.stop();
                 return;
             } else if (elt.hasClassName('kronolithTaskCheckbox')) {
-                var taskId = elt.up('tr.kronolithTaskRow', 0).readAttribute('id'),
+                var taskId = elt.up('tr.kronolithTaskRow', 0).readAttribute('taskId'),
                     taskList = elt.up('tr.kronolithTaskRow', 0).readAttribute('tasklist');
                 this._toggleCompletionClass(taskId);
                 this.doAction('ToggleCompletion',
@@ -1981,7 +1981,7 @@ KronolithCore = {
                 if (calClass == 'remote' || calClass == 'external') {
                     if (calClass == 'external' && calendar.startsWith('tasks/')) {
                         var taskList = calendar.substr(6);
-                        if (typeof this.tcache.get(taskList) == 'undefined' &&
+                        if (Object.isUndefined(this.tcache.get(taskList)) &&
                             this.view == 'tasks') {
                             this._loadTasks(this.taskType,[taskList]);
                         } else {
index 8bfb04c..8950d7c 100644 (file)
@@ -116,7 +116,7 @@ $_services['listTimeObjects'] = array(
     'type' => '{urn:horde}hashHash'
 );
 
-$_services['completeTask'] = array(
+$_services['toggleCompletion'] = array(
     'args' => array('task_id' => 'string', 'tasklist_id' => 'string'),
     'type' => 'boolean'
 );
@@ -1079,6 +1079,10 @@ function _nag_toggleCompletion($task_id, $tasklist_id)
     }
 
     $task = Nag::getTask($tasklist_id, $task_id);
+    if (is_a($task, 'PEAR_Error')) {
+        return $task;
+    }
+
     $task->completed = !$task->completed;
     if ($task->completed) {
         $task->completed_date = time();