|
5 | 5 | * ------------------------------------------------------------------------------------------- |
6 | 6 | */ |
7 | 7 |
|
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'; |
10 | 10 | import { customElement, html, property } from 'lit-element'; |
11 | 11 | import { classMap } from 'lit-html/directives/class-map'; |
12 | 12 | import { repeat } from 'lit-html/directives/repeat'; |
@@ -192,6 +192,13 @@ export class MgtTasks extends MgtTemplatedComponent { |
192 | 192 | @property({ attribute: 'group-id', type: String }) |
193 | 193 | public groupId: string = null; |
194 | 194 |
|
| 195 | + /** |
| 196 | + * Optional filter function when rendering tasks |
| 197 | + * |
| 198 | + * @memberof MgtTasks |
| 199 | + */ |
| 200 | + public taskFilter: (task: PlannerTask | OutlookTask) => boolean; |
| 201 | + |
195 | 202 | @property() private _isNewTaskVisible: boolean = false; |
196 | 203 | @property() private _newTaskBeingAdded: boolean = false; |
197 | 204 | @property() private _newTaskName: string = ''; |
@@ -313,11 +320,15 @@ export class MgtTasks extends MgtTemplatedComponent { |
313 | 320 | * trigger the element to update. |
314 | 321 | */ |
315 | 322 | protected render() { |
316 | | - const tasks = this._tasks |
| 323 | + let tasks = this._tasks |
317 | 324 | .filter(task => this.isTaskInSelectedGroupFilter(task)) |
318 | 325 | .filter(task => this.isTaskInSelectedFolderFilter(task)) |
319 | 326 | .filter(task => !this._hiddenTasks.includes(task.id)); |
320 | 327 |
|
| 328 | + if (this.taskFilter) { |
| 329 | + tasks = tasks.filter(task => this.taskFilter(task._raw)); |
| 330 | + } |
| 331 | + |
321 | 332 | const loadingTask = this._inTaskLoad && !this._hasDoneInitialLoad ? this.renderLoadingTask() : null; |
322 | 333 |
|
323 | 334 | let header; |
|
0 commit comments