From f8facef6b2d0fff7ec5f73b1c5539541464c94f9 Mon Sep 17 00:00:00 2001 From: "pavlov%pavlov.net" Date: Wed, 1 Jun 2005 00:44:52 +0000 Subject: [PATCH] hook up weekly recurrence --- .../content/calendar-recurrence-dialog.js | 34 ++++++++++++++++--- .../content/calendar-recurrence-dialog.xul | 16 ++++----- 2 files changed, 38 insertions(+), 12 deletions(-) diff --git a/calendar/base/content/calendar-recurrence-dialog.js b/calendar/base/content/calendar-recurrence-dialog.js index 77357cd4a084..4adf196dea60 100644 --- a/calendar/base/content/calendar-recurrence-dialog.js +++ b/calendar/base/content/calendar-recurrence-dialog.js @@ -71,6 +71,9 @@ function onCancel() function loadDialog() { + if (!window.originalRecurrenceInfo) + return; + var ritems = window.originalRecurrenceInfo.getRecurrenceItems({}); /* split out rules and exceptions */ @@ -92,17 +95,25 @@ function loadDialog() switch(rule.type) { case "DAILY": - setElementValue("period-deck", 0, "selectedIndex"); + document.getElementById("period-list").selectedIndex = 0; + setElementValue("daily-days", rule.interval); break; case "WEEKLY": - setElementValue("period-deck", 1, "selectedIndex"); + document.getElementById("period-list").selectedIndex = 1; + + const byDayTable = { 1 : "sun", 2 : "mon", 3 : "tue", 4 : "wed", + 5 : "thu", 6 : "fri", 7: "sat" }; + + for each (var i in rule.getComponent("BYDAY", {})) { + setElementValue("weekly-" + byDayTable[i], "true", "checked"); + } break; case "MONTHLY": - setElementValue("period-deck", 2, "selectedIndex"); + document.getElementById("period-list").selectedIndex = 2; break; case "YEARLY": - setElementValue("period-deck", 3, "selectedIndex"); + document.getElementById("period-list").selectedIndex = 3; break; default: dump("unable to handle your rule type!\n"); @@ -144,12 +155,27 @@ function saveDialog() break; case 1: recRule.type = "WEEKLY"; + recRule.interval = 1; // XXX we need to support every 2 weeks and so on.. + var onDays = []; + ["sun", "mon", "tue", "wed", "thu", "fri", "sat"]. + forEach(function(d) + { + var elem = document.getElementById("weekly-" + d); + if (elem.checked) { + onDays.push(elem.getAttribute("value")); + } + }); + recRule.setComponent("BYDAY", onDays.length, onDays); break; case 2: recRule.type = "MONTHLY"; break; case 3: recRule.type = "YEARLY"; + var nyears = Number(getElementValue("yearly-years")); + if (nyears == null) + nyears = 1; + recRule.interval = nyears; break; } diff --git a/calendar/base/content/calendar-recurrence-dialog.xul b/calendar/base/content/calendar-recurrence-dialog.xul index 5179b4b32d83..4bd2725a87c8 100644 --- a/calendar/base/content/calendar-recurrence-dialog.xul +++ b/calendar/base/content/calendar-recurrence-dialog.xul @@ -103,15 +103,15 @@ - - - - + + + + - - - + + + @@ -122,7 +122,7 @@ - +