Fix updating tasks if editing from a calendar view.
authorJan Schneider <jan@horde.org>
Sat, 12 Jun 2010 18:41:01 +0000 (20:41 +0200)
committerJan Schneider <jan@horde.org>
Sat, 12 Jun 2010 18:41:01 +0000 (20:41 +0200)
kronolith/js/kronolith.js
kronolith/lib/Ajax/Application.php

index ccfcfa1..c248a8c 100644 (file)
@@ -2582,6 +2582,7 @@ KronolithCore = {
             return el.retrieve('tasklist') == list &&
                 el.retrieve('taskid') == task;
         }).invoke('remove');
+        this.removeEvent('_tasks' + task, 'tasklists|tasks/' + list);
     },
 
     /**
@@ -2595,19 +2596,30 @@ KronolithCore = {
         }
 
         var tasklist = $F('kronolithTaskOldList'),
-            taskid = $F('kronolithTaskId');
+            target = $F('kronolithTaskList'),
+            taskid = $F('kronolithTaskId'),
+            viewDates = this.viewDates(this.date, this.view),
+            start = viewDates[0].dateString(),
+            end = viewDates[1].dateString();
 
         $('kronolithTaskSave').disable();
+        this.startLoading('tasklists|tasks/' + target, start + end);
         this.loading++;
         $('kronolithLoading').show();
         this.doAction('saveTask',
                       $H($('kronolithTaskForm').serialize({ hash: true }))
-                          .merge({ sig: this.tasktype }),
+                          .merge({
+                              sig: this.tasktype,
+                              view: this.view,
+                              view_start: start,
+                              view_end: end
+                          }),
                       function(r) {
                           if (r.response.tasks && taskid) {
                               this.removeTask(taskid, tasklist);
                           }
                           this.loadTasksCallback(r, false);
+                          this.loadEventsCallback(r, false);
                           if (r.response.tasks) {
                               this.closeRedBox();
                               window.history.back();
index 6e015e8..910eadf 100644 (file)
@@ -463,7 +463,7 @@ class Kronolith_Ajax_Application extends Horde_Ajax_Application_Base
         }
         unset($task['alarm_methods']);
 
-        $result = new stdClass;
+        $result = $this->_signedResponse('tasklists|tasks/' . $task['tasklist']);
         try {
             $ids = ($id && $list)
                 ? $GLOBALS['registry']->tasks->updateTask($list, $id, $task)
@@ -477,6 +477,26 @@ class Kronolith_Ajax_Application extends Horde_Ajax_Application_Base
             $result->list = $task->tasklist;
         } catch (Exception $e) {
             $GLOBALS['notification']->push($e, 'horde.error');
+            return $result;
+        }
+
+        if ($kronolith_driver = $this->_getDriver('tasklists|tasks/' . $task->tasklist)) {
+            try {
+                $event = $kronolith_driver->getEvent('_tasks' . $id);
+                $end = new Horde_Date($this->_vars->view_end);
+                $end->hour = 23;
+                $end->min = $end->sec = 59;
+                Kronolith::addEvents($events, $event,
+                                     new Horde_Date($this->_vars->view_start),
+                                     $end, true, true);
+                if (count($events)) {
+                    $result->events = $events;
+                }
+            } catch (Horde_Exception_NotFound $e) {
+                $GLOBALS['notification']->push(_("The requested event was not found."), 'horde.error');
+            } catch (Exception $e) {
+                $GLOBALS['notification']->push($e, 'horde.error');
+            }
         }
 
         return $result;