Monotone-Parent: 25201eca7a2d2327ce725455760027b032810d78

Monotone-Revision: beff03702ba361b408bf967b4f807a2fec161392

Monotone-Author: wsourdeau@inverse.ca
Monotone-Date: 2006-10-19T14:40:24
Monotone-Branch: ca.inverse.sogo
maint-2.0.2
Wolfgang Sourdeau 2006-10-19 14:40:24 +00:00
parent b790b4778e
commit dcfb1be7f3
4 changed files with 207 additions and 134 deletions

View File

@ -33,6 +33,8 @@
@interface UIxTaskEditor : UIxComponentEditor @interface UIxTaskEditor : UIxComponentEditor
{ {
NSCalendarDate *dueDate; NSCalendarDate *dueDate;
BOOL hasStartDate;
BOOL hasDueDate;
} }
- (void) setTaskStartDate: (NSCalendarDate *) _date; - (void) setTaskStartDate: (NSCalendarDate *) _date;

View File

@ -77,8 +77,6 @@
@"STATUS:NEEDS-ACTION\r\n" /* confirmed by default */ @"STATUS:NEEDS-ACTION\r\n" /* confirmed by default */
@"PERCENT-COMPLETE:0\r\n" @"PERCENT-COMPLETE:0\r\n"
@"DTSTAMP:%@Z\r\n" @"DTSTAMP:%@Z\r\n"
@"DTSTART:%@\r\n"
@"DUE:%@\r\n"
@"SEQUENCE:1\r\n" @"SEQUENCE:1\r\n"
@"PRIORITY:5\r\n" @"PRIORITY:5\r\n"
@"%@" /* organizer */ @"%@" /* organizer */
@ -86,7 +84,7 @@
@"END:VTODO\r\n" @"END:VTODO\r\n"
@"END:VCALENDAR"; @"END:VCALENDAR";
NSCalendarDate *lStartDate, *lDueDate, *stamp; NSCalendarDate *stamp;
NSString *template, *s; NSString *template, *s;
unsigned minutes; unsigned minutes;
@ -97,19 +95,13 @@
else { else {
minutes = 60; minutes = 60;
} }
lStartDate = [self selectedDate];
lDueDate = [lStartDate dateByAddingYears:0 months:0 days:0
hours:0 minutes:minutes seconds:0];
stamp = [NSCalendarDate calendarDate]; stamp = [NSCalendarDate calendarDate];
[stamp setTimeZone: [NSTimeZone timeZoneWithName: @"GMT"]]; [stamp setTimeZone: [NSTimeZone timeZoneWithName: @"GMT"]];
s = [self iCalParticipantsAndResourcesStringFromQueryParameters]; s = [self iCalParticipantsAndResourcesStringFromQueryParameters];
template = [NSString stringWithFormat:iCalStringTemplate, template = [NSString stringWithFormat:iCalStringTemplate,
[[self clientObject] nameInContainer], [[self clientObject] nameInContainer],
[stamp iCalFormattedDateTimeString], [stamp iCalFormattedDateTimeString],
[lStartDate iCalFormattedDateTimeString],
[lDueDate iCalFormattedDateTimeString],
[self iCalOrganizerString], [self iCalOrganizerString],
s]; s];
return template; return template;
@ -182,12 +174,14 @@
uTZ = [[self clientObject] userTimeZone]; uTZ = [[self clientObject] userTimeZone];
dueDate = [_task due]; dueDate = [_task due];
if (!dueDate) // if (!dueDate)
dueDate = [[self startDate] dateByAddingYears: 0 months: 0 days: 0 // dueDate = [[self startDate] dateByAddingYears: 0 months: 0 days: 0
hours: 1 minutes: 0 seconds: 0]; // hours: 1 minutes: 0 seconds: 0];
if (dueDate)
[dueDate setTimeZone: uTZ]; {
[dueDate retain]; [dueDate setTimeZone: uTZ];
[dueDate retain];
}
} }
- (void) saveValuesIntoTask: (iCalToDo *) _task - (void) saveValuesIntoTask: (iCalToDo *) _task
@ -195,9 +189,18 @@
/* merge in form values */ /* merge in form values */
NSArray *attendees, *lResources; NSArray *attendees, *lResources;
iCalRecurrenceRule *rrule; iCalRecurrenceRule *rrule;
NSCalendarDate *dateTime;
[_task setStartDate: [self taskStartDate]];
[_task setDue: [self taskDueDate]]; if (hasStartDate)
dateTime = [self taskStartDate];
else
dateTime = nil;
[_task setStartDate: dateTime];
if (hasDueDate)
dateTime = [self taskDueDate];
else
dateTime = nil;
[_task setDue: dateTime];
[_task setSummary: [self title]]; [_task setSummary: [self title]];
[_task setLocation: [self location]]; [_task setLocation: [self location]];
@ -444,4 +447,42 @@
return [self redirectToLocation: [self completeURIForMethod:@"../view"]]; return [self redirectToLocation: [self completeURIForMethod:@"../view"]];
} }
- (void) setHasStartDate: (BOOL) aBool
{
hasStartDate = aBool;
}
- (BOOL) hasStartDate
{
return ([self taskStartDate] != nil);
}
- (BOOL) startDateDisabled
{
return ![self hasStartDate];
}
- (void) setHasDueDate: (BOOL) aBool
{
hasDueDate = aBool;
}
- (BOOL) hasDueDate
{
return ([self taskDueDate] != nil);
}
- (BOOL) dueDateDisabled
{
return ![self hasDueDate];
}
- (void) setDueDateDisabled: (BOOL) aBool
{
}
- (void) setStartDateDisabled: (BOOL) aBool
{
}
@end /* UIxTaskEditor */ @end /* UIxTaskEditor */

