2002-06-27 17:59:51 +00:00
|
|
|
/* ***** BEGIN LICENSE BLOCK *****
|
|
|
|
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
|
|
|
*
|
|
|
|
* The contents of this file are subject to the Mozilla Public License Version
|
|
|
|
* 1.1 (the "License"); you may not use this file except in compliance with
|
|
|
|
* the License. You may obtain a copy of the License at
|
|
|
|
* http://www.mozilla.org/MPL/
|
|
|
|
*
|
|
|
|
* Software distributed under the License is distributed on an "AS IS" basis,
|
|
|
|
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
|
|
|
* for the specific language governing rights and limitations under the
|
|
|
|
* License.
|
|
|
|
*
|
|
|
|
* The Original Code is OEone Calendar Code, released October 31st, 2001.
|
|
|
|
*
|
|
|
|
* The Initial Developer of the Original Code is
|
|
|
|
* OEone Corporation.
|
|
|
|
* Portions created by the Initial Developer are Copyright (C) 2001
|
|
|
|
* the Initial Developer. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Contributor(s): Garth Smedley <garths@oeone.com>
|
|
|
|
* Mike Potter <mikep@oeone.com>
|
|
|
|
* Chris Charabaruk <coldacid@meldstar.com>
|
|
|
|
* Colin Phillips <colinp@oeone.com>
|
2002-07-30 19:19:50 +00:00
|
|
|
* ArentJan Banck <ajbanck@planet.nl>
|
2003-01-09 15:03:08 +00:00
|
|
|
* Curtis Jewell <csjewell@mail.freeshell.org>
|
2003-02-13 13:59:37 +00:00
|
|
|
* Eric Belhaire <eric.belhaire@ief.u-psud.fr>
|
2003-03-12 18:21:34 +00:00
|
|
|
* Mark Swaffer <swaff@fudo.org>
|
2002-06-27 17:59:51 +00:00
|
|
|
*
|
|
|
|
* Alternatively, the contents of this file may be used under the terms of
|
|
|
|
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
|
|
|
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
|
|
|
* in which case the provisions of the GPL or the LGPL are applicable instead
|
|
|
|
* of those above. If you wish to allow use of your version of this file only
|
|
|
|
* under the terms of either the GPL or the LGPL, and not to allow others to
|
|
|
|
* use your version of this file under the terms of the MPL, indicate your
|
|
|
|
* decision by deleting the provisions above and replace them with the notice
|
|
|
|
* and other provisions required by the GPL or the LGPL. If you do not delete
|
|
|
|
* the provisions above, a recipient may use your version of this file under
|
|
|
|
* the terms of any one of the MPL, the GPL or the LGPL.
|
|
|
|
*
|
|
|
|
* ***** END LICENSE BLOCK ***** */
|
|
|
|
|
|
|
|
/*-----------------------------------------------------------------
|
|
|
|
* U N I F I N D E R
|
|
|
|
*
|
|
|
|
* This is a hacked in interface to the unifinder. We will need to
|
|
|
|
* improve this to make it usable in general.
|
|
|
|
*/
|
|
|
|
|
2002-07-31 15:02:35 +00:00
|
|
|
const ToDoUnifinderTreeName = "unifinder-todo-tree";
|
2002-06-27 17:59:51 +00:00
|
|
|
|
2002-10-30 17:16:52 +00:00
|
|
|
var gTaskArray = new Array();
|
|
|
|
|
2002-06-27 17:59:51 +00:00
|
|
|
/**
|
|
|
|
* Observer for the calendar event data source. This keeps the unifinder
|
|
|
|
* display up to date when the calendar event data is changed
|
|
|
|
*/
|
|
|
|
|
|
|
|
var unifinderToDoDataSourceObserver =
|
|
|
|
{
|
|
|
|
onLoad : function()
|
|
|
|
{
|
2002-08-27 12:34:47 +00:00
|
|
|
toDoUnifinderRefresh();
|
2002-06-27 17:59:51 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onStartBatch : function()
|
|
|
|
{
|
|
|
|
},
|
|
|
|
|
|
|
|
onEndBatch : function()
|
|
|
|
{
|
2002-08-27 12:34:47 +00:00
|
|
|
toDoUnifinderRefresh();
|
2002-06-27 17:59:51 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onAddItem : function( calendarToDo )
|
|
|
|
{
|
2002-08-27 12:34:47 +00:00
|
|
|
toDoUnifinderRefresh();
|
2002-06-27 17:59:51 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onModifyItem : function( calendarToDo, originalToDo )
|
|
|
|
{
|
2002-10-30 18:23:30 +00:00
|
|
|
toDoUnifinderRefresh( );
|
2002-06-27 17:59:51 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onDeleteItem : function( calendarToDo )
|
|
|
|
{
|
2002-08-28 17:14:57 +00:00
|
|
|
if( !gICalLib.batchMode )
|
|
|
|
{
|
|
|
|
toDoUnifinderRefresh();
|
|
|
|
}
|
2002-06-27 17:59:51 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onAlarm : function( calendarToDo )
|
|
|
|
{
|
|
|
|
|
2003-06-04 20:42:44 +00:00
|
|
|
},
|
|
|
|
|
|
|
|
onError : function()
|
|
|
|
{
|
2002-06-27 17:59:51 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the calendar is loaded
|
|
|
|
*/
|
|
|
|
|
|
|
|
function prepareCalendarToDoUnifinder( )
|
|
|
|
{
|
|
|
|
// set up our calendar event observer
|
|
|
|
gICalLib.addTodoObserver( unifinderToDoDataSourceObserver );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the calendar is unloaded
|
|
|
|
*/
|
|
|
|
|
|
|
|
function finishCalendarToDoUnifinder( )
|
|
|
|
{
|
|
|
|
gICalLib.removeTodoObserver( unifinderToDoDataSourceObserver );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called by event observers to update the display
|
|
|
|
*/
|
|
|
|
|
2002-08-27 12:34:47 +00:00
|
|
|
function toDoUnifinderRefresh()
|
2002-06-27 17:59:51 +00:00
|
|
|
{
|
2002-07-24 13:19:34 +00:00
|
|
|
var Checked = document.getElementById( "only-completed-checkbox" ).checked;
|
|
|
|
|
2002-09-12 14:53:09 +00:00
|
|
|
gICalLib.resetFilter();
|
|
|
|
|
2002-07-24 13:19:34 +00:00
|
|
|
if( Checked === true )
|
2003-02-05 19:38:28 +00:00
|
|
|
gICalLib.filter.completed.setTime( new Date() );
|
2002-09-12 14:53:09 +00:00
|
|
|
|
2002-09-12 13:16:57 +00:00
|
|
|
var taskTable = gEventSource.getAllToDos();
|
2002-06-27 17:59:51 +00:00
|
|
|
|
2002-09-12 13:16:57 +00:00
|
|
|
refreshToDoTree( taskTable );
|
2002-06-27 17:59:51 +00:00
|
|
|
}
|
|
|
|
|
2002-07-31 15:02:35 +00:00
|
|
|
function getToDoFromEvent( event )
|
|
|
|
{
|
|
|
|
var tree = document.getElementById( ToDoUnifinderTreeName );
|
|
|
|
var row = new Object();
|
|
|
|
|
|
|
|
tree.treeBoxObject.getCellAt( event.clientX, event.clientY, row, {}, {} );
|
2002-10-28 21:37:27 +00:00
|
|
|
|
2002-07-31 15:02:35 +00:00
|
|
|
if( row.value != -1 && row.value < tree.view.rowCount )
|
|
|
|
{
|
2002-10-30 17:16:52 +00:00
|
|
|
return( tree.taskView.getCalendarTaskAtRow( row.value ) );
|
2002-07-31 15:02:35 +00:00
|
|
|
}
|
2002-11-27 15:20:28 +00:00
|
|
|
return false;
|
2002-07-31 15:02:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
function getSelectedToDo()
|
|
|
|
{
|
|
|
|
var tree = document.getElementById( ToDoUnifinderTreeName );
|
|
|
|
// .toDo object sometimes isn't available?
|
2002-10-30 17:16:52 +00:00
|
|
|
return( tree.taskView.getCalendarTaskAtRow(tree.currentIndex) );
|
|
|
|
|
2002-07-31 15:02:35 +00:00
|
|
|
}
|
|
|
|
|
2002-06-27 17:59:51 +00:00
|
|
|
/**
|
|
|
|
* This is attached to the onclik attribute of the to do list shown in the unifinder
|
|
|
|
*/
|
|
|
|
|
2002-10-30 17:16:52 +00:00
|
|
|
function modifyToDoCommand( event )
|
2002-06-27 17:59:51 +00:00
|
|
|
{
|
2003-02-13 15:56:09 +00:00
|
|
|
// we only care about button 0 (left click) events
|
|
|
|
if (event.button != 0) return;
|
|
|
|
|
2002-08-02 14:54:26 +00:00
|
|
|
//open the edit todo dialog box
|
2002-07-31 15:02:35 +00:00
|
|
|
var ThisToDo = getToDoFromEvent( event );
|
2003-02-05 19:38:28 +00:00
|
|
|
|
2002-07-31 15:02:35 +00:00
|
|
|
if( ThisToDo )
|
2002-08-02 14:54:26 +00:00
|
|
|
editToDo( ThisToDo );
|
2003-03-14 20:35:47 +00:00
|
|
|
else
|
|
|
|
newToDoCommand();
|
2002-08-02 14:54:26 +00:00
|
|
|
}
|
2002-06-27 17:59:51 +00:00
|
|
|
|
2002-08-02 14:54:26 +00:00
|
|
|
/**
|
|
|
|
* Set the context menu on mousedown to change it before it is opened
|
|
|
|
*/
|
|
|
|
|
|
|
|
function unifinderMouseDownToDo( event )
|
|
|
|
{
|
|
|
|
var tree = document.getElementById( ToDoUnifinderTreeName );
|
|
|
|
var treechildren = tree.getElementsByTagName( "treechildren" )[0];
|
|
|
|
|
|
|
|
var ThisToDo = getToDoFromEvent( event );
|
|
|
|
if( ThisToDo )
|
|
|
|
{
|
|
|
|
if(event.button == 2)
|
|
|
|
treechildren.setAttribute("context", "taskitem-context-menu")
|
|
|
|
|
|
|
|
// TODO HACK notifiers should be rewritten to integrate events and todos
|
2003-01-31 18:26:19 +00:00
|
|
|
document.getElementById( "delete_todo_command" ).removeAttribute( "disabled" );
|
2002-08-15 20:14:46 +00:00
|
|
|
document.getElementById( "print_command" ).setAttribute( "disabled", "true" );
|
2002-08-02 14:54:26 +00:00
|
|
|
} else
|
|
|
|
{
|
|
|
|
if(event.button == 2)
|
|
|
|
treechildren.setAttribute("context", "context-menu");
|
|
|
|
tree.treeBoxObject.selection.clearSelection();
|
|
|
|
|
|
|
|
// TODO HACK notifiers should be rewritten to integrate events and todos
|
2003-01-31 18:26:19 +00:00
|
|
|
document.getElementById( "delete_todo_command" ).setAttribute( "disabled", "true" );
|
2002-08-15 20:14:46 +00:00
|
|
|
// printing tasks not supported
|
|
|
|
document.getElementById( "print_command" ).setAttribute( "disabled", "true" );
|
2002-08-02 14:54:26 +00:00
|
|
|
}
|
2002-06-27 17:59:51 +00:00
|
|
|
}
|
|
|
|
|
2002-07-31 15:02:35 +00:00
|
|
|
function checkboxClick( ThisToDo, completed )
|
2002-06-27 17:59:51 +00:00
|
|
|
{
|
2002-07-30 19:19:50 +00:00
|
|
|
// var ThisToDo = event.currentTarget.parentNode.parentNode.toDo;
|
2002-07-31 15:02:35 +00:00
|
|
|
if( completed )
|
2002-06-27 17:59:51 +00:00
|
|
|
{
|
|
|
|
var completedTime = new Date();
|
|
|
|
|
|
|
|
ThisToDo.completed.setTime( completedTime );
|
2002-07-25 14:26:22 +00:00
|
|
|
|
|
|
|
ThisToDo.status = ThisToDo.ICAL_STATUS_COMPLETED;
|
|
|
|
|
2002-06-27 17:59:51 +00:00
|
|
|
}
|
|
|
|
else
|
2002-07-25 14:26:22 +00:00
|
|
|
{
|
2002-06-27 17:59:51 +00:00
|
|
|
ThisToDo.completed.clear();
|
|
|
|
|
2002-07-25 14:26:22 +00:00
|
|
|
if( ThisToDo.percent == 0 )
|
|
|
|
ThisToDo.status = ThisToDo.ICAL_STATUS_NEEDSACTION;
|
|
|
|
else
|
|
|
|
ThisToDo.status = ThisToDo.ICAL_STATUS_INPROCESS;
|
|
|
|
}
|
2002-06-27 17:59:51 +00:00
|
|
|
gICalLib.modifyTodo( ThisToDo );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2003-02-13 13:59:37 +00:00
|
|
|
/*
|
|
|
|
This function return the progress state of a ToDo task :
|
2003-03-12 18:21:34 +00:00
|
|
|
completed, overdue, duetoday, inprogress, future
|
2003-02-13 13:59:37 +00:00
|
|
|
*/
|
|
|
|
function ToDoProgressAtom( calendarToDo )
|
2002-10-30 17:16:52 +00:00
|
|
|
{
|
|
|
|
var now = new Date();
|
|
|
|
|
2002-07-05 18:41:18 +00:00
|
|
|
var thisMorning = new Date( now.getFullYear(), now.getMonth(), now.getDate(), 0, 0, 0 );
|
2002-10-30 17:16:52 +00:00
|
|
|
|
2002-06-27 17:59:51 +00:00
|
|
|
var completed = calendarToDo.completed.getTime();
|
2002-10-30 17:16:52 +00:00
|
|
|
|
2002-06-27 17:59:51 +00:00
|
|
|
if( completed > 0 )
|
2002-07-02 13:52:07 +00:00
|
|
|
{
|
2003-02-13 13:59:37 +00:00
|
|
|
return("completed");
|
2002-07-02 13:52:07 +00:00
|
|
|
}
|
2002-10-30 17:16:52 +00:00
|
|
|
|
2002-07-31 15:02:35 +00:00
|
|
|
var startDate = new Date( calendarToDo.start.getTime() );
|
2002-10-30 17:16:52 +00:00
|
|
|
var dueDate = new Date( calendarToDo.due.getTime() );
|
2002-08-26 18:47:22 +00:00
|
|
|
var tonightMidnight = new Date( now.getFullYear(), now.getMonth(), now.getDate(), 23, 59, 00 );
|
2002-10-30 17:16:52 +00:00
|
|
|
|
2002-08-16 13:34:44 +00:00
|
|
|
if( tonightMidnight.getTime() > dueDate.getTime() )
|
2002-07-02 13:52:07 +00:00
|
|
|
{
|
2003-02-13 13:59:37 +00:00
|
|
|
return("overdue");
|
|
|
|
} else
|
|
|
|
if ( dueDate.getFullYear() == now.getFullYear() &&
|
2002-08-26 18:47:22 +00:00
|
|
|
dueDate.getMonth() == now.getMonth() &&
|
|
|
|
dueDate.getDate() == now.getDate() )
|
|
|
|
{
|
2003-02-13 13:59:37 +00:00
|
|
|
return("duetoday");
|
2003-03-12 18:21:34 +00:00
|
|
|
} else
|
|
|
|
if( tonightMidnight.getTime() < startDate.getTime() )
|
|
|
|
{
|
|
|
|
return("future");
|
2002-08-26 18:47:22 +00:00
|
|
|
}
|
2003-03-12 18:21:34 +00:00
|
|
|
|
2002-08-26 18:47:22 +00:00
|
|
|
else
|
2002-07-31 15:02:35 +00:00
|
|
|
{
|
2003-02-13 13:59:37 +00:00
|
|
|
return("inprogress");
|
2002-07-02 13:52:07 +00:00
|
|
|
}
|
2003-02-13 13:59:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var toDoTreeView =
|
|
|
|
{
|
|
|
|
rowCount : gEventArray.length,
|
|
|
|
selectedColumn : null,
|
|
|
|
sortDirection : null,
|
|
|
|
|
|
|
|
isContainer : function(){return false;},
|
|
|
|
// By getCellProperties, the properties defined with
|
|
|
|
// treechildren:-moz-tree-cell-text in CSS are used.
|
|
|
|
// It is use here to color a particular row with a color
|
|
|
|
// given by the progress state of the ToDo task.
|
|
|
|
getCellProperties : function( row,column, props )
|
|
|
|
{
|
|
|
|
calendarToDo = gTaskArray[row];
|
|
|
|
var aserv=Components.classes["@mozilla.org/atom-service;1"].createInstance(Components.interfaces.nsIAtomService);
|
|
|
|
|
|
|
|
if( column == "unifinder-todo-tree-col-priority" )
|
|
|
|
{
|
2002-07-31 15:02:35 +00:00
|
|
|
if(calendarToDo.priority > 0 && calendarToDo.priority < 5)
|
2002-10-30 17:16:52 +00:00
|
|
|
props.AppendElement(aserv.getAtom("highpriority"));
|
2002-07-31 15:02:35 +00:00
|
|
|
if(calendarToDo.priority > 5 && calendarToDo.priority < 10)
|
2002-10-30 17:16:52 +00:00
|
|
|
props.AppendElement(aserv.getAtom("lowpriority"));
|
2003-02-13 13:59:37 +00:00
|
|
|
}
|
|
|
|
props.AppendElement(aserv.getAtom(ToDoProgressAtom(calendarToDo)));
|
|
|
|
},
|
|
|
|
getColumnProperties : function(){return false;},
|
2003-03-14 20:35:47 +00:00
|
|
|
// By getRowProperties, the properties defined with
|
2003-02-13 13:59:37 +00:00
|
|
|
// treechildren:-moz-tree-row in CSS are used.
|
|
|
|
// It is used here to color the background of a selected
|
|
|
|
// ToDo task with a color
|
|
|
|
// given by the progress state of the ToDo task.
|
|
|
|
getRowProperties : function( row,props ){
|
|
|
|
calendarToDo = gTaskArray[row];
|
|
|
|
|
|
|
|
var aserv=Components.classes["@mozilla.org/atom-service;1"].createInstance(Components.interfaces.nsIAtomService);
|
|
|
|
props.AppendElement(aserv.getAtom(ToDoProgressAtom( calendarToDo )));
|
2002-10-30 17:16:52 +00:00
|
|
|
},
|
|
|
|
isSorted : function(){return false;},
|
|
|
|
isEditable : function(){return true;},
|
|
|
|
isSeparator : function(){return false;},
|
2003-02-13 13:59:37 +00:00
|
|
|
// Return the empty string in order
|
|
|
|
// to use moz-tree-image pseudoelement :
|
|
|
|
// it is mandatory to return "" and not false :-(
|
|
|
|
getImageSrc : function(){return("");},
|
|
|
|
cycleCell : function(row,colId)
|
|
|
|
{
|
|
|
|
calendarToDo = gTaskArray[row];
|
2004-04-05 17:55:52 +00:00
|
|
|
if( !calendarToDo ) return;
|
2003-02-13 13:59:37 +00:00
|
|
|
|
|
|
|
if( colId == "unifinder-todo-tree-col-completed")
|
|
|
|
{
|
|
|
|
var completed = calendarToDo.completed.getTime();
|
|
|
|
|
|
|
|
if( completed > 0 )
|
|
|
|
checkboxClick( calendarToDo, false ) ;
|
|
|
|
else
|
|
|
|
checkboxClick( calendarToDo, true ) ;
|
|
|
|
}
|
|
|
|
},
|
2002-10-30 17:16:52 +00:00
|
|
|
cycleHeader : function( ColId, element )
|
|
|
|
{
|
|
|
|
var sortActive;
|
|
|
|
var treeCols;
|
|
|
|
|
|
|
|
this.selectedColumn = ColId;
|
|
|
|
sortActive = element.getAttribute("sortActive");
|
|
|
|
this.sortDirection = element.getAttribute("sortDirection");
|
|
|
|
|
|
|
|
if (sortActive != "true")
|
|
|
|
{
|
|
|
|
treeCols = document.getElementsByTagName("treecol");
|
|
|
|
for (var i = 0; i < treeCols.length; i++)
|
|
|
|
{
|
|
|
|
treeCols[i].removeAttribute("sortActive");
|
|
|
|
treeCols[i].removeAttribute("sortDirection");
|
|
|
|
}
|
|
|
|
sortActive = true;
|
|
|
|
this.sortDirection = "ascending";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sortActive = true;
|
|
|
|
if (this.sortDirection == "" || this.sortDirection == "descending")
|
|
|
|
{
|
|
|
|
this.sortDirection = "ascending";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
this.sortDirection = "descending";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
element.setAttribute("sortActive", sortActive);
|
|
|
|
element.setAttribute("sortDirection", this.sortDirection);
|
2002-11-01 20:46:46 +00:00
|
|
|
gTaskArray.sort( sortTasks );
|
2002-10-30 17:16:52 +00:00
|
|
|
document.getElementById( ToDoUnifinderTreeName ).view = this;
|
|
|
|
},
|
|
|
|
setTree : function( tree ){this.tree = tree;},
|
|
|
|
getCellText : function(row,column)
|
|
|
|
{
|
|
|
|
calendarToDo = gTaskArray[row];
|
|
|
|
if( !calendarToDo )
|
2002-11-27 15:20:28 +00:00
|
|
|
return false;
|
2002-07-02 13:52:07 +00:00
|
|
|
|
2002-10-30 17:16:52 +00:00
|
|
|
switch( column )
|
|
|
|
{
|
|
|
|
case "unifinder-todo-tree-col-completed":
|
2003-02-13 13:59:37 +00:00
|
|
|
return( "" );
|
2002-10-30 17:16:52 +00:00
|
|
|
|
|
|
|
case "unifinder-todo-tree-col-priority":
|
2003-02-13 13:59:37 +00:00
|
|
|
return( "" );
|
2002-10-30 17:16:52 +00:00
|
|
|
|
|
|
|
case "unifinder-todo-tree-col-title":
|
2002-11-27 15:20:28 +00:00
|
|
|
var titleText;
|
2002-10-30 17:16:52 +00:00
|
|
|
if( calendarToDo.title == "" )
|
2003-07-15 15:05:11 +00:00
|
|
|
titleText = gCalendarBundle.getString( "eventUntitled" );
|
2002-10-30 17:16:52 +00:00
|
|
|
else
|
2002-11-27 15:20:28 +00:00
|
|
|
titleText = calendarToDo.title;
|
2002-10-30 17:16:52 +00:00
|
|
|
return( titleText );
|
|
|
|
case "unifinder-todo-tree-col-startdate":
|
|
|
|
return( formatUnifinderEventDate( new Date( calendarToDo.start.getTime() ) ) );
|
|
|
|
case "unifinder-todo-tree-col-duedate":
|
|
|
|
return( formatUnifinderEventDate( new Date( calendarToDo.due.getTime() ) ) );
|
|
|
|
case "unifinder-todo-tree-col-completeddate":
|
|
|
|
return( formatUnifinderEventDate( new Date( calendarToDo.completed.getTime() ) ) );
|
|
|
|
case "unifinder-todo-tree-col-percentcomplete":
|
2003-01-13 13:46:34 +00:00
|
|
|
return( calendarToDo.percent+"%" );
|
2002-10-30 17:16:52 +00:00
|
|
|
case "unifinder-todo-tree-col-categories":
|
|
|
|
return( calendarToDo.categories );
|
2002-11-27 15:20:28 +00:00
|
|
|
default:
|
|
|
|
return false;
|
2002-10-30 17:16:52 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-06-27 17:59:51 +00:00
|
|
|
|
2002-11-01 20:46:46 +00:00
|
|
|
function sortTasks( TaskA, TaskB )
|
2002-10-30 17:16:52 +00:00
|
|
|
{
|
|
|
|
var modifier = 1;
|
|
|
|
if (toDoTreeView.sortDirection == "descending")
|
|
|
|
{
|
|
|
|
modifier = -1;
|
|
|
|
}
|
2002-06-27 17:59:51 +00:00
|
|
|
|
2002-10-30 17:16:52 +00:00
|
|
|
switch(toDoTreeView.selectedColumn)
|
|
|
|
{
|
2002-11-27 15:20:28 +00:00
|
|
|
case "unifinder-todo-tree-col-completed":
|
|
|
|
return( ((TaskA.completed.getTime() > TaskB.completed.getTime()) ? 1 : -1) * modifier );
|
|
|
|
|
|
|
|
case "unifinder-todo-tree-col-priority":
|
|
|
|
return( ((TaskA.priority > TaskB.priority) ? 1 : -1) * modifier );
|
2002-10-30 17:16:52 +00:00
|
|
|
|
2002-11-27 15:20:28 +00:00
|
|
|
case "unifinder-todo-tree-col-title":
|
2002-10-30 17:16:52 +00:00
|
|
|
return( ((TaskA.title > TaskB.title) ? 1 : -1) * modifier );
|
2002-11-27 15:20:28 +00:00
|
|
|
|
|
|
|
case "unifinder-todo-tree-col-startdate":
|
2002-10-30 17:16:52 +00:00
|
|
|
return( ((TaskA.start.getTime() > TaskB.start.getTime()) ? 1 : -1) * modifier );
|
2002-11-27 15:20:28 +00:00
|
|
|
|
|
|
|
case "unifinder-todo-tree-col-duedate":
|
2002-10-30 17:16:52 +00:00
|
|
|
return( ((TaskA.due.getTime() > TaskB.due.getTime()) ? 1 : -1) * modifier );
|
|
|
|
|
2002-11-27 15:20:28 +00:00
|
|
|
case "unifinder-todo-tree-col-completeddate":
|
|
|
|
return( ((TaskA.completed.getTime() > TaskB.completed.getTime()) ? 1 : -1) * modifier );
|
|
|
|
|
|
|
|
case "unifinder-todo-tree-col-percentcomplete":
|
2003-01-09 15:03:08 +00:00
|
|
|
return( ((TaskA.percent > TaskB.percent) ? 1 : -1) * modifier );
|
2002-11-27 15:20:28 +00:00
|
|
|
|
|
|
|
case "unifinder-todo-tree-col-categories":
|
|
|
|
return( ((TaskA.categories > TaskB.categories) ? 1 : -1) * modifier );
|
|
|
|
default:
|
|
|
|
return true;
|
2002-10-30 17:16:52 +00:00
|
|
|
}
|
2002-07-30 19:19:50 +00:00
|
|
|
}
|
|
|
|
|
2002-07-31 15:02:35 +00:00
|
|
|
|
2002-10-30 17:16:52 +00:00
|
|
|
function calendarTaskView( taskArray )
|
|
|
|
{
|
|
|
|
this.taskArray = taskArray;
|
|
|
|
}
|
2002-07-30 19:19:50 +00:00
|
|
|
|
2002-10-30 17:16:52 +00:00
|
|
|
calendarTaskView.prototype.getCalendarTaskAtRow = function( i )
|
2002-07-30 19:19:50 +00:00
|
|
|
{
|
2002-10-30 17:16:52 +00:00
|
|
|
return( gTaskArray[ i ] );
|
|
|
|
}
|
2002-09-11 18:29:06 +00:00
|
|
|
|
2002-10-30 17:16:52 +00:00
|
|
|
calendarTaskView.prototype.getRowOfCalendarTask = function( Task )
|
|
|
|
{
|
|
|
|
for( var i = 0; i < this.gTaskArray.length; i++ )
|
|
|
|
{
|
|
|
|
if( this.gTaskArray[i].id == Event.id )
|
|
|
|
return( i );
|
|
|
|
}
|
|
|
|
return( "null" );
|
|
|
|
}
|
2002-07-30 19:19:50 +00:00
|
|
|
|
2002-10-30 17:16:52 +00:00
|
|
|
/**
|
|
|
|
* Redraw the categories unifinder tree
|
|
|
|
*/
|
|
|
|
|
|
|
|
function refreshToDoTree( taskArray )
|
|
|
|
{
|
|
|
|
if( taskArray === false )
|
|
|
|
taskArray = getTaskTable();
|
|
|
|
|
|
|
|
gTaskArray = taskArray;
|
|
|
|
|
|
|
|
toDoTreeView.rowCount = gTaskArray.length;
|
|
|
|
|
2003-08-12 14:12:40 +00:00
|
|
|
var ArrayOfTreeCols = document.getElementById( ToDoUnifinderTreeName ).getElementsByTagName( "treecol" );
|
2002-11-05 18:44:27 +00:00
|
|
|
|
|
|
|
for( var i = 0; i < ArrayOfTreeCols.length; i++ )
|
|
|
|
{
|
|
|
|
if( ArrayOfTreeCols[i].getAttribute( "sortActive" ) == "true" )
|
|
|
|
{
|
2003-01-13 13:46:34 +00:00
|
|
|
toDoTreeView.selectedColumn = ArrayOfTreeCols[i].getAttribute( "id" );
|
|
|
|
toDoTreeView.sortDirection = ArrayOfTreeCols[i].getAttribute("sortDirection");
|
2002-11-05 18:44:27 +00:00
|
|
|
gTaskArray.sort(sortTasks);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2002-10-30 17:16:52 +00:00
|
|
|
document.getElementById( ToDoUnifinderTreeName ).view = toDoTreeView;
|
2002-06-27 17:59:51 +00:00
|
|
|
|
2002-10-30 17:16:52 +00:00
|
|
|
document.getElementById( ToDoUnifinderTreeName ).taskView = new calendarTaskView( gTaskArray );
|
2002-07-30 19:19:50 +00:00
|
|
|
}
|
|
|
|
|
2002-07-31 15:02:35 +00:00
|
|
|
|
2002-09-12 13:16:57 +00:00
|
|
|
function getTaskTable( )
|
|
|
|
{
|
|
|
|
var taskTable;
|
|
|
|
|
2002-09-12 14:53:09 +00:00
|
|
|
gICalLib.resetFilter();
|
|
|
|
|
2002-09-12 13:16:57 +00:00
|
|
|
if( document.getElementById( "only-completed-checkbox" ).getAttribute( "checked" ) == "true" )
|
|
|
|
{
|
|
|
|
var now = new Date();
|
|
|
|
|
|
|
|
gICalLib.filter.completed.setTime( now );
|
|
|
|
}
|
|
|
|
|
2002-11-27 15:20:28 +00:00
|
|
|
taskTable = gEventSource.getAllToDos();
|
2002-09-12 13:16:57 +00:00
|
|
|
|
|
|
|
return( taskTable );
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-09-03 18:42:28 +00:00
|
|
|
function contextChangeProgress( event, Progress )
|
2002-08-22 14:33:32 +00:00
|
|
|
{
|
2002-09-03 18:42:28 +00:00
|
|
|
var tree = document.getElementById( ToDoUnifinderTreeName );
|
|
|
|
|
2002-08-22 14:33:32 +00:00
|
|
|
if (tree.treeBoxObject.selection.count > 0)
|
|
|
|
{
|
2002-10-30 17:16:52 +00:00
|
|
|
var toDoItem = tree.taskView.getCalendarTaskAtRow( tree.currentIndex );
|
|
|
|
if(toDoItem)
|
2002-08-22 14:33:32 +00:00
|
|
|
{
|
2002-10-30 17:16:52 +00:00
|
|
|
toDoItem.percent = Progress;
|
|
|
|
gICalLib.modifyTodo( toDoItem );
|
2002-08-22 14:33:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2002-09-03 18:42:28 +00:00
|
|
|
function contextChangePriority( event, Priority )
|
2002-08-22 14:33:32 +00:00
|
|
|
{
|
2002-09-03 18:42:28 +00:00
|
|
|
var tree = document.getElementById( ToDoUnifinderTreeName );
|
|
|
|
|
2002-08-22 14:33:32 +00:00
|
|
|
if (tree.treeBoxObject.selection.count > 0)
|
|
|
|
{
|
2002-10-30 17:16:52 +00:00
|
|
|
var toDoItem = tree.taskView.getCalendarTaskAtRow( tree.currentIndex );
|
|
|
|
if(toDoItem)
|
2002-08-22 14:33:32 +00:00
|
|
|
{
|
2002-10-30 17:16:52 +00:00
|
|
|
toDoItem.priority = Priority;
|
|
|
|
gICalLib.modifyTodo( toDoItem );
|
2002-08-22 14:33:32 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-08-27 20:06:09 +00:00
|
|
|
|
|
|
|
function changeToolTipTextForToDo( event )
|
|
|
|
{
|
|
|
|
var toDoItem = getToDoFromEvent( event );
|
|
|
|
|
2002-10-30 17:16:52 +00:00
|
|
|
var Html = document.getElementById( "taskTooltip" );
|
2002-08-27 20:06:09 +00:00
|
|
|
|
|
|
|
while( Html.hasChildNodes() )
|
|
|
|
{
|
|
|
|
Html.removeChild( Html.firstChild );
|
|
|
|
}
|
2003-07-09 12:48:42 +00:00
|
|
|
var HolderBox = getPreviewTextForTask( toDoItem ) ;
|
|
|
|
if( HolderBox ) Html.appendChild( HolderBox ) ;
|
2002-08-27 20:06:09 +00:00
|
|
|
}
|
|
|
|
|
2002-10-28 21:37:27 +00:00
|
|
|
function changeContextMenuForToDo( event )
|
|
|
|
{
|
|
|
|
var toDoItem = getToDoFromEvent( event );
|
|
|
|
|
|
|
|
if( toDoItem )
|
|
|
|
{
|
|
|
|
var ArrayOfElements = document.getElementById( "taskitem-context-menu" ).getElementsByAttribute( "checked", "true" );
|
|
|
|
|
|
|
|
for( var i = 0; i < ArrayOfElements.length; i++ )
|
|
|
|
ArrayOfElements[i].removeAttribute( "checked" );
|
2002-08-27 20:06:09 +00:00
|
|
|
|
2002-10-28 21:37:27 +00:00
|
|
|
if( document.getElementById( "percent-"+toDoItem.percent+"-menuitem" ) )
|
|
|
|
{
|
|
|
|
document.getElementById( "percent-"+toDoItem.percent+"-menuitem" ).setAttribute( "checked", "true" );
|
|
|
|
}
|
|
|
|
|
|
|
|
if( document.getElementById( "priority-"+toDoItem.priority+"-menuitem" ) )
|
|
|
|
{
|
|
|
|
document.getElementById( "priority-"+toDoItem.priority+"-menuitem" ).setAttribute( "checked", "true" );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2002-10-30 18:23:30 +00:00
|
|
|
|