From b3ed9d5664c775e911a1b2e38f1d91b61f2d767f Mon Sep 17 00:00:00 2001 From: wolfgang Date: Fri, 8 Feb 2008 19:40:50 +0000 Subject: [PATCH] git-svn-id: http://svn.opengroupware.org/SOGo/inverse/trunk@1365 d1b88da0-ebda-0310-925b-ed51d893ca5b --- SOPE/NGCards/CardElement.m | 2 +- SOPE/NGCards/ChangeLog | 11 ++ SOPE/NGCards/iCalRecurrenceRule.m | 11 +- UI/Scheduler/UIxComponentEditor.m | 24 ++- .../SchedulerUI/UIxRecurrenceEditor.wox | 4 +- UI/WebServerResources/UIxRecurrenceEditor.js | 172 +++++++++++------- 6 files changed, 154 insertions(+), 70 deletions(-) diff --git a/SOPE/NGCards/CardElement.m b/SOPE/NGCards/CardElement.m index 9767359b..b3ccea5d 100644 --- a/SOPE/NGCards/CardElement.m +++ b/SOPE/NGCards/CardElement.m @@ -314,7 +314,7 @@ [self addValue: newValue]; else { - if (aValue) + if ([aValue length]) [self setValue: index to: newValue]; else [values removeObjectAtIndex: index]; diff --git a/SOPE/NGCards/ChangeLog b/SOPE/NGCards/ChangeLog index 8fd11bd8..6ecd16f9 100644 --- a/SOPE/NGCards/ChangeLog +++ b/SOPE/NGCards/ChangeLog @@ -1,3 +1,14 @@ +2008-02-08 Wolfgang Sourdeau + + * iCalRecurrenceRule.m ([iCalRecurrenceRule -wkst]): if no wkst + parameter is specified, we supply "MO" as default value. + ([iCalRecurrenceRule -weekDayFromICalRepresentation:_day]): the + second letter of sunday if "u", fixed typo. + + * CardElement.m ([CardElement + -setNamedValue:aValueNameto:aValue]): if the value is empty, we + removed the named value. + 2008-01-28 Wolfgang Sourdeau * iCalRecurrenceRule.m ([iCalRecurrenceRule diff --git a/SOPE/NGCards/iCalRecurrenceRule.m b/SOPE/NGCards/iCalRecurrenceRule.m index afeb28d0..f53f7988 100644 --- a/SOPE/NGCards/iCalRecurrenceRule.m +++ b/SOPE/NGCards/iCalRecurrenceRule.m @@ -251,9 +251,16 @@ [self setNamedValue: @"wkst" to: _weekStart]; } +#warning we also should handle the user weekstarts - (NSString *) wkst { - return [self namedValue: @"wkst"]; + NSString *start; + + start = [self namedValue: @"wkst"]; + if (![start length]) + start = @"MO"; + + return start; } - (void) setWeekStart: (iCalWeekDay) _weekStart @@ -359,7 +366,7 @@ case 'S': if (chars[1] == 'A') foundDay = iCalWeekDaySaturday; - else if (chars[1] == 'H') + else if (chars[1] == 'U') foundDay = iCalWeekDaySunday; } } diff --git a/UI/Scheduler/UIxComponentEditor.m b/UI/Scheduler/UIxComponentEditor.m index 1c5ab268..1521b06d 100644 --- a/UI/Scheduler/UIxComponentEditor.m +++ b/UI/Scheduler/UIxComponentEditor.m @@ -58,9 +58,31 @@ #import "UIxComponentEditor.h" +#define iREPEAT(X) \ +- (NSString *) repeat##X; \ +- (void) setRepeat##X: (NSString *) theValue + +#define iRANGE(X) \ +- (NSString *) range##X; \ +- (void) setRange##X: (NSString *) theValue + +@interface UIxComponentEditor (Private) + +iREPEAT(1); +iREPEAT(2); +iREPEAT(3); +iREPEAT(4); +iREPEAT(5); +iREPEAT(6); +iREPEAT(7); +iRANGE(1); +iRANGE(2); + +@end + #define REPEAT(X) \ - (NSString *) repeat##X { return repeat##X; } \ -- (void) setRepeat##X: (NSString *) theValue { NSLog(@"setRepeat %@", theValue); ASSIGN(repeat##X, theValue); } \ +- (void) setRepeat##X: (NSString *) theValue { NSLog(@"setRepeat%d %@", X, theValue); ASSIGN(repeat##X, theValue); } \ #define RANGE(X) \ - (NSString *) range##X { return range##X; } \ diff --git a/UI/Templates/SchedulerUI/UIxRecurrenceEditor.wox b/UI/Templates/SchedulerUI/UIxRecurrenceEditor.wox index b246c968..a9764a1b 100644 --- a/UI/Templates/SchedulerUI/UIxRecurrenceEditor.wox +++ b/UI/Templates/SchedulerUI/UIxRecurrenceEditor.wox @@ -60,14 +60,14 @@
-

