From ac612703fd00db7d8780d9a02e28f89b559a4900 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Wed, 24 Mar 2010 21:42:14 +0100 Subject: [PATCH] Reload calendar after importing events. --- kronolith/data.php | 7 +++++-- kronolith/js/kronolith.js | 19 +++++++++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/kronolith/data.php b/kronolith/data.php index 63943c411..d57392da9 100644 --- a/kronolith/data.php +++ b/kronolith/data.php @@ -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; } diff --git a/kronolith/js/kronolith.js b/kronolith/js/kronolith.js index 655d20836..e3a9c6006 100644 --- a/kronolith/js/kronolith.js +++ b/kronolith/js/kronolith.js @@ -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; -- 2.11.0