Bug 940697 - Tasks have some menu items and controls wrongly enabled when the calendar is read-only. r=mmecca
authorDecathlon <bv1578@gmail.com>
Mon, 02 Dec 2013 23:33:30 +0100
changeset 16952 2c9924d0479d32292a4eb0a5d0293aeb6b9335b7
parent 16951 aeeb4b2ee2093a53029873206c47d508a3f33412
child 16953 65f8a8468c6a8c1e435131b7416023bac978d53f
push id1074
push userbugzilla@standard8.plus.com
push dateMon, 03 Feb 2014 22:47:23 +0000
treeherdercomm-beta@6b791b5369ed [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmmecca
bugs940697
Bug 940697 - Tasks have some menu items and controls wrongly enabled when the calendar is read-only. r=mmecca
calendar/base/content/calendar-common-sets.xul
calendar/base/content/calendar-task-tree.js
calendar/base/content/calendar-task-tree.xml
--- a/calendar/base/content/calendar-common-sets.xul
+++ b/calendar/base/content/calendar-common-sets.xul
@@ -70,17 +70,17 @@
     <command id="calendar_percentComplete-50_command" oncommand="contextChangeTaskProgress(event, 50)"/>
     <command id="calendar_percentComplete-75_command" oncommand="contextChangeTaskProgress(event, 75)"/>
     <command id="calendar_percentComplete-100_command" oncommand="contextChangeTaskProgress(event, 100)"/>
     <command id="calendar_priority-0_command" oncommand="contextChangeTaskPriority(event, 0)"/>
     <command id="calendar_priority-9_command" oncommand="contextChangeTaskPriority(event, 9)"/>
     <command id="calendar_priority-5_command" oncommand="contextChangeTaskPriority(event, 5)"/>
     <command id="calendar_priority-1_command" oncommand="contextChangeTaskPriority(event, 1)"/>
     <command id="calendar_general-priority_command" oncommand="goDoCommand('calendar_general-priority_command')"/>
-    <command id="calendar_general-progress_command" oncommand="goDoCommand('calendar_general-priority_command')"/>
+    <command id="calendar_general-progress_command" oncommand="goDoCommand('calendar_general-progress_command')"/>
     <command id="calendar_general-postpone_command"/>
     <command id="calendar_postpone-1hour_command" oncommand="contextPostponeTask(event, 'PT1H')"/>
     <command id="calendar_postpone-1day_command" oncommand="contextPostponeTask(event, 'P1D')"/>
     <command id="calendar_postpone-1week_command" oncommand="contextPostponeTask(event, 'P1W')"/>
     <command id="calendar_toggle_orientation_command" persist="checked" oncommand="goDoCommand('calendar_toggle_orientation_command')"/>
     <command id="calendar_toggle_workdays_only_command" persist="checked" oncommand="goDoCommand('calendar_toggle_workdays_only_command')"/>
     <command id="calendar_toggle_tasks_in_view_command" persist="checked" oncommand="toggleTasksInView()"/>
     <command id="calendar_toggle_show_completed_in_view_command" persist="checked" oncommand="toggleShowCompletedInView()"/>
@@ -382,27 +382,33 @@
                 type="checkbox"
                 autocheck="false"
                 label="&calendar.context.markcompleted.label;"
                 accesskey="&calendar.context.markcompleted.accesskey;"
                 observes="calendar_toggle_completed_command"
                 command="calendar_toggle_completed_command"/>
       <menu id="task-context-menu-progress"
             label="&calendar.context.progress.label;"
-            accesskey="&calendar.context.progress.accesskey;">
+            accesskey="&calendar.context.progress.accesskey;"
+            command="calendar_general-progress_command"
+            observes="calendar_general-progress_command">
         <menupopup id="progress-menupopup" type="task-progress"/>
       </menu>
       <menu id="task-context-menu-priority"
             label="&calendar.context.priority.label;"
-            accesskey="&calendar.context.priority.accesskey;">
+            accesskey="&calendar.context.priority.accesskey;"
+            command="calendar_general-priority_command"
+            observes="calendar_general-priority_command">
         <menupopup id="priority-menupopup" type="task-priority"/>
       </menu>
       <menu id="task-context-menu-postpone"
             label="&calendar.context.postpone.label;"
-            accesskey="&calendar.context.postpone.accesskey;">
+            accesskey="&calendar.context.postpone.accesskey;"
+            command="calendar_general-postpone_command"
+            observes="calendar_general-postpone_command">
         <menupopup id="task-context-postpone-menupopup">
           <menuitem id="task-context-postpone-1hour"
                     label="&calendar.context.postpone.1hour.label;"
                     accesskey="&calendar.context.postpone.1hour.accesskey;"
                     observes="calendar_postpone-1hour_command"/>
           <menuitem id="task-context-postpone-1day"
                     label="&calendar.context.postpone.1day.label;"
                     accesskey="&calendar.context.postpone.1day.accesskey;"
@@ -433,16 +439,17 @@
                     accesskey="&calendar.context.convertmenu.event.accesskey;"
                     oncommand="tasksToEvents(event)"/>
         </menupopup>
       </menu>
       <menuseparator/>
       <menuitem id="task-context-menu-delete"
                 label="&calendar.context.deletetask.label;"
                 accesskey="&calendar.context.deletetask.accesskey;"
+                command="calendar_delete_todo_command"
                 observes="calendar_delete_todo_command"/>
       <menu id="task-context-menu-attendance-menu"
             class="attendance-menu"
             label="&calendar.context.attendance.menu.label;"
             accesskey="&calendar.context.attendance.menu.accesskey;"
             oncommand="setContextPartstat(event.target.value, event.target.getAttribute('scope'), getSelectedTasks())"
             observes="calendar_attendance_command">
         <menupopup id="task-context-menu-attendance-menupopup">
--- a/calendar/base/content/calendar-task-tree.js
+++ b/calendar/base/content/calendar-task-tree.js
@@ -57,18 +57,19 @@ function changeContextMenuForTask(aEvent
         calendarController.isCommandEnabled("calendar_new_todo_todaypane_command")) {
         document.getElementById("calendar_new_todo_command").removeAttribute("disabled");
         document.getElementById("calendar_new_todo_todaypane_command").removeAttribute("disabled");
     } else {
         document.getElementById("calendar_new_todo_command").setAttribute("disabled", "true");
         document.getElementById("calendar_new_todo_todaypane_command").setAttribute("disabled", "true");
     }
 
-    // make sure the paste menu item is enabled
+    // make sure the "Paste" and "Cut" menu items are enabled
     goUpdateCommand("cmd_paste");
+    goUpdateCommand("cmd_cut");
 
     // make sure the filter menu is enabled
     document.getElementById("task-context-menu-filter-todaypane").removeAttribute("disabled");
     applyAttributeToMenuChildren(document.getElementById("task-context-menu-filter-todaypane-popup"),
                                  "disabled", false);
 
     changeMenuForTask(aEvent);
 
@@ -90,16 +91,23 @@ function handleTaskContextMenuStateChang
 }
 
 /**
  * Change the opening menu for the selected tasks.
  *
  * @param aEvent    The popupshowing event of the opening menu.
  */
 function changeMenuForTask(aEvent) {
+    // Make sure to update the status of some commands. 
+    ["calendar_delete_todo_command",
+     "calendar_toggle_completed_command",
+     "calendar_general-progress_command",
+     "calendar_general-priority_command",
+     "calendar_general-postpone_command"].forEach(goUpdateCommand);
+
     let tasks = getSelectedTasks(aEvent);
     let tasksSelected = (tasks.length > 0);
     if (tasksSelected) {
         let cmd = document.getElementById("calendar_toggle_completed_command");
         if (isPropertyValueSame(tasks, "isCompleted")) {
             setBooleanAttribute(cmd, "checked", tasks[0].isCompleted);
         } else {
             setBooleanAttribute(cmd, "checked", false);
--- a/calendar/base/content/calendar-task-tree.xml
+++ b/calendar/base/content/calendar-task-tree.xml
@@ -538,18 +538,19 @@
               return properties.join(" ");
           },
 
           // Called on the view when a cell in a non-selectable cycling
           // column (e.g., unread/flag/etc.) is clicked.
           cycleCell: function mTV_cycleCell(aRow, aCol) {
               var task = this.binding.mTaskArray[aRow];
 
-              // prevent toggling completed status for parent items of repeating tasks
-              if (!task || task.recurrenceInfo) {
+              // prevent toggling completed status for parent items of
+              // repeating tasks or when the calendar is read-only.
+              if (!task || task.recurrenceInfo || task.calendar.readOnly) {
                   return;
               }
               if (aCol != null) {
                   var content = aCol.element.getAttribute("itemproperty");
                   if (content == "completed")  {
                       var newTask = task.clone().QueryInterface(Components.interfaces.calITodo);
                       newTask.isCompleted = !task.completedDate;
                       doTransaction('modify', newTask, newTask.calendar, task, null);