Show 'No items' in empty agenda and task lists.
authorJan Schneider <jan@horde.org>
Mon, 30 Nov 2009 18:47:36 +0000 (19:47 +0100)
committerJan Schneider <jan@horde.org>
Mon, 30 Nov 2009 18:50:32 +0000 (19:50 +0100)
kronolith/js/kronolith.js
kronolith/templates/index/agenda.inc
kronolith/templates/index/tasks.inc

index d8f657e..1b41f24 100644 (file)
@@ -519,7 +519,8 @@ KronolithCore = {
             // Remove old rows. Maybe we should only rebuild the calendars if
             // necessary.
             tbody = $('kronolithViewAgendaBody').childElements().each(function(row) {
-                if (row.identify() != 'kronolithAgendaTemplate') {
+                if (row.identify() != 'kronolithAgendaTemplate' &&
+                    row.identify() != 'kronolithAgendaNoItems') {
                     row.remove();
                 }
             });
@@ -1147,7 +1148,16 @@ KronolithCore = {
                 this._insertEvent(event, date, view);
             }, this);
 
-            if (view == 'year') {
+            switch (view) {
+            case 'agenda':
+                if ($('kronolithViewAgendaBody').select('tr').length > 2) {
+                    $('kronolithAgendaNoItems').hide();
+                } else {
+                    $('kronolithAgendaNoItems').show();
+                }
+                break;
+
+            case 'year':
                 td = $('kronolithYear' + date);
                 td.className = '';
                 if (title) {
@@ -1719,6 +1729,12 @@ KronolithCore = {
                 this._insertTask(task);
             }, this);
         }, this);
+
+        if ($('kronolithViewTasksBody').select('tr').length > 3) {
+            $('kronolithTasksNoItems').hide();
+        } else {
+            $('kronolithTasksNoItems').show();
+        }
     },
 
     /**
@@ -1767,7 +1783,7 @@ KronolithCore = {
     {
         var rows = $('kronolithViewTasksBody').select('tr');
         // The first row is the add task row, the second a template, ignoring.
-        for (var i = 2; i < rows.length; i++) {
+        for (var i = 3; i < rows.length; i++) {
             var rowTasklist = rows[i].retrieve('tasklist');
             var rowTaskId = rows[i].retrieve('taskid');
             var rowTask = this.tcache.inject(null, function(acc, list) {
index 3ff126d..82aee47 100644 (file)
       <td>
       </td>
     </tr>
+    <tr id="kronolithAgendaNoItems" style="display:none">
+      <td colspan="2">
+        <?php echo _("No items") ?>
+      </td>
+    </tr>
   </tbody>
 </table>
 </div>
index 40ccdbf..b78e77c 100644 (file)
         <div class="kronolithTaskCheckbox"/>
       </td>
     </tr>
+    <tr id="kronolithTasksNoItems" class="kronolithTaskRow" style="display:none">
+      <td class="kronolithTaskCol">
+        <?php echo _("No items") ?>
+      </td>
+    </tr>
   </tbody>
 </table>
 </div>