Monotone-Parent: 4efc308e378492efdb95420253ab9f2c2b3ab674

Monotone-Revision: 7a455791a787acec10f4b9c8249a9f97a36998e0

Monotone-Author: crobert@inverse.ca
Monotone-Date: 2009-06-04T18:50:23
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
C Robert 2009-06-04 18:50:23 +00:00
parent 52a4de60bd
commit 93067312ec
4 changed files with 79 additions and 27 deletions

View File

@ -1,9 +1,9 @@
2009-06-04 Cyril Robert <crobert@inverse.ca>
* UI/Scheduler/UIxCalListingActions.m: Added everything needed for the
findSlot action.
findSlot action. Fixes for allday & multiday events.
* UI/WebServerResources/UIxAttendeesEditor.js: Added everything needed for
the findSlot action.
the findSlot action. Fixes for allday events.
* UI/Scheduler/UIxCalListingActions.h (findPossibleSlotAction): Added header.
2009-06-03 Wolfgang Sourdeau <wsourdeau@inverse.ca>

View File

@ -1134,27 +1134,51 @@ _computeBlocksPosition (NSArray *blocks)
andEnd: (NSCalendarDate *) end
against: (NSArray *) limits
{
NSCalendarDate *maxFrom, *maxTo;
NSString *buffer;
NSCalendarDate *sFrom, *sTo, *eFrom, *eTo;
BOOL rc = YES;
buffer = [NSString stringWithFormat: @"%04d-%02d-%02d %@ %05d",
[start yearOfCommonEra], [start monthOfYear], [start dayOfMonth],
[[limits objectAtIndex: 0] descriptionWithCalendarFormat: @"%H:%M"],
([[start timeZone] secondsFromGMTForDate: start]/36)];
maxFrom = [NSCalendarDate dateWithString: buffer
calendarFormat: @"%Y-%m-%d %H:%M %z"];
sFrom = [NSCalendarDate dateWithYear: [start yearOfCommonEra]
month: [start monthOfYear]
day: [start dayOfMonth]
hour: [[limits objectAtIndex: 0] hourOfDay]
minute: [[limits objectAtIndex: 0] minuteOfHour]
second: 0
timeZone: [start timeZone]];
sTo = [NSCalendarDate dateWithYear: [start yearOfCommonEra]
month: [start monthOfYear]
day: [start dayOfMonth]
hour: [[limits objectAtIndex: 1] hourOfDay]
minute: [[limits objectAtIndex: 1] minuteOfHour]
second: 0
timeZone: [start timeZone]];
buffer = [NSString stringWithFormat: @"%04d-%02d-%02d %@ %05d",
[start yearOfCommonEra], [start monthOfYear], [start dayOfMonth],
[[limits objectAtIndex: 1] descriptionWithCalendarFormat: @"%H:%M"],
([[end timeZone] secondsFromGMTForDate: end]/36)];
maxTo = [NSCalendarDate dateWithString: buffer
calendarFormat: @"%Y-%m-%d %H:%M %z"];
eFrom = [NSCalendarDate dateWithYear: [end yearOfCommonEra]
month: [end monthOfYear]
day: [end dayOfMonth]
hour: [[limits objectAtIndex: 0] hourOfDay]
minute: [[limits objectAtIndex: 0] minuteOfHour]
second: 0
timeZone: [end timeZone]];
eTo = [NSCalendarDate dateWithYear: [end yearOfCommonEra]
month: [end monthOfYear]
day: [end dayOfMonth]
hour: [[limits objectAtIndex: 1] hourOfDay]
minute: [[limits objectAtIndex: 1] minuteOfHour]
second: 0
timeZone: [end timeZone]];
if ([maxFrom compare: start] == NSOrderedDescending)
// start < sFrom
if ([sFrom compare: start] == NSOrderedDescending)
rc = NO;
if ([maxTo compare: end] == NSOrderedAscending)
// start > sTo
if ([sTo compare: start] == NSOrderedAscending)
rc = NO;
// end > eTo
if ([eTo compare: end] == NSOrderedAscending)
rc = NO;
// end < eFrom
if ([eFrom compare: end] == NSOrderedDescending)
rc = NO;
return rc;
@ -1192,8 +1216,9 @@ _computeBlocksPosition (NSArray *blocks)
NSCalendarDate *nStart, *nEnd;
NSArray *uids, *limits;
NSMutableDictionary *rc;
int direction, count, blockDuration;
int direction, count, blockDuration, step;
unsigned int **fbData;
BOOL isAllDay = NO;
r = [context request];
rc = nil;
@ -1201,15 +1226,21 @@ _computeBlocksPosition (NSArray *blocks)
uids = [[r formValueForKey: @"uids"] componentsSeparatedByString: @","];
if ([uids count] > 0)
{
isAllDay = [[r formValueForKey: @"isAllDay"] boolValue];
direction = [[r formValueForKey: @"direction"] intValue];
limits = [self _loadScheduleLimitsForUsers: uids];
direction = [[r formValueForKey: @"direction"] intValue];
if (isAllDay)
step = direction * 96;
else
step = direction;
nStart = [[self _parseDateField: @"startDate"
timeField: @"startTime"]
addTimeInterval: intervalSeconds * direction];
addTimeInterval: intervalSeconds * step];
nEnd = [[self _parseDateField: @"endDate"
timeField: @"endTime"]
addTimeInterval: intervalSeconds * direction];
addTimeInterval: intervalSeconds * step];
blockDuration = [nEnd timeIntervalSinceDate: nStart] / intervalSeconds;
fbData = [self _loadFreeBusyForUsers: uids
@ -1217,24 +1248,27 @@ _computeBlocksPosition (NSArray *blocks)
for (count = offsetBlocks;
(count < offsetBlocks + maxBlocks) && count >= 0;
count += direction)
count += step)
{
//NSLog (@"Trying %@ -> %@", nStart, nEnd);
if ([self _validateStart: nStart
andEnd: nEnd
against: limits])
{
//NSLog (@"valid");
if ([self _possibleBlock: count
forUsers: [uids count]
freeBusy: fbData
interval: blockDuration])
{
//NSLog (@"possible");
rc = [self _makeValidResponseFrom: nStart
to: nEnd];
break;
}
}
nStart = [nStart addTimeInterval: intervalSeconds * direction];
nEnd = [nEnd addTimeInterval: intervalSeconds * direction];
nStart = [nStart addTimeInterval: intervalSeconds * step];
nEnd = [nEnd addTimeInterval: intervalSeconds * step];
}
for (count = 0; count < [uids count]; count++)

