Bug 293201 Activate the agenda filter r=dmose

This commit is contained in:
jminta%gmail.com 2005-09-27 00:57:02 +00:00
parent 1a64476844
commit 0bb57fc1dd
3 changed files with 51 additions and 14 deletions

View File

@ -231,6 +231,24 @@ calTodo.prototype = {
isPropertyPromoted: function (name) {
return (this.todoPromotedProps[name]);
},
getOccurrencesBetween: function(aStartDate, aEndDate, aCount) {
if (this.recurrenceInfo) {
return this.recurrenceInfo.getOccurrences(aStartDate, aEndDate, 0, aCount);
}
if (!this.entryDate && !this.dueDate)
return null;
if ((this.entryDate && this.entryDate.compare(aStartDate) >= 0 && this.entryDate.compare(aEndDate) <= 0) ||
(this.dueDate && this.dueDate.compare(aStartDate) >= 0 && this.dueDate.compare(aEndDate) <= 0))
{
aCount.value = 1;
return ([ this ]);
}
aCount.value = 0;
return null;
}
};
// var decl to prevent spurious error messages when loaded as component

View File

@ -10,11 +10,11 @@
<hbox>
<spacer flex="1"/>
<label value="View:"/>
<menulist label="View" oncommand="updateAgendaView(this);">
<menulist label="View" oncommand="agendaTreeView.updateFilter(this);">
<menupopup>
<menuitem label="All"/>
<menuitem label="Events"/>
<menuitem label="Tasks"/>
<menuitem label="All" value="all"/>
<menuitem label="Events" value="events"/>
<menuitem label="Tasks" value="tasks"/>
<!-- menuitem label="Reminders"/ -->
<menuseparator id="calendar-list-start"/>
<!--menuseparator id="calendar-list-end"/>
@ -34,4 +34,4 @@
<label value="Customize yer views!"/>
</deck>
</vbox>
</overlay>
</overlay>

View File

@ -148,7 +148,7 @@ function getCellText(row, column)
if (event instanceof Synthetic)
return "";
var start = event.startDate || event.entryDate;
var start = event.startDate || event.dueDate;
return start.toString();
};
@ -224,7 +224,9 @@ function hasNextSibling(row, afterIndex)
agendaTreeView.findPeriodForItem =
function findPeriodForItem(item)
{
var start = item.startDate || item.entryDate;
var start = item.startDate || item.dueDate;
if (!start)
return null;
if (start.compare(this.today.end) <= 0)
return this.today;
@ -279,8 +281,8 @@ function calendarUpdateComplete()
{
[this.today, this.tomorrow, this.soon].forEach(function(when) {
function compare(a, b) {
var ad = a.startDate || a.entryDate;
var bd = b.startDate || b.entryDate;
var ad = a.startDate || a.dueDate;
var bd = b.startDate || b.dueDate;
return ad.compare(bd);
}
when.events.sort(compare);
@ -312,9 +314,22 @@ function listener_onGetResult(calendar, status, itemtype, detail, count, items)
agendaTreeView.refreshCalendarQuery =
function refreshCalendarQuery()
{
var filter = this.calendar.ITEM_FILTER_TYPE_EVENT |
this.calendar.ITEM_FILTER_COMPLETED_ALL |
var filter = this.calendar.ITEM_FILTER_COMPLETED_ALL |
this.calendar.ITEM_FILTER_CLASS_OCCURRENCES;
if (!this.filterType)
this.filterType = 'all';
switch (this.filterType) {
case 'all':
filter |= this.calendar.ITEM_FILTER_TYPE_EVENT |
this.calendar.ITEM_FILTER_TYPE_TODO;
break;
case 'events':
filter |= this.calendar.ITEM_FILTER_TYPE_EVENT;
break;
case 'tasks':
filter |= this.calendar.ITEM_FILTER_TYPE_TODO;
break;
}
this.periods.forEach(function (p) { p.events = []; });
this.calendar.getItems(filter, 0, this.today.start, this.soon.end,
@ -322,6 +337,13 @@ function refreshCalendarQuery()
void("Calendar query started (" + this.today.start + " -> " + this.soon.end + ")\n");
};
agendaTreeView.updateFilter =
function updateAgendaFilter(menulist) {
this.filterType = menulist.selectedItem.value;
this.refreshCalendarQuery();
return;
};
agendaTreeView.refreshPeriodDates =
function refreshPeriodDates()
{
@ -367,9 +389,6 @@ agendaTreeView.calendarObserver.onLoad = function() {};
agendaTreeView.calendarObserver.onAddItem =
function observer_onAddItem(item)
{
if (!(item instanceof Components.interfaces.calIEvent))
return;
var occs = item.getOccurrencesBetween(this.agendaTreeView.today.start,
this.agendaTreeView.soon.end, {});
occs.forEach(this.agendaTreeView.addItem, this.agendaTreeView);