From: znek Date: Mon, 16 Aug 2004 09:32:04 +0000 (+0000) Subject: new time controls X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=460fc8cd7ef9df69cbf1d5aa2bdd7a304f7745b9;p=scalable-opengroupware.org new time controls git-svn-id: http://svn.opengroupware.org/SOGo/trunk@247 d1b88da0-ebda-0310-925b-ed51d893ca5b --- diff --git a/SOGo/UI/Scheduler/ChangeLog b/SOGo/UI/Scheduler/ChangeLog index bd3bece2..7b69aa18 100644 --- a/SOGo/UI/Scheduler/ChangeLog +++ b/SOGo/UI/Scheduler/ChangeLog @@ -1,3 +1,11 @@ +2004-08-15 Marcus Mueller + + * v0.9.54 + + * UIxTimeDateControl.*, UIxTimeSelector.*, UIxDatePicker.*: + fixed. DatePicker expects day, month, year bindings now, + TimeSelector expects hour, minute, second. + 2004-08-16 Helge Hess * v0.9.53 diff --git a/SOGo/UI/Scheduler/UIxAppointmentEditor.m b/SOGo/UI/Scheduler/UIxAppointmentEditor.m index db7e548a..57937355 100644 --- a/SOGo/UI/Scheduler/UIxAppointmentEditor.m +++ b/SOGo/UI/Scheduler/UIxAppointmentEditor.m @@ -378,6 +378,9 @@ req = [[self context] request]; NSLog(@"%@", [req formValues]); + [self logWithFormat:@"aptStartDate:%@ aptEndDate:%@", + [self aptStartDate], + [self aptEndDate]]; return self; } diff --git a/SOGo/UI/Scheduler/UIxDatePicker.m b/SOGo/UI/Scheduler/UIxDatePicker.m index 68514c10..56c830b8 100644 --- a/SOGo/UI/Scheduler/UIxDatePicker.m +++ b/SOGo/UI/Scheduler/UIxDatePicker.m @@ -27,7 +27,9 @@ @interface UIxDatePicker : WOComponent { NSString *dateID; - NSCalendarDate *date; + id day; + id month; + id year; NSString *label; } @@ -42,7 +44,9 @@ - (void)dealloc { [self->dateID release]; - [self->date release]; + [self->day release]; + [self->month release]; + [self->year release]; [self->label release]; [super dealloc]; } @@ -56,15 +60,26 @@ return self->dateID; } -- (void)setDate:(NSCalendarDate *)_date { - ASSIGN(self->date, _date); +- (void)setDay:(id)_day { + ASSIGN(self->day, _day); } -- (NSCalendarDate *)date { - if (self->date == nil) /* HACK, return 'now' */ - return [NSCalendarDate date]; - return self->date; +- (id)day { + return self->day; +} +- (void)setMonth:(id)_month { + ASSIGN(self->month, _month); +} +- (id)month { + return self->month; +} +- (void)setYear:(id)_year { + ASSIGN(self->year, _year); +} +- (id)year { + return self->year; } + - (void)setLabel:(NSString *)_label { ASSIGNCOPY(self->label, _label); } @@ -73,7 +88,10 @@ } - (NSString *)formattedDateString { - return [[self date] descriptionWithCalendarFormat:@"%Y-%m-%d"]; + return [NSString stringWithFormat:@"%d-%02d-%02d", + [[self year] intValue], + [[self month] intValue], + [[self day] intValue]]; } - (NSString *)dateFormat { @@ -141,13 +159,17 @@ [self debugWithFormat:@"got no date string!"]; return; } - + d = [NSCalendarDate dateWithString:dateString calendarFormat:@"%Y-%m-%d"]; if (d == nil) [self logWithFormat:@"WARNING: Could not parse dateString: '%@'", dateString]; [self logWithFormat:@"%s setting date: %@", __PRETTY_FUNCTION__, d]; - [self setDate:d]; + [self setDay:[NSNumber numberWithInt:[d dayOfMonth]]]; + [self setMonth:[NSNumber numberWithInt:[d monthOfYear]]]; + [self setYear:[NSNumber numberWithInt:[d yearOfCommonEra]]]; + + [super takeValuesFromRequest:_rq inContext:_ctx]; } @end /* UIxDatePicker */ diff --git a/SOGo/UI/Scheduler/UIxTimeDateControl.m b/SOGo/UI/Scheduler/UIxTimeDateControl.m index 0dbbafd8..a86defa0 100644 --- a/SOGo/UI/Scheduler/UIxTimeDateControl.m +++ b/SOGo/UI/Scheduler/UIxTimeDateControl.m @@ -24,20 +24,42 @@ @interface UIxTimeDateControl : WOComponent { - NSString *controlID; + NSString *controlID; + NSString *label; NSCalendarDate *date; - NSString *label; - - NSCalendarDate *timeComponent; - NSCalendarDate *dateComponent; + id hour; + id minute; + id second; + id day; + id month; + id year; } +- (void)setControlID:(NSString *)_controlID; +- (NSString *)controlID; +- (void)setLabel:(NSString *)_label; +- (NSString *)label; +- (void)setDate:(NSCalendarDate *)_date; +- (NSCalendarDate *)date; + +- (void)setHour:(id)_hour; +- (id)hour; +- (void)setMinute:(id)_minute; +- (id)minute; +- (void)setSecond:(id)_second; +- (id)second; +- (void)setDay:(id)_day; +- (id)day; +- (void)setMonth:(id)_month; +- (id)month; +- (void)setYear:(id)_year; +- (id)year; + - (NSString *)timeID; - (NSString *)dateID; -- (void)setTimeComponent:(NSCalendarDate *)_timeComponent; -- (void)setDateComponent:(NSCalendarDate *)_dateComponent; - +- (void)_setDate:(NSCalendarDate *)_date; + @end #include "common.h" @@ -45,11 +67,15 @@ @implementation UIxTimeDateControl - (void)dealloc { - [self->controlID release]; - [self->date release]; - [self->label release]; - [self->timeComponent release]; - [self->dateComponent release]; + [self->controlID release]; + [self->label release]; + [self->date release]; + [self->hour release]; + [self->minute release]; + [self->second release]; + [self->day release]; + [self->month release]; + [self->year release]; [super dealloc]; } @@ -61,33 +87,63 @@ - (NSString *)controlID { return self->controlID; } -- (void)setDate:(NSCalendarDate *)_date { - ASSIGN(self->date, _date); - [self setTimeComponent:_date]; - [self setDateComponent:_date]; -} -- (NSCalendarDate *)date { - return self->date; -} - (void)setLabel:(NSString *)_label { ASSIGNCOPY(self->label, _label); } - (NSString *)label { return self->label; } +- (void)setDate:(NSCalendarDate *)_date { + [self _setDate:_date]; + [self setHour:[NSNumber numberWithInt:[_date hourOfDay]]]; + [self setMinute:[NSNumber numberWithInt:[_date minuteOfHour]]]; + [self setYear:[NSNumber numberWithInt:[_date yearOfCommonEra]]]; + [self setMonth:[NSNumber numberWithInt:[_date monthOfYear]]]; + [self setDay:[NSNumber numberWithInt:[_date dayOfMonth]]]; +} +- (void)_setDate:(NSCalendarDate *)_date { + ASSIGN(self->date, _date); +} +- (NSCalendarDate *)date { + return self->date; +} -- (void)setTimeComponent:(NSCalendarDate *)_timeComponent { - ASSIGN(self->timeComponent, _timeComponent); +- (void)setHour:(id)_hour { + ASSIGN(self->hour, _hour); +} +- (id)hour { + return self->hour; +} +- (void)setMinute:(id)_minute { + ASSIGN(self->minute, _minute); } -- (NSCalendarDate *)timeComponent { - return self->timeComponent; +- (id)minute { + return self->minute; +} +- (void)setSecond:(id)_second { + ASSIGN(self->second, _second); +} +- (id)second { + return self->second; } -- (void)setDateComponent:(NSCalendarDate *)_dateComponent { - ASSIGN(self->dateComponent, _dateComponent); +- (void)setDay:(id)_day { + ASSIGN(self->day, _day); +} +- (id)day { + return self->day; } -- (NSCalendarDate *)dateComponent { - return self->dateComponent; +- (void)setMonth:(id)_month { + ASSIGN(self->month, _month); +} +- (id)month { + return self->month; +} +- (void)setYear:(id)_year { + ASSIGN(self->year, _year); +} +- (id)year { + return self->year; } - (NSString *)timeID { @@ -101,22 +157,29 @@ - (void)takeValuesFromRequest:(WORequest *)_rq inContext:(WOContext *)_ctx { NSCalendarDate *d; - + unsigned _year, _month, _day, _hour, _minute, _second; + /* call super, so that the form values are applied on the popups */ [super takeValuesFromRequest:_rq inContext:_ctx]; - - d = [self dateComponent]; - [self logWithFormat:@"base date: %@", d]; - - d = [d hour:[[self timeComponent] hourOfDay] - minute:[[self timeComponent] minuteOfHour]]; - [self logWithFormat:@"%s newDate:%@", - __PRETTY_FUNCTION__, - d]; - - if (d == nil) - return; - [self setDate:d]; + + _year = [[self year] intValue]; + if(_year == 0) + return; + + _month = [[self month] intValue]; + _day = [[self day] intValue]; + _hour = [[self hour] intValue]; + _minute = [[self minute] intValue]; + _second = [[self second] intValue]; + d = [NSCalendarDate dateWithYear:_year + month:_month + day:_day + hour:_hour + minute:_minute + second:_second + timeZone:[[self date] timeZone]]; + [self debugWithFormat:@"%s setting date:%@", __PRETTY_FUNCTION__, d]; + [self _setDate:d]; } @end /* UIxTimeDateControl */ diff --git a/SOGo/UI/Scheduler/UIxTimeDateControl.wox b/SOGo/UI/Scheduler/UIxTimeDateControl.wox index 3d52f3b0..f6e2d465 100644 --- a/SOGo/UI/Scheduler/UIxTimeDateControl.wox +++ b/SOGo/UI/Scheduler/UIxTimeDateControl.wox @@ -5,9 +5,24 @@ xmlns:const="http://www.skyrix.com/od/constant" xmlns:rsrc="OGo:url" > - - + + + + + +
+ + + +
diff --git a/SOGo/UI/Scheduler/UIxTimeSelector.m b/SOGo/UI/Scheduler/UIxTimeSelector.m index a558990e..fcc2a1d5 100644 --- a/SOGo/UI/Scheduler/UIxTimeSelector.m +++ b/SOGo/UI/Scheduler/UIxTimeSelector.m @@ -26,16 +26,19 @@ @interface UIxTimeSelector : WOComponent { - NSString *timeID; - NSCalendarDate *date; - BOOL combined; - NSString *minuteInterval; - id item; - NSArray *hours, *minutes; -} - -- (NSArray *)hours; -- (NSArray *)minutes; + NSString *timeID; + id hour; + id minute; + NSString *minuteInterval; +} + +- (void)setTimeID:(NSString *)_timeID; +- (NSString *)timeID; +- (void)setHour:(id)_hour; +- (id)hour; +- (void)setMinute:(id)_minute; +- (id)minute; +- (void)setMinuteInterval:(NSString *)_minuteInterval; - (NSString *)minuteInterval; @end @@ -46,11 +49,9 @@ - (void)dealloc { [self->timeID release]; - [self->date release]; + [self->hour release]; + [self->minute release]; [self->minuteInterval release]; - [self->item release]; - [self->hours release]; - [self->minutes release]; [super dealloc]; } @@ -63,13 +64,17 @@ return self->timeID; } -- (void)setDate:(NSCalendarDate *)_date { - ASSIGN(self->date, _date); +- (void)setHour:(id)_hour { + ASSIGN(self->hour, _hour); +} +- (id)hour { + return self->hour; } -- (NSCalendarDate *)date { - if (self->date == nil) /* HACK, return 'now' */ - return [NSCalendarDate date]; - return self->date; +- (void)setMinute:(id)_minute { + ASSIGN(self->minute, _minute); +} +- (id)minute { + return self->minute; } - (void)setMinuteInterval:(NSString *)_minuteInterval { @@ -81,87 +86,9 @@ return self->minuteInterval; } -- (void)setItem:(id)_item { - ASSIGN(self->item, _item); -} -- (id)item { - return self->item; -} - -- (NSString *)hoursName { - return [[self timeID] stringByAppendingString:@"_hours"]; -} - -- (NSString *)minutesName { - return [[self timeID] stringByAppendingString:@"_minutes"]; -} - -- (NSArray *)hours { - NSMutableArray *values; - unsigned i, count; - - if (self->hours) - return self->hours; - - count = 24; - values = [NSMutableArray arrayWithCapacity:count]; - for (i = 0; i < count; i++) - [values addObject:[NSNumber numberWithInt:i]]; - - self->hours = [values copy]; - return self->hours; -} - -- (NSArray *)minutes { - NSMutableArray *values; - unsigned i, count, iv; - - if (self->minutes) - return self->minutes; - - iv = [[self minuteInterval] intValue]; - - count = 60; - values = [NSMutableArray arrayWithCapacity:count]; - for (i = 0; i < count; i += iv) - [values addObject:[NSNumber numberWithInt:i]]; - - self->minutes = [values copy]; - return self->minutes; -} - -- (NSNumber *)selectedHour { - return [[self hours] objectAtIndex:[[self date] hourOfDay]]; -} - -- (NSNumber *)selectedMinute { - return [[self minutes] objectAtIndex:[[self date] minuteOfHour]]; -} - -- (NSString *)displayString { - char buf[8]; - sprintf(buf, "%02d", [item intValue]); - return [NSString stringWithCString:buf]; -} - -/* action */ - -- (void)takeValuesFromRequest:(WORequest *)_rq inContext:(WOContext *)_ctx { - NSString *h, *m; - NSCalendarDate *d; - - h = [_rq formValueForKey:[self hoursName]]; - m = [_rq formValueForKey:[self minutesName]]; - - [self logWithFormat:@"got hour (%@): %@", [self hoursName], h]; - [self logWithFormat:@"got minute (%@): %@", [self minutesName], m]; - - if (h == nil) - return; - - d = [[self date] hour:[h intValue] minute:[m intValue]]; - [self logWithFormat:@"%s setting date:%@", __PRETTY_FUNCTION__, d]; - [self setDate:d]; +- (void)takeValuesFromRequest:(WORequest *)_rq inContext:(WOContext *)_ctx { + /* call super, so that the form values are applied on the popups */ + [super takeValuesFromRequest:_rq inContext:_ctx]; } @end /* UIxTimeSelector */ diff --git a/SOGo/UI/Scheduler/UIxTimeSelector.wox b/SOGo/UI/Scheduler/UIxTimeSelector.wox index 938bff14..a5c3a7bb 100644 --- a/SOGo/UI/Scheduler/UIxTimeSelector.wox +++ b/SOGo/UI/Scheduler/UIxTimeSelector.wox @@ -6,15 +6,9 @@ xmlns:rsrc="OGo:url" var:id="timeID" > - : + diff --git a/SOGo/UI/Scheduler/Version b/SOGo/UI/Scheduler/Version index f8d8760c..a96e7c74 100644 --- a/SOGo/UI/Scheduler/Version +++ b/SOGo/UI/Scheduler/Version @@ -1,6 +1,6 @@ # $Id$ -SUBMINOR_VERSION:=53 +SUBMINOR_VERSION:=54 # v0.9.41 requires libNGObjWeb v4.2.431 # v0.9.31 requires libWEExtensions v4.2.52