Skip to content

Commit c8c2f19

Browse files
authored
added taskFilter property to mgt-tasks (#211)
1 parent 470f543 commit c8c2f19

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

src/components/mgt-tasks/mgt-tasks.ts

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
* -------------------------------------------------------------------------------------------
66
*/
77

8-
import { Person, PlannerAssignments, User } from '@microsoft/microsoft-graph-types';
9-
import { Contact, OutlookTaskFolder } from '@microsoft/microsoft-graph-types-beta';
8+
import { Person, PlannerAssignments, PlannerTask, User } from '@microsoft/microsoft-graph-types';
9+
import { Contact, OutlookTask, OutlookTaskFolder } from '@microsoft/microsoft-graph-types-beta';
1010
import { customElement, html, property } from 'lit-element';
1111
import { classMap } from 'lit-html/directives/class-map';
1212
import { repeat } from 'lit-html/directives/repeat';
@@ -192,6 +192,13 @@ export class MgtTasks extends MgtTemplatedComponent {
192192
@property({ attribute: 'group-id', type: String })
193193
public groupId: string = null;
194194

195+
/**
196+
* Optional filter function when rendering tasks
197+
*
198+
* @memberof MgtTasks
199+
*/
200+
public taskFilter: (task: PlannerTask | OutlookTask) => boolean;
201+
195202
@property() private _isNewTaskVisible: boolean = false;
196203
@property() private _newTaskBeingAdded: boolean = false;
197204
@property() private _newTaskName: string = '';
@@ -313,11 +320,15 @@ export class MgtTasks extends MgtTemplatedComponent {
313320
* trigger the element to update.
314321
*/
315322
protected render() {
316-
const tasks = this._tasks
323+
let tasks = this._tasks
317324
.filter(task => this.isTaskInSelectedGroupFilter(task))
318325
.filter(task => this.isTaskInSelectedFolderFilter(task))
319326
.filter(task => !this._hiddenTasks.includes(task.id));
320327

328+
if (this.taskFilter) {
329+
tasks = tasks.filter(task => this.taskFilter(task._raw));
330+
}
331+
321332
const loadingTask = this._inTaskLoad && !this._hasDoneInitialLoad ? this.renderLoadingTask() : null;
322333

323334
let header;

0 commit comments

Comments
 (0)