Bug 299163: add a calITodo.isCompleted for some semblance of sane completion

handling. r=pavlov.
This commit is contained in:
shaver%mozilla.org 2005-06-30 21:59:22 +00:00
Родитель 039eac9e8d
Коммит 7ecfd9c993
2 изменённых файлов: 48 добавлений и 5 удалений

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

@ -69,5 +69,30 @@ interface calITodo : calIItemBase
attribute calIDateTime dueDate;
attribute calIDateTime completedDate;
attribute short percentComplete;
// A todo isCompleted if any of the following is true:
// - percentComplete is 100, or
// - completedDate is non-null, or
// - status is COMPLETED.
// Setting isCompleted to true will
// - set percentComplete to 100, and
// - set completedDate to the current time, if it is not already set, and
// - set status to COMPLETED.
// Setting isCompleted to false will remove percentComplete, completedDate,
// and status properties. (This returns the todo to its state at creation,
// in terms of completion-relevant properties.)
//
// If you would like to take advantage of the full, confusing disaster that
// is the RFC2445 VTODO status state space, you can feel free to set the
// fields individually, instead of setting isCompleted directly. (And then
// hope that whatever else you're talking to has the same set of rules for
// determining if something is completed or not.)
//
// Setting percentComplete, completedDate, or status individually does not
// affect any of the others at present. (E.g., setting the percentComplete
// from 100 to 50 doesn't clear completedDate, or change status to
// IN-PROCESS.) It's not clear that we want any more magic than a simple
// property to control "all complete" vs "not complete in any way".
attribute boolean isCompleted;
};

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

@ -54,7 +54,6 @@ function calTodo() {
"DTSTAMP": true,
"DUE": true,
"COMPLETED": true,
"PERCENT-COMPLETE": true,
__proto__: this.itemBasePromotedProps
};
}
@ -97,12 +96,12 @@ calTodo.prototype = {
if (aIID.equals(Components.interfaces.nsIClassInfo))
return calTodoClassInfo;
return this.__proto__.__proto__.QueryInterface.apply(this, aIID);
return this.__proto__.__proto__.QueryInterface.call(this, aIID);
},
initTodo: function () {
// todos by default don't have any of the dates set
this.percentComplete = 0;
// todos by default don't have any of the dates set, or status, or
// percentComplete
},
cloneShallow: function (aNewParent) {
@ -141,6 +140,25 @@ calTodo.prototype = {
this.makeItemBaseImmutable();
},
get isCompleted() {
return this.completedDate != null ||
this.percentComplete == 100 ||
this.status == "COMPLETED";
},
set isCompleted(v) {
if (v) {
if (!this.completedDate)
this.completedDate = NewCalDateTime(new Date);
this.status = "COMPLETED";
this.percentComplete = 100;
} else {
this.deleteProperty("COMPLETED");
this.deleteProperty("STATUS");
this.deleteProperty("PERCENT-COMPLETE");
}
},
get recurrenceStartDate() {
return this.entryDate;
},
@ -178,7 +196,7 @@ calTodo.prototype = {
var iprop = bagenum.getNext().
QueryInterface(Components.interfaces.nsIProperty);
try {
if (!this.eventPromotedProps[iprop.name]) {
if (!this.todoPromotedProps[iprop.name]) {
var icalprop = icssvc.createIcalProperty(iprop.name);
icalprop.stringValue = iprop.value;
icalcomp.addProperty(icalprop);