Fix bug 432966 - Required start date of a repeating task can be deselected after changing the calendar. r=philipp
authorMatthew Mecca <matthew.mecca@gmail.com>
Sat, 19 Feb 2011 16:22:00 +0100
changeset 7256 21d32ea89dbfb901a59fa4a2f9d4707043d87b75
parent 7255 59e01ab2fabd62200dffba5fed9604ab31815ad5
child 7257 8b87f8b2ef0b2ecb5310438c5831385bdd9e7f61
push idunknown
push userunknown
push dateunknown
reviewersphilipp
bugs432966
Fix bug 432966 - Required start date of a repeating task can be deselected after changing the calendar. r=philipp
calendar/base/content/dialogs/calendar-dialog-utils.js
calendar/base/content/dialogs/calendar-event-dialog.js
--- a/calendar/base/content/dialogs/calendar-dialog-utils.js
+++ b/calendar/base/content/dialogs/calendar-dialog-utils.js
@@ -685,31 +685,35 @@ function getCurrentCalendar() {
     return (calendarNode && calendarNode.selectedItem ?
                 calendarNode.selectedItem.calendar :
                 window.calendarItem.calendar);
 }
 
 /**
  * Common update functions for both event dialogs. Called when a reminder has
  * been selected from the menulist.
+ *
+ * @param aSuppressDialogs     If true, controls are updated without prompting
+ *                               for changes with the dialog
  */
-function commonUpdateReminder() {
+function commonUpdateReminder(aSuppressDialogs) {
     // if a custom reminder has been selected, we show the appropriate
     // dialog in order to allow the user to specify the details.
     // the result will be placed in the 'reminder-custom-menuitem' tag.
     let reminderList = document.getElementById("item-alarm");
     if (reminderList.value == 'custom') {
         // Clear the reminder icons first, this will make sure that while the
         // dialog is open the default reminder image is not shown which may
         // confuse users.
         removeChildren("reminder-icon-box");
 
         // show the dialog. This call blocks until the dialog is closed. Don't
-        // pop up the dialog if this happens during initialization of the dialog
-        if (reminderList.hasAttribute("last-value")) {
+        // pop up the dialog if aSuppressDialogs was specified or if this
+        // happens during initialization of the dialog
+        if (!aSuppressDialogs && reminderList.hasAttribute("last-value")) {
             editReminder();
         }
 
         if (reminderList.value == 'custom') {
             // Only do this if the 'custom' item is still selected. If the edit
             // reminder dialog was canceled then the previously selected
             // menuitem is selected, which may not be the custom menuitem.
 
--- a/calendar/base/content/dialogs/calendar-event-dialog.js
+++ b/calendar/base/content/dialogs/calendar-event-dialog.js
@@ -20,16 +20,17 @@
  * Contributor(s):
  *   Michael Buettner <michael.buettner@sun.com>
  *   Philipp Kewisch <mozilla@kewis.ch>
  *   Martin Schroeder <mschroeder@mozilla.x-home.org>
  *   Fred Jendrzejewski <fred.jen@web.de>
  *   Daniel Boelzle <daniel.boelzle@sun.com>
  *   Markus Adrario <Mozilla@Adrario.de>
  *   Gianfranco Balza <bv1578@gmail.com>
+ *   Matthew Mecca <matthew.mecca@gmail.com>
  *
  * Alternatively, the contents of this file may be used under the terms of
  * either the GNU General Public License Version 2 or later (the "GPL"), or
  * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
  * in which case the provisions of the GPL or the LGPL are applicable instead
  * of those above. If you wish to allow use of your version of this file only
  * under the terms of either the GPL or the LGPL, and not to allow others to
  * use your version of this file under the terms of the MPL, indicate your
@@ -444,18 +445,18 @@ function loadDialog(item) {
         let itemProp = item.getProperty("X-MOZ-SEND-INVITATIONS");
         notifyCheckbox.checked = (item.calendar.getProperty("imip.identity") &&
                                   ((itemProp === null)
                                    ? getPrefSafe("calendar.itip.notify", true)
                                    : (itemProp == "TRUE")));
     }
 
     updateAttendees();
-    updateRepeat();
-    updateReminder();
+    updateRepeat(true);
+    updateReminder(true);
 
     gShowTimeAs = item.getProperty("TRANSP");
     updateShowTimeAs();
 }
 
 /**
  * Sets up all date related controls from the passed item
  *
@@ -842,19 +843,22 @@ function loadRepeat(item) {
 
     if (item.parentItem != item) {
         disableElement("item-repeat");
     }
 }
 
 /**
  * Update reminder related elements on the dialog.
+ *
+ * @param aSuppressDialogs     If true, controls are updated without prompting
+ *                               for changes with the custom dialog
  */
-function updateReminder() {
-    commonUpdateReminder();
+function updateReminder(aSuppressDialogs) {
+    commonUpdateReminder(aSuppressDialogs);
     updateAccept();
 }
 
 /**
  * Saves all values the user chose on the dialog to the passed item
  *
  * @param item    The item to save to.
  */
@@ -1966,21 +1970,20 @@ function updateCalendar() {
         // valid.
         if (item.parentItem != item) {
             disableElement("item-calendar");
 
             // don't allow to revoke the entrydate of recurring todo's.
             disableElementWithLock("todo-has-entrydate", "permanent-lock");
         }
 
-        // update datetime pickers
-        updateDueDate();
-        updateEntryDate();
-
-        // update datetime pickers
+        // update datetime pickers, disable checkboxes if dates are required by
+        // recurrence or reminders.
+        updateRepeat(true);
+        updateReminder(true);
         updateAllDay();
     }
 
     // Make sure capabilties are reflected correctly
     updateCapabilities();
 }
 
 /**
@@ -2009,18 +2012,21 @@ function editRepeat() {
         args);
 }
 
 /**
  * This function is responsilble for propagating UI state to controls
  * depending on the repeat setting of an item. This functionality is used
  * after the dialog has been loaded as well as if the repeat pattern has
  * been changed.
+ *
+ * @param aSuppressDialogs     If true, controls are updated without prompting
+ *                               for changes with the recurrence dialog
  */
-function updateRepeat() {
+function updateRepeat(aSuppressDialogs) {
     var repeatMenu = document.getElementById("item-repeat");
     var repeatItem = repeatMenu.selectedItem;
     var repeatValue = repeatItem.getAttribute("value");
 
     if (repeatValue == 'none') {
         window.recurrenceInfo = null;
         var item = window.calendarItem;
         if (isToDo(item)) {
@@ -2051,19 +2057,19 @@ function updateRepeat() {
         }
 
         // retrieve the current recurrence info, we need this
         // to find out whether or not the user really created
         // a new repeat pattern.
         var recurrenceInfo = window.recurrenceInfo;
 
         // now bring up the recurrence dialog.
-        // don't pop up the dialog if this happens during
-        // initialization of the dialog.
-        if (repeatMenu.hasAttribute("last-value")) {
+        // don't pop up the dialog if aSuppressDialogs was specified or if
+        // called during initialization of the dialog.
+        if (!aSuppressDialogs && repeatMenu.hasAttribute("last-value")) {
             editRepeat();
         }
 
         // we need to address two separate cases here.
         // 1) we need to revoke the selection of the repeat
         //    drop down list in case the user didn't specify
         //    a new repeat pattern (i.e. canceled the dialog)
         // 2) re-enable the 'has entrydate' option in case