Fix bug 482110 - calendar stays hidden after adding event to it; new event not visible (regression). r=decathlon
authorPhilipp Kewisch <mozilla@kewis.ch>
Tue, 26 Jul 2011 16:40:17 +0200
changeset 8188 7dbc9c5c2b4159a25da8f92eca10a5409168ed71
parent 8187 59230f04d91cc7542f90a7cf9547d3629e967207
child 8189 fcd97e93cea62ea2d8c16ed91ebff3418dced77b
push id6295
push usermozilla@kewis.ch
push dateTue, 26 Jul 2011 14:40:36 +0000
treeherdercomm-central@7dbc9c5c2b41 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdecathlon
bugs482110
Fix bug 482110 - calendar stays hidden after adding event to it; new event not visible (regression). r=decathlon
calendar/base/content/calendar-item-editing.js
calendar/base/content/calendar-management.js
calendar/base/content/calendar-views.js
--- a/calendar/base/content/calendar-item-editing.js
+++ b/calendar/base/content/calendar-item-editing.js
@@ -418,16 +418,21 @@ function getTransactionMgr() {
  * @see                 calITransactionManager
  * @param aAction       The action to do.
  * @param aItem         The new item to add/modify/delete
  * @param aCalendar     The calendar to do the transaction on
  * @param aOldItem      (optional) some actions require an old item
  * @param aListener     (optional) the listener to call when complete.
  */
 function doTransaction(aAction, aItem, aCalendar, aOldItem, aListener) {
+    // This is usually a user-initiated transaction, so make sure the calendar
+    // this transaction is happening on is visible.
+    ensureCalendarVisible(aCalendar);
+
+    // Now use the transaction manager to execute the action
     getTransactionMgr().createAndCommitTxn(aAction,
                                            aItem,
                                            aCalendar,
                                            aOldItem,
                                            aListener ? aListener : null);
     updateUndoRedoMenu();
 }
 
--- a/calendar/base/content/calendar-management.js
+++ b/calendar/base/content/calendar-management.js
@@ -208,16 +208,26 @@ function calendarListSetupContextMenu(ev
     } else {
         disableElement("list-calendars-context-edit");
         disableElement("list-calendars-context-publish");
         disableElement("list-calendars-context-delete");
     }
     return true;
 }
 
+/**
+ * Makes sure the passed calendar is visible to the user
+ *
+ * @param aCalendar   The calendar to make visible.
+ */
+function ensureCalendarVisible(aCalendar) {
+    // We use the main window's calendar list to ensure that the calendar is visible
+    document.getElementById("calendar-list-tree-widget").ensureCalendarVisible(aCalendar);
+}
+
 var compositeObserver = {
     QueryInterface: function cO_QueryInterface(aIID) {
         return cal.doQueryInterface(this,
                                     calendarManagementCompositeObserver.prototype,
                                     aIID,
                                     [Components.interfaces.calICompositeObserver]);
     },
 
--- a/calendar/base/content/calendar-views.js
+++ b/calendar/base/content/calendar-views.js
@@ -61,16 +61,17 @@ var calendarViewController = {
 
     /**
      * Creates a new event
      * @see calICalendarViewController
      */
     createNewEvent: function (aCalendar, aStartTime, aEndTime, aForceAllday) {
         aCalendar = aCalendar || getSelectedCalendar();
 
+
         // if we're given both times, skip the dialog
         if (aStartTime && aEndTime && !aStartTime.isDate && !aEndTime.isDate) {
             let item = cal.createEvent();
             item.startDate = aStartTime;
             item.endDate = aEndTime;
             item.title = calGetString("calendar", "newEvent");
             item.calendar = aCalendar;
             cal.alarms.setDefaultValues(item);