switching items from one calendar to another now correctly propagated to all interested parties including necessary status update

This commit is contained in:
michael.buettner%sun.com 2006-08-04 13:44:06 +00:00
Родитель ab1eec7d03
Коммит 4de28769ed
5 изменённых файлов: 210 добавлений и 122 удалений

Просмотреть файл

@ -1476,41 +1476,7 @@
var item = args.calendarEvent;
var calendar = item.calendar;
// set 'mIsReadOnly' if the calendar is read-only
if (calendar && calendar.readOnly)
this.mIsReadOnly = true;
// assume we're the organizer [in case that the calendar
// does not support the concept of identities].
this.mIsOrganizer = true;
try {
this.mUserID = "";
this.mCalID = "";
this.mOrganizerID = "";
var provider = item.calendar.QueryInterface(Components.interfaces.calIWcapCalendar);
this.mCalID = provider.calId;
this.mUserID = provider.session.userId;
this.mOrganizerID = ((item.organizer == null || item.organizer.id == null)
? this.mCalID // sensible default
: item.organizer.id);
// set 'mIsOrganizer' if the current calid originally scheduled this event.
this.mIsOrganizer = false;
if(this.mCalID == this.mOrganizerID)
this.mIsOrganizer = true;
// display the organizer [try to get the common name from the calid]
var organizerRow = document.getAnonymousElementByAttribute(this, "anonid", "event-organizer-row");
organizerRow.removeAttribute("collapsed");
var organizer = document.getAnonymousElementByAttribute(this, "anonid", "event-organizer");
organizer.value = this.mOrganizerID;
var props = provider.getCalendarProperties("X-S1CS-CALPROPS-COMMON-NAME",{});
if(props.length > 0)
organizer.value = props[0];
}
catch(e) {}
this.onChangeCalendar(calendar);
// we need to enfore several layout constraints which can't be modelled
// with plain xul and css, at least as far as i know.
@ -1535,11 +1501,6 @@
}
}
if(this.mIsReadOnly || !this.mIsOrganizer) {
document.getAnonymousElementByAttribute(this, "anonid", "next-slot").setAttribute('disabled', 'true');
document.getAnonymousElementByAttribute(this, "anonid", "previous-slot").setAttribute('disabled', 'true');
}
this.setTimeRange(item.startDate,item.endDate);
]]>
</body>
@ -1558,6 +1519,62 @@
</body>
</method>
<method name="onChangeCalendar">
<parameter name="calendar"/>
<body>
<![CDATA[
var args = window.arguments[0];
var item = args.calendarEvent;
// set 'mIsReadOnly' if the calendar is read-only
if (calendar && calendar.readOnly)
this.mIsReadOnly = true;
// assume we're the organizer [in case that the calendar
// does not support the concept of identities].
this.mIsOrganizer = true;
var organizerRow = document.getAnonymousElementByAttribute(this, "anonid", "event-organizer-row");
organizerRow.setAttribute("collapsed","true");
try {
this.mUserID = "";
this.mCalID = "";
this.mOrganizerID = "";
var provider = calendar.QueryInterface(Components.interfaces.calIWcapCalendar);
this.mCalID = provider.calId;
this.mUserID = provider.session.userId;
this.mOrganizerID = ((item.organizer == null || item.organizer.id == null)
? this.mCalID // sensible default
: item.organizer.id);
// set 'mIsOrganizer' if the current calid originally scheduled this event.
this.mIsOrganizer = false;
if(this.mCalID == this.mOrganizerID)
this.mIsOrganizer = true;
// display the organizer [try to get the common name from the calid]
organizerRow.removeAttribute("collapsed");
var organizer = document.getAnonymousElementByAttribute(this, "anonid", "event-organizer");
organizer.value = this.mOrganizerID;
var props = provider.getCalendarProperties("X-S1CS-CALPROPS-COMMON-NAME",{});
if(props.length > 0)
organizer.value = props[0];
}
catch(e) {}
if(this.mIsReadOnly || !this.mIsOrganizer) {
document.getAnonymousElementByAttribute(this, "anonid", "next-slot").setAttribute('disabled', 'true');
document.getAnonymousElementByAttribute(this, "anonid", "previous-slot").setAttribute('disabled', 'true');
}
var freebusy = document.getAnonymousElementByAttribute(this, "anonid", "freebusy-grid");
freebusy.onChangeCalendar(calendar);
]]>
</body>
</method>
<method name="onNextSlot">
<body>
<![CDATA[

Просмотреть файл

@ -1027,6 +1027,29 @@
</body>
</method>
<method name="onChangeCalendar">
<parameter name="calendar"/>
<body>
<![CDATA[
// query for the wcap interface, the appropriate functionality of this interface
// should be migrated to some other generic one instead of relying on the wcap provider.
this.mCalendar = null;
try {
this.mCalendar = calendar.QueryInterface(Components.interfaces.calIWcapCalendar);
}
catch (ex) {}
if (this.mMaxFreeBusy != 0) {
for (var i=1; i<=this.mMaxFreeBusy; i++) {
var freebusy = this.getFreeBusyElement(i);
freebusy.setAttribute("dirty","true");
}
this.updateFreeBusy();
}
]]>
</body>
</method>
<!-- appends a new empty row -->
<method name="appendNewRow">
<parameter name="aParentNode"/>
@ -1137,6 +1160,9 @@
var end = start.clone();
end.day += this.mRange;
// update with 'no data available' until response will be received
freebusy.onFreeBusy(null);
try {
if(this.mCalendar) {
@ -1145,9 +1171,6 @@
"### " + (msg ? msg : ""));
this.mConsoleService.logStringMessage(str);
// update with 'no data available' until response will be received
freebusy.onFreeBusy(null);
this.mFreeBusy.push(i);
this.mFreeBusySequence = this.mFreeBusy.length-1;

Просмотреть файл

@ -115,7 +115,7 @@
<!-- Calendar -->
<xul:row align="center">
<xul:label value="&newevent.server.label;" disable-on-readonly="true"/>
<xul:menulist id="item-calendar" flex="1" disable-on-readonly="true"/>
<xul:menulist id="item-calendar" oncommand="onChangeCalendar();" flex="1" disable-on-readonly="true"/>
</xul:row>
<!-- Category -->
@ -326,8 +326,13 @@
var calendars = getCalendarManager().getCalendars({});
for (i in calendars) {
var calendar = calendars[i];
if (calendar == item.calendar || calendar == window.arguments[0].calendar) {
var menuitem = calendarList.appendItem(calendar.name, i);
menuitem.calendar = calendar;
} else if (calendar && !calendar.readOnly) {
var menuitem = calendarList.appendItem(calendar.name, i);
menuitem.calendar = calendar;
}
}
// item default calendar
@ -504,46 +509,7 @@
// update datetime pickers
this.updateAllDay();
// set 'mIsReadOnly' if the calendar is read-only
if (calendar && calendar.readOnly)
this.mIsReadOnly = true;
// assume we're the organizer [in case that the calendar
// does not support the concept of identities].
this.mIsOrganizer = true;
try {
this.mUserID = "";
this.mCalID = "";
this.mOrganizerID = "";
var provider = item.calendar.QueryInterface(Components.interfaces.calIWcapCalendar);
this.mCalID = provider.calId;
this.mUserID = provider.session.userId;
this.mOrganizerID = ((item.organizer == null || item.organizer.id == null)
? this.mCalID // sensible default
: item.organizer.id);
// set 'mIsOrganizer' if the current calid originally scheduled this event.
this.mIsOrganizer = false;
if(this.mCalID == this.mOrganizerID)
this.mIsOrganizer = true;
}
catch(e) {}
if (!this.mIsReadOnly)
this.mIsReadOnly = !this.mIsOrganizer;
// update the accept button
this.updateAccept();
if(this.mIsReadOnly) {
var list = document.getAnonymousNodes(this)[0];
var disableElements = list.getElementsByAttribute("disable-on-readonly", "true");
for (i=0;i<disableElements.length;i++) {
disableElements[i].setAttribute('disabled', 'true');
}
}
this.onChangeCalendar();
document.getElementById("item-title").focus();
]]>
@ -668,6 +634,66 @@
</body>
</method>
<method name="onChangeCalendar">
<body>
<![CDATA[
var calendar = document.getElementById("item-calendar").selectedItem.calendar;
// set 'mIsReadOnly' if the calendar is read-only
this.mIsReadOnly = false;
if (calendar && calendar.readOnly)
this.mIsReadOnly = true;
// assume we're the organizer [in case that the calendar
// does not support the concept of identities].
this.mIsOrganizer = true;
try {
this.mUserID = "";
this.mCalID = "";
this.mOrganizerID = "";
var provider = calendar.QueryInterface(Components.interfaces.calIWcapCalendar);
this.mCalID = provider.calId;
this.mUserID = provider.session.userId;
this.mOrganizerID = ((item.organizer == null || item.organizer.id == null)
? this.mCalID // sensible default
: item.organizer.id);
// set 'mIsOrganizer' if the current calid originally scheduled this event.
this.mIsOrganizer = false;
if(this.mCalID == this.mOrganizerID)
this.mIsOrganizer = true;
}
catch(e) {}
if (!this.mIsReadOnly)
this.mIsReadOnly = !this.mIsOrganizer;
// update the accept button
this.updateAccept();
var list = document.getAnonymousNodes(this)[0];
if(this.mIsReadOnly) {
var disableElements = list.getElementsByAttribute("disable-on-readonly", "true");
for (i=0;i<disableElements.length;i++) {
disableElements[i].setAttribute('disabled', 'true');
}
} else {
var enableElements = list.getElementsByAttribute("disable-on-readonly", "true");
for (i=0;i<enableElements.length;i++) {
enableElements[i].removeAttribute('disabled');
}
}
var event = document.createEvent('Events');
event.initEvent('calendar', true, false);
event.details = calendar;
this.dispatchEvent(event);
]]>
</body>
</method>
<method name="onStartTimeChange">
<body>
<![CDATA[

Просмотреть файл

@ -299,45 +299,12 @@
var calendar = item.calendar;
var recinfo = item.recurrenceInfo;
// set 'mIsReadOnly' if the calendar is read-only
if (calendar && calendar.readOnly)
this.mIsReadOnly = true;
// assume we're the organizer [in case that the calendar
// does not support the concept of identities].
this.mIsOrganizer = true;
try {
this.mUserID = "";
this.mCalID = "";
this.mOrganizerID = "";
var provider = item.calendar.QueryInterface(Components.interfaces.calIWcapCalendar);
this.mCalID = provider.calId;
this.mUserID = provider.session.userId;
this.mOrganizerID = ((item.organizer == null || item.organizer.id == null)
? this.mCalID // sensible default
: item.organizer.id);
// set 'mIsOrganizer' if the current calid originally scheduled this event.
this.mIsOrganizer = false;
if(this.mCalID == this.mOrganizerID)
this.mIsOrganizer = true;
}
catch(e) {}
this.onChangeCalendar(calendar);
// set starting value for 'repeat until' rule.
this.mStartDate = item.startDate || item.entryDate || item.dueDate;
setElementValue("repeat-until-date", this.mStartDate);
// disable or enable controls based on a set or rules
// - whether this item is a stand-alone item or an occurrence
// - whether or not this item is read-only
// - whether or not the state of the item allows recurrence rules
// - tasks without an entrydate are invalid
this.disableOrEnable(item);
if(item.parentItem != item) {
item = item.parentItem;
}
@ -587,6 +554,53 @@
</body>
</method>
<method name="onChangeCalendar">
<parameter name="calendar"/>
<body>
<![CDATA[
var args = window.arguments[0];
var item = args.calendarEvent;
// set 'mIsReadOnly' if the calendar is read-only
this.mIsReadOnly = false;
if (calendar && calendar.readOnly)
this.mIsReadOnly = true;
// assume we're the organizer [in case that the calendar
// does not support the concept of identities].
this.mIsOrganizer = true;
try {
this.mUserID = "";
this.mCalID = "";
this.mOrganizerID = "";
var provider = calendar.QueryInterface(Components.interfaces.calIWcapCalendar);
this.mCalID = provider.calId;
this.mUserID = provider.session.userId;
this.mOrganizerID = ((item.organizer == null || item.organizer.id == null)
? this.mCalID // sensible default
: item.organizer.id);
// set 'mIsOrganizer' if the current calid originally scheduled this event.
this.mIsOrganizer = false;
if(this.mCalID == this.mOrganizerID)
this.mIsOrganizer = true;
}
catch(e) {}
// disable or enable controls based on a set or rules
// - whether this item is a stand-alone item or an occurrence
// - whether or not this item is read-only
// - whether or not the state of the item allows recurrence rules
// - tasks without an entrydate are invalid
this.disableOrEnable(item);
this.updateRecurrenceControls();
]]>
</body>
</method>
<method name="disableRecurrenceFields">
<parameter name="aAttributeName"/>
<body>

Просмотреть файл

@ -91,6 +91,14 @@ function onLoad()
};
window.addEventListener('warning', warning, true);
var calendar = function calendarHandler(event) {
var recurrencepage = document.getElementById("recurrence-page");
recurrencepage.onChangeCalendar(event.details);
var attendeespage = document.getElementById("attendees-page");
attendeespage.onChangeCalendar(event.details);
};
window.addEventListener('calendar', calendar, true);
// figure out what the title of the dialog should be and set it
updateTitle();