Bug 825778 - Event dialog: the Save&Close button can wrongly be in disabled status with tasks and timezone enabled. r=Philipp
authorDecathlon <bv1578@gmail.com>
Thu, 07 Feb 2013 22:41:32 +0100
changeset 14833 899bbca945e57cafa22dadeb1bc459a82bf6e7c3
parent 14832 0701728ff277887179ee8836fe89a5bef5d0913b
child 14834 e58ec29c87f93b80f15a7591420f2c9a2212a5e2
push id867
push userbugzilla@standard8.plus.com
push dateMon, 01 Apr 2013 20:44:27 +0000
treeherdercomm-beta@797726b8d244 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersPhilipp
bugs825778
Bug 825778 - Event dialog: the Save&Close button can wrongly be in disabled status with tasks and timezone enabled. r=Philipp
calendar/base/content/dialogs/calendar-event-dialog.js
--- a/calendar/base/content/dialogs/calendar-event-dialog.js
+++ b/calendar/base/content/dialogs/calendar-event-dialog.js
@@ -1086,27 +1086,34 @@ function onPopupShowing(menuPopup) {
 }
 
 /**
  * Update the disabled status of the accept button. The button is enabled if all
  * parts of the dialog have options selected that make sense.
  * constraining factors like
  */
 function updateAccept() {
-    var enableAccept = true;
-
-    var kDefaultTimezone = calendarDefaultTimezone();
+    let enableAccept = true;
+    let kDefaultTimezone = calendarDefaultTimezone();
+    let startDate;
+    let endDate;
+    let isEvent = cal.isEvent(window.calendarItem);
 
     // don't allow for end dates to be before start dates
-    var startDate;
-    var endDate;
-    if (isEvent(window.calendarItem)) {
+    if (isEvent) {
         startDate = cal.jsDateToDateTime(getElementValue("event-starttime"));
         endDate = cal.jsDateToDateTime(getElementValue("event-endtime"));
-
+    } else {
+        startDate = getElementValue("todo-has-entrydate", "checked") ?
+            cal.jsDateToDateTime(getElementValue("todo-entrydate")) : null;
+        endDate = getElementValue("todo-has-duedate", "checked") ?
+            cal.jsDateToDateTime(getElementValue("todo-duedate")) : null;
+    }
+
+    if (startDate && endDate) {
         var menuItem = document.getElementById('options-timezone-menuitem');
         if (menuItem.getAttribute('checked') == 'true') {
             var startTimezone = gStartTimezone;
             var endTimezone = gEndTimezone;
             if (endTimezone.isUTC) {
                 if (!compareObjects(gStartTimezone, gEndTimezone)) {
                     endTimezone = gStartTimezone;
                 }
@@ -1119,35 +1126,30 @@ function updateAccept() {
             endDate.timezone = endTimezone;
         }
 
         startDate = startDate.getInTimezone(kDefaultTimezone);
         endDate = endDate.getInTimezone(kDefaultTimezone);
 
         // For all-day events we are not interested in times and compare only
         // dates.
-        if (getElementValue("event-all-day", "checked")) {
+        if (isEvent && getElementValue("event-all-day", "checked")) {
             // jsDateToDateTime returnes the values in UTC. Depending on the
             // local timezone and the values selected in datetimepicker the date
             // in UTC might be shifted to the previous or next day.
             // For example: The user (with local timezone GMT+05) selected
             // Feb 10 2006 00:00:00. The corresponding value in UTC is
             // Feb 09 2006 19:00:00. If we now set isDate to true we end up with
             // a date of Feb 09 2006 instead of Feb 10 2006 resulting in errors
             // during the following comparison.
             // Calling getInTimezone() ensures that we use the same dates as
             // displayed to the user in datetimepicker for comparison.
             startDate.isDate = true;
             endDate.isDate = true;
         }
-    } else {
-        startDate = getElementValue("todo-has-entrydate", "checked") ?
-            cal.jsDateToDateTime(getElementValue("todo-entrydate")) : null;
-        endDate = getElementValue("todo-has-duedate", "checked") ?
-            cal.jsDateToDateTime(getElementValue("todo-duedate")) : null;
     }
 
     if (endDate && startDate && endDate.compare(startDate) == -1) {
         enableAccept = false;
     }
 
     enableAcceptCommand(enableAccept);