Monotone-Parent: 1573ea3dacf6d889750a42ad556297539f95422a

Monotone-Revision: 5a3c5e24f7615c54657e9e9cb706861e6724ac1c

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2006-11-15T00:06:21
Monotone-Branch: ca.inverse.sogo
This commit is contained in:
Wolfgang Sourdeau
2006-11-15 00:06:21 +00:00
parent aa13918cfb
commit d9caed2d8f
3 changed files with 194 additions and 122 deletions

View File

@@ -27,18 +27,22 @@
@class NSArray;
@class NSCalendarDay;
@class NSDictionary;
@class NSString;
@class SOGoDateFormatter;
@interface UIxCalDayTable : UIxCalView
{
SOGoDateFormatter *dateFormatter;
int numberOfDays;
NSCalendarDate *startDate;
NSCalendarDate *currentTableDay;
NSString *currentTableHour;
NSArray *daysToDisplay;
NSMutableArray *daysToDisplay;
NSMutableArray *hoursToDisplay;
SOGoDateFormatter *dateFormatter;
NSArray *allAppointments;
NSDictionary *currentAppointment;
NSString *cssClass;
NSString *cssId;
@@ -51,6 +55,7 @@
- (NSString *) cssId;
- (void) setNumberOfDays: (NSString *) aNumber;
- (NSString *) numberOfDays;
- (void) setStartDate: (NSCalendarDate *) aStartDate;
- (NSCalendarDate *) startDate;
@@ -60,6 +65,9 @@
- (void) setCurrentTableDay: (NSCalendarDate *) aTableDay;
- (NSCalendarDate *) currentTableDay;
- (void) setCurrentAppointment: (NSDictionary *) newCurrentAppointment;
- (NSDictionary *) currentAppointment;
@end
#endif /* UIXCALDAYTABLE_H */

View File

@@ -22,6 +22,7 @@
#import <Foundation/NSArray.h>
#import <Foundation/NSCalendarDate.h>
#import <Foundation/NSDictionary.h>
#import <Foundation/NSKeyValueCoding.h>
#import <Foundation/NSString.h>
@@ -40,6 +41,7 @@
{
if ((self = [super init]))
{
allAppointments = nil;
daysToDisplay = nil;
hoursToDisplay = nil;
numberOfDays = 1;
@@ -55,6 +57,10 @@
- (void) dealloc
{
if (allAppointments)
[allAppointments release];
if (daysToDisplay)
[daysToDisplay release];
[dateFormatter release];
[super dealloc];
}
@@ -82,11 +88,26 @@
- (void) setNumberOfDays: (NSString *) aNumber
{
numberOfDays = [aNumber intValue];
if (daysToDisplay)
{
[daysToDisplay release];
daysToDisplay = nil;
}
}
- (NSString *) numberOfDays
{
return [NSString stringWithFormat: @"%d", numberOfDays];
}
- (void) setStartDate: (NSCalendarDate *) aStartDate
{
startDate = aStartDate;
if (daysToDisplay)
{
[daysToDisplay release];
daysToDisplay = nil;
}
}
- (NSCalendarDate *) startDate
@@ -132,23 +153,22 @@
- (NSArray *) daysToDisplay
{
NSMutableArray *days;
NSCalendarDate *currentDate;
int count;
days = [NSMutableArray arrayWithCapacity: numberOfDays];
currentDate = [[self startDate] hour: [currentTableHour intValue]
minute: 0];
[days addObject: currentDate];
for (count = 1; count < numberOfDays; count++)
if (!daysToDisplay)
{
currentDate = [currentDate dateByAddingYears: 0
months: 0
days: 1];
[days addObject: currentDate];
daysToDisplay = [NSMutableArray new];
currentDate = [[self startDate] hour: [self dayStartHour]
minute: 0];
[daysToDisplay addObject: currentDate];
for (count = 1; count < numberOfDays; count++)
[daysToDisplay addObject: [currentDate dateByAddingYears: 0
months: 0
days: count]];
}
return days;
return daysToDisplay;
}
- (void) setCurrentTableDay: (NSCalendarDate *) aTableDay
@@ -161,28 +181,6 @@
return currentTableDay;
}
- (NSString *) dayCellClasses
{
NSMutableString *classes;
int dayOfWeek;
classes = [NSMutableString new];
[classes autorelease];
[classes appendString: @"contentOfDay"];
if (numberOfDays > 1)
{
dayOfWeek = [currentTableDay dayOfWeek];
if (dayOfWeek == 0 || dayOfWeek == 6)
[classes appendString: @" weekEndDay"];
if ([currentTableDay isToday])
[classes appendString: @" dayOfToday"];
if ([[self selectedDate] isDateOnSameDay: currentTableDay])
[classes appendString: @" selectedDay"];
}
return classes;
}
- (void) setCurrentTableHour: (NSString *) aTableHour
{
currentTableHour = aTableHour;
@@ -205,34 +203,116 @@
[dateFormatter stringForObjectValue: currentTableDay]];
}
- (NSArray *) aptsForCurrentDate
- (NSDictionary *) _adjustedAppointment: (NSDictionary *) anAppointment
forStart: (NSCalendarDate *) start
andEnd: (NSCalendarDate *) end
{
NSArray *apts;
NSMutableArray *filtered;
unsigned i, count;
NSCalendarDate *start, *end;
SOGoAppointment *apt;
NSCalendarDate *aptStartDate;
NSMutableDictionary *newMutableAppointment;
NSDictionary *newAppointment;
BOOL startIsEarlier, endIsLater;
start = currentTableDay;
end = [start dateByAddingYears: 0 months: 0 days: 0
hours: 0 minutes: 59 seconds: 59];
startIsEarlier
= ([[anAppointment objectForKey: @"startDate"] laterDate: start] == start);
endIsLater
= ([[anAppointment objectForKey: @"endDate"] earlierDate: end] == end);
apts = [self fetchCoreAppointmentsInfos];
filtered = [NSMutableArray new];
[filtered autorelease];
count = [apts count];
for (i = 0; i < count; i++)
if (startIsEarlier || endIsLater)
{
apt = [apts objectAtIndex:i];
aptStartDate = [apt valueForKey:@"startDate"];
if ([aptStartDate isGreaterThanOrEqualTo: start]
&& [aptStartDate isLessThan: end])
[filtered addObject:apt];
newMutableAppointment
= [NSMutableDictionary dictionaryWithDictionary: anAppointment];
if (startIsEarlier)
[newMutableAppointment setObject: start
forKey: @"startDate"];
if (endIsLater)
[newMutableAppointment setObject: end
forKey: @"endDate"];
newAppointment = newMutableAppointment;
}
else
newAppointment = anAppointment;
return newAppointment;
}
- (NSArray *) appointmentsForCurrentDay
{
NSMutableArray *filteredAppointments;
NSEnumerator *aptsEnumerator;
NSDictionary *currentDayAppointment;
NSCalendarDate *start, *end;
if (!allAppointments)
{
allAppointments = [self fetchCoreAppointmentsInfos];
[allAppointments retain];
}
return filtered;
filteredAppointments = [NSMutableArray new];
[filteredAppointments autorelease];
start = [currentTableDay hour: [self dayStartHour] minute: 0];
end = [currentTableDay hour: [self dayEndHour] minute: 0];
aptsEnumerator = [allAppointments objectEnumerator];
currentDayAppointment = [aptsEnumerator nextObject];
while (currentDayAppointment)
{
if (([end laterDate: [currentDayAppointment
valueForKey: @"startDate"]] == end)
&& ([start earlierDate: [currentDayAppointment
valueForKey: @"endDate"]] == start))
[filteredAppointments
addObject: [self _adjustedAppointment: currentDayAppointment
forStart: start andEnd: end]];
currentDayAppointment = [aptsEnumerator nextObject];
}
return filteredAppointments;
}
- (void) setCurrentAppointment: (NSDictionary *) newCurrentAppointment
{
currentAppointment = newCurrentAppointment;
}
- (NSDictionary *) currentAppointment
{
return currentAppointment;
}
- (NSArray *) appointmentsClasses
{
return [NSString stringWithFormat: @"appointments appointmentsFor%dDays",
numberOfDays];
}
- (NSString *) daysViewClasses
{
return [NSString stringWithFormat: @"daysView daysViewFor%dDays", numberOfDays];
}
- (NSString *) dayClasses
{
NSMutableString *classes;
int dayOfWeek;
classes = [NSMutableString new];
[classes autorelease];
[classes appendFormat: @"day day%d", [currentTableDay dayOfWeek]];
if (numberOfDays > 1)
{
dayOfWeek = [currentTableDay dayOfWeek];
if (dayOfWeek == 0 || dayOfWeek == 6)
[classes appendString: @" weekEndDay"];
if ([currentTableDay isToday])
[classes appendString: @" dayOfToday"];
if ([[self selectedDate] isDateOnSameDay: currentTableDay])
[classes appendString: @" selectedDay"];
}
return classes;
}
@end

View File

@@ -5,32 +5,51 @@
xmlns:const="http://www.skyrix.com/od/constant"
xmlns:rsrc="OGo:url"
xmlns:label="OGo:label">
<table var:class="cssClass" var:id="cssId">
<tr>
<td class="nullHeader">
</td>
<var:foreach list="daysToDisplay" item="currentTableDay"
><td class="header"><var:string value="labelForDay"/></td
<div id="daysView" var:class="daysViewClasses">
<div class="hours">
<var:foreach list="hoursToDisplay" item="currentTableHour"
><div class="hour"><var:string value="currentTableHour" />:00</div
></var:foreach>
</tr>
</div>
<var:if condition="hasHolidayInfo">
<tr>
<td class="hourOfDay" colspan="2">
<b><var:string value="holidayInfo.title" /></b>
</td>
</tr>
</var:if>
<div class="hourLines">
<div class="hourLine hourLine0"><!-- space --></div
><div class="hourLine hourLine1"><!-- space --></div
><div class="hourLine hourLine2"><!-- space --></div
><div class="hourLine hourLine3"><!-- space --></div
><div class="hourLine hourLine4"><!-- space --></div
><div class="hourLine hourLine5"><!-- space --></div
><div class="hourLine hourLine6"><!-- space --></div
><div class="hourLine hourLine7"><!-- space --></div
><div class="hourLine hourLine8"><!-- space --></div
><div class="hourLine hourLine9"><!-- space --></div
><div class="hourLine hourLine10"><!-- space --></div
><div class="hourLine hourLine11"><!-- space --></div
><div class="hourLine hourLine12"><!-- space --></div
><div class="hourLine hourLine13"><!-- space --></div
><div class="hourLine hourLine14"><!-- space --></div
><div class="hourLine hourLine15"><!-- space --></div
><div class="hourLine hourLine16"><!-- space --></div
><div class="hourLine hourLine17"><!-- space --></div
><div class="hourLine hourLine18"><!-- space --></div
><div class="hourLine hourLine19"><!-- space --></div
><div class="hourLine hourLine20"><!-- space --></div
><div class="hourLine hourLine21"><!-- space --></div
><div class="hourLine hourLine22"><!-- space --></div
><div class="hourLine hourLine23"><!-- space --></div>
</div>
<var:foreach list="allDayApts" item="appointment">
<tr>
<td class="hourOfDay">
<var:entity name="nbsp" />
</td>
<td class="contentOfDay" width="90%">
<var:foreach list="allDayApts" item="appointment">
<var:component className="UIxCalInlineAptView"
appointment="appointment"
<div class="days">
<var:foreach list="daysToDisplay" item="currentTableDay"
><div var:class="dayClasses"
var:day="currentTableDay.shortDateString"
><div class="header"><var:string value="labelForDay" /></div>
<div class="appointments">
<var:foreach list="appointmentsForCurrentDay" item="currentAppointment"
><var:component className="UIxCalInlineAptView"
dayStartHour="dayStartHour"
dayEndHour="dayEndHour"
appointment="currentAppointment"
formatter="aptFormatter"
tooltipFormatter="aptTooltipFormatter"
url="appointmentViewURL"
@@ -38,46 +57,11 @@
queryDictionary="currentDateQueryParameters"
referenceDate="selectedDate"
canAccess="canAccessApt"
/>
</var:foreach>
</td>
</tr>
</var:foreach>
<var:foreach list="hoursToDisplay" item="currentTableHour">
<tr>
<td class="hourOfDay">
<var:string value="currentTableHour"
/>:00
</td>
<var:foreach list="daysToDisplay" item="currentTableDay"
><td var:class="dayCellClasses"
onclick="onCalendarSelectDay(event, this);"
ondblclick="return newEvent(this, 'event');"
var:day="currentTableDay.shortDateString"
var:hour="currentAppointmentHour"
><var:foreach
list="aptsForCurrentDate"
item="appointment"
>
<var:component className="UIxCalInlineAptView"
appointment="appointment"
formatter="aptFormatter"
tooltipFormatter="aptTooltipFormatter"
url="appointmentViewURL"
const:style="dayoverview"
queryDictionary="currentDayQueryParameters"
referenceDate="currentTableDay"
canAccess="canAccessApt"
/>
</var:foreach
></td>
</var:foreach>
</tr>
</var:foreach>
</table>
<script type="text/javascript">
scrollDayView();
</script>
/></var:foreach
>
</div>
</div>
</var:foreach>
</div>
</div>
</container>