From 2eaf0b73a4b016c511b4bd1065ed2a5a5ee3656b Mon Sep 17 00:00:00 2001 From: "michael.buettner%sun.com" Date: Fri, 16 Jun 2006 15:24:53 +0000 Subject: [PATCH] Bug 328197 Turn recurring tasks back on. r=jminta git-svn-id: svn://10.0.0.236/branches/MOZILLA_1_8_BRANCH@200121 18797224-902f-48f8-a5cc-f745e15eee43 --- .../base/content/calendar-event-dialog.js | 58 +++++++++++++++---- .../base/content/calendar-event-dialog.xul | 2 + .../content/calendar-recurrence-dialog.js | 21 +++---- mozilla/calendar/base/public/calITodo.idl | 7 +++ .../calendar/base/src/calRecurrenceInfo.js | 28 ++++++++- mozilla/calendar/base/src/calTodo.js | 8 +++ 6 files changed, 99 insertions(+), 25 deletions(-) diff --git a/mozilla/calendar/base/content/calendar-event-dialog.js b/mozilla/calendar/base/content/calendar-event-dialog.js index e83cb4dabae..f0a6abd9e27 100644 --- a/mozilla/calendar/base/content/calendar-event-dialog.js +++ b/mozilla/calendar/base/content/calendar-event-dialog.js @@ -78,10 +78,6 @@ function onLoad() // update the accept button updateAccept(); - // disabling recurring todo until bug 328197 is fixed - if (isToDo(window.calendarItem)) - disableElement("item-recurrence"); - // update datetime pickers updateDueDate(); updateEntryDate(); @@ -243,6 +239,9 @@ function loadDialog(item) setElementValue("item-recurrence", "true", "disabled"); setElementValue("set-recurrence", "true", "disabled"); setElementValue("item-calendar", "true", "disabled"); + + // don't allow to revoke the entrydate of recurring todo's. + disableElement("todo-has-entrydate"); } else if (item.recurrenceInfo) setElementValue("item-recurrence", "true", "checked"); @@ -295,6 +294,10 @@ function saveDialog(item) jsDateToDateTime(getElementValue("todo-entrydate")) : null; if (entryDate) { entryDate = entryDate.getInTimezone(kDefaultTimezone); + } else { + // no entrydate, no recurrence + item.recurrenceInfo = null; + window.recurrenceInfo = null; } setItemProperty(item, "entryDate", entryDate); @@ -486,14 +489,13 @@ function onEndTimeChange() } function updateAccept() { + var enableAccept = true; + var kDefaultTimezone = calendarDefaultTimezone(); - var acceptButton = document.getElementById("calendar-event-dialog").getButton("accept"); var title = getElementValue("item-title"); if (title.length == 0) - acceptButton.setAttribute("disabled", "true"); - else if (acceptButton.getAttribute("disabled")) - acceptButton.removeAttribute("disabled"); + enableAccept = false; // don't allow for end dates to be before start dates var startDate; @@ -524,14 +526,21 @@ function updateAccept() jsDateToDateTime(getElementValue("todo-entrydate")) : null; endDate = getElementValue("todo-has-duedate", "checked") ? jsDateToDateTime(getElementValue("todo-duedate")) : null; + + var taskRepeatWarning = document.getElementById("task-repeat-warning"); + if (!startDate && getElementValue("item-recurrence", "checked")) { + enableAccept = false; + taskRepeatWarning.removeAttribute("hidden"); + } else { + taskRepeatWarning.setAttribute("hidden", "true"); + } } var timeWarning = document.getElementById("end-time-warning"); if (endDate && startDate && endDate.compare(startDate) == -1) { - acceptButton.setAttribute("disabled", "true"); + enableAccept = false; timeWarning.removeAttribute("hidden"); } else { - acceptButton.removeAttribute("disabled"); timeWarning.setAttribute("hidden", "true"); } @@ -541,12 +550,20 @@ function updateAccept() document.getElementById("read-only-cal").setAttribute("hidden", !cal.readOnly); if (gReadOnlyMode || cal.readOnly) { - acceptButton.setAttribute("disabled", "true"); + enableAccept = false; } if (!updateTaskAlarmWarnings()) { - acceptButton.setAttribute("disabled", "true"); + enableAccept = false; } + + var acceptButton = document.getElementById("calendar-event-dialog").getButton("accept"); + if (!enableAccept) { + acceptButton.setAttribute("disabled", "true"); + } else if (acceptButton.getAttribute("disabled")) { + acceptButton.removeAttribute("disabled"); + } + return; } @@ -639,6 +656,8 @@ function updateRecurrence() } else { setElementValue("set-recurrence", "true", "disabled"); } + + updateAccept(); } var prevAlarmItem = null; @@ -691,6 +710,21 @@ function editRecurrence() args.calendarEvent = window.calendarItem; args.recurrenceInfo = window.recurrenceInfo || args.calendarEvent.recurrenceInfo; + var kDefaultTimezone = calendarDefaultTimezone(); + if (isEvent(window.calendarItem)) { + var startDate = jsDateToDateTime(getElementValue("event-starttime")).getInTimezone(kDefaultTimezone); + if (getElementValue("event-all-day", "checked")) { + startDate.isDate = true; + startDate.normalize(); + } + args.startDate = startDate; + } else if (isToDo(window.calendarItem)) { + if (!getElementValue("todo-has-entrydate", "checked")) { + return; + } + args.startDate = jsDateToDateTime(getElementValue("todo-entrydate")).getInTimezone(kDefaultTimezone); + } + var savedWindow = window; args.onOk = function(recurrenceInfo) { savedWindow.recurrenceInfo = recurrenceInfo; diff --git a/mozilla/calendar/base/content/calendar-event-dialog.xul b/mozilla/calendar/base/content/calendar-event-dialog.xul index edc1f69915d..21c3b5e385e 100644 --- a/mozilla/calendar/base/content/calendar-event-dialog.xul +++ b/mozilla/calendar/base/content/calendar-event-dialog.xul @@ -137,6 +137,8 @@