Reload calendar after importing events.
authorJan Schneider <jan@horde.org>
Wed, 24 Mar 2010 20:42:14 +0000 (21:42 +0100)
committerJan Schneider <jan@horde.org>
Wed, 24 Mar 2010 20:42:14 +0000 (21:42 +0100)
kronolith/data.php
kronolith/js/kronolith.js

index 63943c4..d57392d 100644 (file)
@@ -292,6 +292,9 @@ if (is_array($next_step)) {
     if (!$error) {
         $notification->push(sprintf(_("%s file successfully imported"),
                                     $file_types[$_SESSION['import_data']['format']]), 'horde.success');
+        if (Horde_Util::getFormData('import_ajax')) {
+            Horde::addInlineScript('window.parent.KronolithCore.loadCalendar(\'internal\', \'' . $_SESSION['import_data']['import_cal'] . '\');');
+        }
     }
     $next_step = $data->cleanup();
 }
@@ -300,9 +303,9 @@ if (Horde_Util::getFormData('import_ajax')) {
     $stack = $notification->notify(array('listeners' => 'status', 'raw' => true));
     if ($stack) {
         Horde::addInlineScript('window.parent.KronolithCore.showNotifications(window.parent.$A(' . Horde_Serialize::serialize($stack, Horde_Serialize::JSON, Horde_Nls::getCharset()) . '));');
-        Horde::addInlineScript('window.parent.$(window.name).remove();');
-        Horde::outputInlineScript();
     }
+    Horde::addInlineScript('window.parent.$(window.name).remove();');
+    Horde::outputInlineScript();
     exit;
 }
 
index 655d208..e3a9c60 100644 (file)
@@ -1028,6 +1028,22 @@ KronolithCore = {
     },
 
     /**
+     * Loads a certain calendar, if the current view is still a calendar view.
+     *
+     * @param string type      The calendar type.
+     * @param string calendar  The calendar id.
+     */
+    loadCalendar: function(type, calendar)
+    {
+        if (Kronolith.conf.calendars[type][calendar].show &&
+            $w('day week month year').include(this.view)) {
+            var dates = this.viewDates(this.date, this.view);
+            this.deleteCache(null, [type, calendar]);
+            this.loadEvents(dates[0], dates[1], this.view, [[type, calendar]]);
+        }
+    },
+
+    /**
      * Toggles a calendars visibility.
      *
      * @param string type      The calendar type.
@@ -1039,8 +1055,7 @@ KronolithCore = {
             if (this.view == 'year' ||
                 Object.isUndefined(this.ecache.get(type)) ||
                 Object.isUndefined(this.ecache.get(type).get(calendar))) {
-                var dates = this.viewDates(this.date, this.view);
-                this.loadEvents(dates[0], dates[1], this.view, [[type, calendar]]);
+                this.loadCalendar(type, calendar);
             } else {
                 $('kronolithBody').select('div').findAll(function(el) {
                     return el.retrieve('calendar') == type + '|' + calendar;