View File

@ -23,7 +23,7 @@
</div>
<label><span class="content">
<span id="allDay"><input class="checkBox"
<span id="allDay"><input id="isAllDay" class="checkBox"
type="checkbox" var:selection="isAllDay"
var:checked="isAllDay"
/> <var:string label:value="All day Event"

View File

@ -4,6 +4,7 @@ var resultsDiv;
var address;
var awaitingFreeBusyRequests = new Array();
var additionalDays = 2;
var isAllDay = parent$("isAllDay").checked + 0;
var attendeesEditor = {
delay: 500,
@ -16,6 +17,19 @@ var attendeesEditor = {
states: null
};
function handleAllDay () {
window.timeWidgets['end']['hour'].value = 17;
window.timeWidgets['end']['minute'].value = 0;
window.timeWidgets['start']['hour'].value = 9;
window.timeWidgets['start']['minute'].value = 0;
$("startTime_time_hour").disabled = true;
$("startTime_time_minute").disabled = true;
$("endTime_time_hour").disabled = true;
$("endTime_time_minute").disabled = true;
}
/* address completion */
function onContactKeydown(event) {
@ -486,7 +500,8 @@ function findSlot (direction) {
+ "&startDate=" + escape (sd)
+ "&startTime=" + escape (st)
+ "&endDate=" + escape (ed)
+ "&endTime=" + escape (et));
+ "&endTime=" + escape (et)
+ "&isAllDay=" + isAllDay);
document.findSlotAjaxRequest = triggerAjaxRequest(urlstr,
updateSlotDisplayCallback,
userList);
@ -836,6 +851,9 @@ function initTimeWidgets(widgets) {
}
}
}
if (isAllDay)
handleAllDay ();
}
function onAdjustTime(event) {