diff --git a/calendar/base/content/calendar-common-sets.js b/calendar/base/content/calendar-common-sets.js
index cff74451c59..432cdc8702d 100644
--- a/calendar/base/content/calendar-common-sets.js
+++ b/calendar/base/content/calendar-common-sets.js
@@ -95,13 +95,13 @@ var calendarController = {
isCommandEnabled: function cC_isCommandEnabled(aCommand) {
switch (aCommand) {
case "calendar_new_event_command":
- return this.writable;
+ return this.writable && this.calendars_support_events;
case "calendar_modify_event_command":
return this.item_selected;
case "calendar_delete_event_command":
return this.selected_items_writable;
case "calendar_new_todo_command":
- return this.writable;
+ return this.writable && this.calendars_support_tasks;
case "calendar_delete_todo_comand":
return this.writable; // XXX are selected todo items readonly?
@@ -350,6 +350,32 @@ var calendarController = {
this.item_selected &&
!this.selected_events_readonly &&
(!this.offline || !this.selected_events_requires_network);
+ },
+
+ get calendars_support_tasks() {
+ // XXX We might want to cache this
+ var calendars = getCalendarManager().getCalendars({});
+
+ for each (var cal in calendars) {
+ if (isCalendarWritable(cal) &&
+ cal.getProperty("capabilities.tasks.supported") !== false) {
+ return true;
+ }
+ }
+ return false;
+ },
+
+ get calendars_support_events() {
+ // XXX We might want to cache this
+ var calendars = getCalendarManager().getCalendars({});
+
+ for each (var cal in calendars) {
+ if (isCalendarWritable(cal) &&
+ cal.getProperty("capabilities.events.supported") !== false) {
+ return true;
+ }
+ }
+ return false;
}
};
diff --git a/calendar/base/content/calendar-item-editing.js b/calendar/base/content/calendar-item-editing.js
index 978dd060898..8cf0d27a12b 100644
--- a/calendar/base/content/calendar-item-editing.js
+++ b/calendar/base/content/calendar-item-editing.js
@@ -1,4 +1,3 @@
-/* -*- Mode: javascript; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
@@ -186,14 +185,30 @@ function openEventDialog(calendarItem, calendar, mode, callback, job)
mode = mode || "new";
calendar = calendar || getSelectedCalendar();
var calendars = getCalendarManager().getCalendars({});
- calendars = calendars.filter(function(el) { return !el.readOnly; });
+ calendars = calendars.filter(isCalendarWritable);
- if (calendar.readOnly && mode == "new" && calendars.length < 1) {
- // All calendars are marked readonly, don't show the dialog
+ var isItemSupported;
+ if (isToDo(calendarItem)) {
+ isItemSupported = function isTodoSupported(cal) {
+ return (cal.getProperty("capabilities.tasks.supported") !== false);
+ };
+ } else if (isEvent(calendarItem)) {
+ isItemSupported = function isEventSupported(cal) {
+ return (cal.getProperty("capabilities.events.supported") !== false);
+ };
+ }
+
+ // Filter out calendars that don't support the given calendar item
+ calendars = calendars.filter(isItemSupported);
+
+ if (mode == "new" && calendars.length < 1 &&
+ (!isCalendarWritable(calendar) || !isItemSupported(calendar))) {
+ // There are no writable calendars or no calendar supports the given
+ // item. Don't show the dialog.
return;
- } else if (calendar.readOnly && mode == "new") {
- // If the default calendar is marked readOnly, pick the first
- // non-readOnly calendar
+ } else if (mode == "new" &&
+ (!isCalendarWritable(calendar) || !isItemSupported(calendar))) {
+ // Pick the first calendar that supports the item and is writable
calendar = calendars[0];
if (calendarItem) {
// XXX The dialog currently uses the items calendar as a first
@@ -230,7 +245,7 @@ function openEventDialog(calendarItem, calendar, mode, callback, job)
// open the dialog modeless
var url = "chrome://calendar/content/sun-calendar-event-dialog.xul";
- if (isInvitation || calendar.readOnly) {
+ if (isInvitation || !isCalendarWritable(calendar)) {
url = "chrome://calendar/content/calendar-summary-dialog.xul";
}
openDialog(url, "_blank", "chrome,titlebar,resizable", args);
diff --git a/calendar/base/content/calendar-multiday-view.xml b/calendar/base/content/calendar-multiday-view.xml
index c89992c6743..d7e2e2a611c 100644
--- a/calendar/base/content/calendar-multiday-view.xml
+++ b/calendar/base/content/calendar-multiday-view.xml
@@ -1548,7 +1548,8 @@