Re-enable inactive task forms.
authorJan Schneider <jan@horde.org>
Fri, 12 Feb 2010 10:49:56 +0000 (11:49 +0100)
committerJan Schneider <jan@horde.org>
Fri, 12 Feb 2010 10:49:56 +0000 (11:49 +0100)
Create task cache when adding a first task.
Show "no items" initially when no tasks exist from the start.
Catch edge case when to-be-deleted tasks don't exist anymore.

kronolith/js/kronolith.js
kronolith/templates/index/tasks.inc

index 77510fb..ac70ce2 100644 (file)
@@ -1563,9 +1563,11 @@ KronolithCore = {
         }
 
         tasktypes.each(function(type) {
+            if (Object.isUndefined(this.tcache.get(type))) {
+                this._storeTasksCache($H(), type, null, true);
+            }
             tasklists.each(function(list) {
-                if (Object.isUndefined(this.tcache.get(type)) ||
-                    Object.isUndefined(this.tcache.get(type).get(list))) {
+                if (Object.isUndefined(this.tcache.get(type).get(list))) {
                     loading = true;
                     this.startLoading('tasks:' + type + list, tasktype);
                     this._storeTasksCache($H(), type, list, true);
@@ -1840,6 +1842,8 @@ KronolithCore = {
             $('kronolithTaskPriority').setValue(3);
             $('kronolithTaskCompleted').setValue(0);
             $('kronolithTaskDelete').hide();
+            $('kronolithTaskSave').show();
+            $('kronolithTaskForm').enable();
             RedBox.showHtml($('kronolithTaskDialog').show());
         }
     },
@@ -2284,6 +2288,9 @@ KronolithCore = {
                     return;
                 }
             }
+            if (!tasklist) {
+                return;
+            }
             if (!this.tcache.get(tasktype).get(tasklist)) {
                 if (createCache) {
                     this.tcache.get(tasktype).set(tasklist, $H());
@@ -2607,10 +2614,13 @@ KronolithCore = {
                                       }).toggle();
                                   }
                               }.bind(this));
-                $('kronolithViewTasksBody').select('tr').find(function(el) {
+                var taskrow = $('kronolithViewTasksBody').select('tr').find(function(el) {
                     return el.retrieve('tasklist') == tasklist &&
                         el.retrieve('taskid') == taskid;
-                }).hide();
+                });
+                if (taskrow) {
+                    taskrow.hide();
+                }
                 this._closeRedBox();
                 window.history.back();
                 e.stop();
index 53cdb37..00f6bd2 100644 (file)
@@ -21,7 +21,7 @@
         <div class="kronolithTaskCheckbox"/>
       </td>
     </tr>
-    <tr id="kronolithTasksNoItems" class="kronolithTaskRow" style="display:none">
+    <tr id="kronolithTasksNoItems" class="kronolithTaskRow">
       <td class="kronolithTaskCol">
         <?php echo _("No items") ?>
       </td>