|
| 1 | +# MgtTodo Component |
| 2 | + |
| 3 | +The Todo component enables the user to view, add, remove, complete, or edit tasks. It works with tasks from the Microsoft To-Do API. |
| 4 | + |
| 5 | +## Properties |
| 6 | + |
| 7 | +| Attribute | Property | Description | |
| 8 | +| -- | -- | -- | |
| 9 | +| read-only | readOnly | A Boolean to set the task interface to be read only (no adding or removing tasks). Default is `false`. | |
| 10 | +| hide-header | hideHeader | A Boolean to show or hide the header of the component. Default is `false`. | |
| 11 | +| hide-options | hideOptions | A Boolean to show or hide the options in tasks. Default is `false`. |
| 12 | +| initial-id="folder_id" | initialId | A string ID to set the initially displayed folder to the provided ID. | |
| 13 | +| target-id="folder_id"| targetId | A string ID to lock the tasks interface to the provided folder ID. | |
| 14 | +| N/A | isNewTaskVisible | Determines whether new task view is visible at render. | |
| 15 | +| N/A | taskFilter | An optional function to filter which tasks are shown to the user. | |
| 16 | + |
| 17 | +The following example shows only tasks from the folder with ID *12345* and does not allow the user to create new tasks. |
| 18 | + |
| 19 | +```html |
| 20 | +<mgt-todo read-only initial-id="12345"></mgt-todo> |
| 21 | +``` |
| 22 | + |
| 23 | +## Custom CSS variables |
| 24 | + |
| 25 | +````css |
| 26 | +mgt-todo { |
| 27 | + --tasks-background-color |
| 28 | + --tasks-header-padding |
| 29 | + --tasks-title-padding |
| 30 | + --tasks-plan-title-font-size |
| 31 | + --tasks-plan-title-padding |
| 32 | + |
| 33 | + --tasks-new-button-width |
| 34 | + --tasks-new-button-height |
| 35 | + --tasks-new-button-color |
| 36 | + --tasks-new-button-background |
| 37 | + --tasks-new-button-border |
| 38 | + --tasks-new-button-hover-background |
| 39 | + --tasks-new-button-active-background |
| 40 | + |
| 41 | + --task-margin |
| 42 | + --task-background |
| 43 | + --task-border |
| 44 | + --task-header-color |
| 45 | + --task-header-margin |
| 46 | + |
| 47 | + --task-new-margin |
| 48 | + --task-new-border |
| 49 | + --task-new-input-margin |
| 50 | + --task-new-input-padding |
| 51 | + --task-new-input-font-size |
| 52 | + --task-new-select-border |
| 53 | + |
| 54 | + --task-new-add-button-background |
| 55 | + --task-new-add-button-disabled-background |
| 56 | + --task-new-cancel-button-color |
| 57 | + |
| 58 | + --task-complete-background |
| 59 | + --task-complete-border |
| 60 | + |
| 61 | + --task-icon-alignment: flex-start (default) | center | flex-end |
| 62 | + --task-icon-background |
| 63 | + --task-icon-background-completed |
| 64 | + --task-icon-border |
| 65 | + --task-icon-border-completed |
| 66 | + --task-icon-border-radius |
| 67 | + --task-icon-color |
| 68 | + --task-icon-color-completed |
| 69 | +} |
| 70 | +```` |
| 71 | + |
| 72 | +## Events |
| 73 | +| Event | Detail | Description | |
| 74 | +| --- | --- | --- | |
| 75 | +| taskAdded | The detail contains the respective `task` object | Fires when a new task has been created. | |
| 76 | +| taskChanged | The detail contains the respective `task` object | Fires when task metadata has been changed, such as marking completed. | |
| 77 | +| taskClick | The detail contains the respective `task` object | Fires when the user clicks or taps on a task. | |
| 78 | +| taskRemoved | The detail contains the respective `task` object | Fires when an existing task has been deleted. | |
| 79 | + |
| 80 | +## Templates |
| 81 | + |
| 82 | +The `tasks` component supports several [templates](../templates.md) that allow you to replace certain parts of the component. To specify a template, include a `<template>` element inside a component and set the `data-type` value to one of the following: |
| 83 | + |
| 84 | +| Data type | Data context | Description | |
| 85 | +| --------- | ------------------------- | ----------------------------------------------------------------- | |
| 86 | +| task | task: a to-do task object | replaces the whole default task. | |
| 87 | +| task-details | task: a to-do task object | template replaces the details section of the task. | |
| 88 | + |
| 89 | +The following example defines a template for the tasks component. |
| 90 | + |
| 91 | +```html |
| 92 | +<mgt-todo> |
| 93 | + <template data-type="task-details"> |
| 94 | + <div> |
| 95 | + Importance Level: {{task.importance}} |
| 96 | + </div> |
| 97 | + </template> |
| 98 | +</mgt-todo> |
| 99 | +``` |
| 100 | + |
| 101 | +## Microsoft Graph permissions |
| 102 | + |
| 103 | +This control uses the following Microsoft Graph APIs and permissions. |
| 104 | + |
| 105 | +| Resource | Permission | |
| 106 | +| - | - | |
| 107 | +| /me/todo/lists/ | Tasks.ReadWrite | |
| 108 | +| /me/todo/lists/{todoTaskListId}/tasks | Tasks.ReadWrite | |
| 109 | +| /me/todo/lists/{todoTaskListId}/tasks/{taskId} | Tasks.ReadWrite | |
0 commit comments