View File

@ -35,17 +35,26 @@
var:checked="isPrivate" var:checked="isPrivate"
/><var:string label:value="is private" /></label> /><var:string label:value="is private" /></label>
<span class="checkBoxList"><var:string label:value="Date" /> <span class="checkBoxList"><var:string label:value="Date" />
<span class="content"><var:component className="UIxTimeDateControl" <span class="content"
><input var:checked="hasStartDate" type="checkbox" class="checkBox"
onchange="onTimeControlCheck(this);"
/><var:component className="UIxTimeDateControl"
var:disabled="startDateDisabled"
const:controlID="startTime" const:controlID="startTime"
date="taskStartDate" date="taskStartDate"
const:dayStartHour="0" const:dayStartHour="0"
const:dayEndHour="23" const:dayEndHour="23"
/></span></span> /></span></span>
<a class="button" href="#" onclick="return toggleDetails();" id="detailsButton" <a class="button" href="#" onclick="return toggleDetails();"
id="detailsButton"
><var:string label:value="Show Details" /></a> ><var:string label:value="Show Details" /></a>
<span class="checkBoxList"><var:string label:value="Due Time" /> <span class="checkBoxList"><var:string label:value="Due Time" />
<span class="content"><var:component className="UIxTimeDateControl" <span class="content"
const:controlID="endTime" ><input var:checked="hasDueDate" type="checkbox" class="checkBox"
onchange="onTimeControlCheck(this);"
/><var:component className="UIxTimeDateControl"
var:disabled="dueDateDisabled"
const:controlID="dueTime"
date="taskDueDate" date="taskDueDate"
const:dayStartHour="0" const:dayStartHour="0"
const:dayEndHour="23" const:dayEndHour="23"
@ -83,7 +92,8 @@
></span ></span
></label> ></label>
<span class="checkBoxList" id="participantsCB"><var:string label:value="Participants" /> <span class="checkBoxList" id="participantsCB"
><var:string label:value="Participants" />
<span class="content"><var:component className="UIxContactSelector" <span class="content"><var:component className="UIxContactSelector"
const:selectorId="participants" const:selectorId="participants"
contacts="participants" contacts="participants"
@ -101,6 +111,11 @@
<var:popup list="priorities" item="item" <var:popup list="priorities" item="item"
string="itemPriorityText" selection="priority" /></label> string="itemPriorityText" selection="priority" /></label>
<label style="clear: both;"><var:string label:value="Calendar" />
<var:popup list="availableCalendars" item="item"
const:onChange="onChangeCalendar(this);"
string="item" selection="componentOwner" /></label>
<label><var:string label:value="Comment" <label><var:string label:value="Comment"
/><textarea name="comment" var:value="comment" /></label> /><textarea name="comment" var:value="comment" /></label>
</div> </div>

View File