-
+

+
diff --git a/UI/WebServerResources/UIxRecurrenceEditor.js b/UI/WebServerResources/UIxRecurrenceEditor.js index 24364984..b513dc12 100644 --- a/UI/WebServerResources/UIxRecurrenceEditor.js +++ b/UI/WebServerResources/UIxRecurrenceEditor.js @@ -93,11 +93,17 @@ function initializeFormValues() { else if (repeatType == 1) { // Repeat weekly $('weeklyWeeksField').value = parent$("repeat1").value; - var weekDiv = $("week").firstChild; - var daysArray = parent$("repeat2").value.split(","); - daysArray.each(function(index) { - $(weekDiv).down('div', index).addClassName("_selected"); + var weekDiv = $($("week").firstChild); +// log ("div: " + weekDiv); +// log ("days: " + parent$("repeat2").value); + var days = "" + parent$("repeat2").value; + if (days.length > 0) { + var daysArray = days.split(","); + var divs = weekDiv.childNodesWithTag("div"); + daysArray.each(function(index) { + divs[index-1].addClassName("_selected"); }); + } } else if (repeatType == 2) { // Repeat monthly @@ -106,10 +112,13 @@ function initializeFormValues() { $('monthlyRepeat').value = parent$("repeat3").value; $('monthlyDay').value = parent$("repeat4").value; var monthDiv = $("month"); - var daysArray = parent$("repeat5").value.split(","); - daysArray.each(function(index) { - $(monthDiv).down('DIV[name="'+index+'"]').addClassName("_selected"); - }); + var days = "" + parent$("repeat5").value; + if (days.length > 0) { + var daysArray = days.split(","); + daysArray.each(function(index) { + $(monthDiv).down('DIV[name="'+index+'"]').addClassName("_selected"); + }); + } } else if (repeatType == 3) { // Repeat yearly @@ -154,21 +163,26 @@ function handleDailyRecurrence() { // We check if the dailyDaysField really contains an integer if (radioValue == 0) { + var showError = true; + var v = "" + $('dailyDaysField').value; if (v.length > 0) { v = parseInt(v); - if (isNaN(v) || v <= 1) - window.alert("Please specify a numerical value in the Days field greater or equal to 1."); - else +// log("v: " + v); + if (!isNaN(v) && v > 0) { validate = true; + showError = false; + parent$("repeat1").value = radioValue; + parent$("repeat2").value = v; + } } + + if (showError) + window.alert("Please specify a numerical value in the Days field greater or equal to 1."); } - else + else { validate = true; - - if (validate) { parent$("repeat1").value = radioValue; - parent$("repeat2").value = v; } return validate; @@ -177,17 +191,21 @@ function handleDailyRecurrence() { function handleWeeklyRecurrence() { var validate = false; + var showError = true; var fieldValue = "" + $('weeklyWeeksField').value; + if (fieldValue.length > 0) { + // We check if the weeklyWeeksField really contains an integer + var v = parseInt(fieldValue); + if (!isNaN(v) && v > 0) { + validate = true; + showError = false; + parent$("repeat1").value = fieldValue; + parent$("repeat2").value = getSelectedDays($('week')); + } + } - // We check if the weeklyWeeksField really contains an integer - var v = parseInt(fieldValue); - if (isNaN(v) || v <= 0) + if (showError) window.alert("Please specify a numerical value in the Week(s) field greater or equal to 1."); - else { - validate = true; - parent$("repeat1").value = fieldValue; - parent$("repeat2").value = getSelectedDays($('week')); - } return validate; } @@ -203,68 +221,95 @@ function handleMonthlyRecurrence() { window.alert("This type of recurrence is currently unsupported."); else { // We check if the monthlyMonthsField really contains an integer - var fieldValue = $('monthlyMonthsField').value; - var v = parseInt(fieldValue); - if (isNaN(v) || v <= 0) - window.alert("Please specify a numerical value in the Month(s) field greater or equal to 1."); - else { - parent$("repeat1").value = fieldValue; - parent$("repeat2").value = radioValue; - parent$("repeat3").value = $('monthlyRepeat').value; - parent$("repeat4").value = $('monthlyDay').value; - parent$("repeat5").value = getSelectedDays($('month')); + var showError = true; + + var fieldValue = "" + $('monthlyMonthsField').value; + if (fieldValue.length > 0) { + var v = parseInt(fieldValue); + if (!isNaN(v) && v > 0) { + validate = true; + showError = false; + parent$("repeat1").value = fieldValue; + parent$("repeat2").value = radioValue; + parent$("repeat3").value = $('monthlyRepeat').value; + parent$("repeat4").value = $('monthlyDay').value; + parent$("repeat5").value = getSelectedDays($('month')); + } } + + if (showError) + window.alert("Please specify a numerical value in the Month(s) field greater or equal to 1."); } return validate; } function handleYearlyRecurrence() { - var validate = true; + var validate = false; - parent$("repeat1").value = $('yearlyYearsField').value; - parent$("repeat2").value = $('recurrence_form').getRadioValue('yearlyRadioButtonName'); - parent$("repeat3").value = $('yearlyDayField').value; - parent$("repeat4").value = $('yearlyMonth1').value; - parent$("repeat5").value = $('yearlyRepeat').value; - parent$("repeat6").value = $('yearlyDay').value; - parent$("repeat7").value = $('yearlyMonth2').value; + var radioValue = $('recurrence_form').getRadioValue('yearlyRadioButtonName'); // FIXME - right now we do not support rules // such as Every Second Tuesday of February - if (parent$("repeat2").value == 1) { + if (radioValue == 1) window.alert("This type of recurrence is currently unsupported."); - validate = false; - } + else { + var showError = true; - // We check if the yearlyYearsField really contains an integer - var v = parseInt(parent$("repeat1").value); - if (isNaN(v) || v <= 0) { - window.alert("Please specify a numerical value in the Year(s) field greater or equal to 1."); - validate = false; + var fieldValue = "" + $('yearlyYearsField').value; + if (fieldValue.length > 0) { + // We check if the yearlyYearsField really contains an integer + var v = parseInt(fieldValue); + if (!isNaN(v) && v > 0) { + validate = true; + showError = false; + parent$("repeat1").value = fieldValue; + parent$("repeat2").value = radioValue; + parent$("repeat3").value = $('yearlyDayField').value; + parent$("repeat4").value = $('yearlyMonth1').value; + parent$("repeat5").value = $('yearlyRepeat').value; + parent$("repeat6").value = $('yearlyDay').value; + parent$("repeat7").value = $('yearlyMonth2').value; + } + } + + if (showError) + window.alert("Please specify a numerical value in the Year(s) field greater or equal to 1."); } return validate; } -function validateRange() { - var validate = true; - - var range = $('recurrence_form').getRadioValue('rangeRadioButtonName'); - parent$("range1").value = range; +function handleRange() { + var validate = false; - if (range == 1) { - parent$("range2").value = $('rangeAppointmentsField').value; + var radioValue = $('recurrence_form').getRadioValue('rangeRadioButtonName'); + if (radioValue == 0) + validate = true; + else if (radioValue == 1) { + var showError = true; + + var fieldValue = "" + $('rangeAppointmentsField').value; + if (fieldValue.length > 0) { + // We check if the rangeAppointmentsField really contains an integer + var v = parseInt(fieldValue); + if (!isNaN(v) && v > 0) { + validate = true; + showError = false; + parent$("range2").value = fieldValue; + } + } - // We check if the rangeAppointmentsField really contains an integer - var v = parseInt(parent$("range2").value); - if (isNaN(v) || v <= 0) { + if (showError) window.alert("Please specify a numerical value in the Appointment(s) field greater or equal to 1."); - validate = false; - } } - else if (range == 2) + else if (radioValue == 2) { + validate = true; parent$("range2").value = $('endDate_date').value; + } + + if (validate) + parent$("range1").value = radioValue; return validate; } @@ -284,8 +329,7 @@ function onEditorOkClick(event) { else validate = handleYearlyRecurrence(); - if (validate - && validateRange()) + if (validate && handleRange()) window.close(); } -- 2.39.5