@ -22,148 +22,163 @@
var contactSelectorAction = 'calendars-contacts'; var contactSelectorAction = 'calendars-contacts';
function uixEarlierDate(date1, date2) { function uixEarlierDate(date1, date2) {
// can this be done in a sane way? // can this be done in a sane way?
// cuicui = 'year'; // cuicui = 'year';
if (date1.getYear() < date2.getYear()) return date1; if (date1.getYear() < date2.getYear()) return date1;
if (date1.getYear() > date2.getYear()) return date2; if (date1.getYear() > date2.getYear()) return date2;
// same year // same year
// cuicui += '/month'; // cuicui += '/month';
if (date1.getMonth() < date2.getMonth()) return date1; if (date1.getMonth() < date2.getMonth()) return date1;
if (date1.getMonth() > date2.getMonth()) return date2; if (date1.getMonth() > date2.getMonth()) return date2;
// // same month // // same month
// cuicui += '/date'; // cuicui += '/date';
if (date1.getDate() < date2.getDate()) return date1; if (date1.getDate() < date2.getDate()) return date1;
if (date1.getDate() > date2.getDate()) return date2; if (date1.getDate() > date2.getDate()) return date2;
// same day // same day
return null; return null;
} }
function validateAptEditor() { function validateAptEditor() {
var e, startdate, enddate, tmpdate; var e, startdate, enddate, tmpdate;
e = document.getElementById('summary'); e = document.getElementById('summary');
if (e.value.length == 0) { if (e.value.length == 0) {
if (!confirm(labels.validate_notitle.decodeEntities())) if (!confirm(labels.validate_notitle.decodeEntities()))
return false; return false;
} }
e = document.getElementById('startTime_date'); e = document.getElementById('startTime_date');
if (e.value.length != 10) { if (!e.disabled) {
alert(labels.validate_invalid_startdate.decodeEntities()); if (e.value.length != 10) {
return false; alert(labels.validate_invalid_startdate.decodeEntities());
} return false;
startdate = e.calendar.prs_date(e.value); }
if (startdate == null) { startdate = e.calendar.prs_date(e.value);
alert(labels.validate_invalid_startdate.decodeEntities()); if (startdate == null) {
return false; alert(labels.validate_invalid_startdate.decodeEntities());
} return false;
}
e = document.getElementById('endTime_date'); }
if (e.value.length != 10) {
alert(labels.validate_invalid_enddate.decodeEntities()); e = document.getElementById('dueTime_date');
return false; if (!e.disabled) {
} if (e.value.length != 10) {
enddate = e.calendar.prs_date(e.value); alert(labels.validate_invalid_enddate.decodeEntities());
if (enddate == null) { return false;
alert(labels.validate_invalid_enddate.decodeEntities()); }
return false; enddate = e.calendar.prs_date(e.value);
} if (enddate == null) {
// cuicui = ''; alert(labels.validate_invalid_enddate.decodeEntities());
tmpdate = uixEarlierDate(startdate, enddate); return false;
if (tmpdate == enddate) { }
// window.alert(cuicui); }
alert(labels.validate_endbeforestart.decodeEntities()); // cuicui = '';
return false; tmpdate = uixEarlierDate(startdate, enddate);
} if (tmpdate == enddate) {
else if (tmpdate == null /* means: same date */) { // window.alert(cuicui);
// TODO: check time
var start, end;
start = parseInt(document.forms[0]['startTime_time_hour'].value);
end = parseInt(document.forms[0]['endTime_time_hour'].value);
if (start > end) {
alert(labels.validate_endbeforestart.decodeEntities()); alert(labels.validate_endbeforestart.decodeEntities());
return false; return false;
} }
else if (start == end) { else if (tmpdate == null /* means: same date */) {
start = parseInt(document.forms[0]['startTime_time_minute'].value); // TODO: check time
end = parseInt(document.forms[0]['endTime_time_minute'].value); var start, end;
if (start > end) {
alert(labels.validate_endbeforestart.decodeEntities()); start = parseInt(document.forms[0]['startTime_time_hour'].value);
return false; end = parseInt(document.forms[0]['dueTime_time_hour'].value);
}
}
}
return true; if (start > end) {
alert(labels.validate_endbeforestart.decodeEntities());
return false;
}
else if (start == end) {
start = parseInt(document.forms[0]['startTime_time_minute'].value);
end = parseInt(document.forms[0]['dueTime_time_minute'].value);
if (start > end) {
alert(labels.validate_endbeforestart.decodeEntities());
return false;
}
}
}
return true;
} }
function toggleDetails() { function toggleDetails() {
var div = $("details"); var div = $("details");
var buttons = $("buttons"); var buttons = $("buttons");
var buttonsHeight = buttons.clientHeight * 3; var buttonsHeight = buttons.clientHeight * 3;
if (div.style.visibility) { if (div.style.visibility) {
div.style.visibility = null; div.style.visibility = null;
window.resizeBy(0, -(div.clientHeight + buttonsHeight)); window.resizeBy(0, -(div.clientHeight + buttonsHeight));
$("detailsButton").innerHTML = labels["Show Details"]; $("detailsButton").innerHTML = labels["Show Details"];
} else { } else {
div.style.visibility = 'visible;'; div.style.visibility = 'visible;';
window.resizeBy(0, (div.clientHeight + buttonsHeight)); window.resizeBy(0, (div.clientHeight + buttonsHeight));
$("detailsButton").innerHTML = labels["Hide Details"]; $("detailsButton").innerHTML = labels["Hide Details"];
} }
return false; return false;
} }
function toggleCycleVisibility(node, nodeName, hiddenValue) { function toggleCycleVisibility(node, nodeName, hiddenValue) {
var spanNode = $(nodeName); var spanNode = $(nodeName);
var newVisibility = ((node.value == hiddenValue) ? null : 'visible;'); var newVisibility = ((node.value == hiddenValue) ? null : 'visible;');
spanNode.style.visibility = newVisibility; spanNode.style.visibility = newVisibility;
if (nodeName == 'cycleSelectionFirstLevel') { if (nodeName == 'cycleSelectionFirstLevel') {
var otherSpanNode = $('cycleSelectionSecondLevel'); var otherSpanNode = $('cycleSelectionSecondLevel');
if (!newVisibility) if (!newVisibility)
{ {
otherSpanNode.superVisibility = otherSpanNode.style.visibility; otherSpanNode.superVisibility = otherSpanNode.style.visibility;
otherSpanNode.style.visibility = null; otherSpanNode.style.visibility = null;
} }
else else
{ {
otherSpanNode.style.visibility = otherSpanNode.superVisibility; otherSpanNode.style.visibility = otherSpanNode.superVisibility;
otherSpanNode.superVisibility = null; otherSpanNode.superVisibility = null;
} }
} }
} }
function addContact(tag, fullContactName, contactId, contactName, contactEmail) function addContact(tag, fullContactName, contactId, contactName, contactEmail)
{ {
var uids = $('uixselector-participants-uidList'); var uids = $('uixselector-participants-uidList');
log ("contactId: " + contactId); log ("contactId: " + contactId);
if (contactId) if (contactId)
{ {
var re = new RegExp("(^|,)" + contactId + "($|,)"); var re = new RegExp("(^|,)" + contactId + "($|,)");
log ("uids: " + uids); log ("uids: " + uids);
if (!re.test(uids.value)) if (!re.test(uids.value))
{ {
log ("no match... realling adding"); log ("no match... realling adding");
if (uids.value.length > 0) if (uids.value.length > 0)
uids.value += ',' + contactId; uids.value += ',' + contactId;
else else
uids.value = contactId; uids.value = contactId;
log ('values: ' + uids.value); log ('values: ' + uids.value);
var names = $('uixselector-participants-display'); var names = $('uixselector-participants-display');
names.innerHTML += ('<li onmousedown="return false;"' names.innerHTML += ('<li onmousedown="return false;"'
+ ' onclick="onRowClick(event);"><img src="' + ' onclick="onRowClick(event);"><img src="'
+ ResourcesURL + '/abcard.gif" />' + ResourcesURL + '/abcard.gif" />'
+ contactName + '</li>'); + contactName + '</li>');
} }
else else
log ("match... ignoring contact"); log ("match... ignoring contact");
} }
return false; return false;
}
function onTimeControlCheck(checkBox) {
var inputs = checkBox.parentNode.getElementsByTagName("input");
var selects = checkBox.parentNode.getElementsByTagName("select");
for (var i = 0; i < inputs.length; i++)
if (inputs[i] != checkBox)
inputs[i].disabled = !checkBox.checked;
for (var i = 0; i < selects.length; i++)
if (selects[i] != checkBox)
selects[i].disabled = !checkBox.checked;
} }