演示¶
任务管理器管理未完成 (TODO) 任务和已完成任务(非空 doneDate 属性)。未完成的任务按位置和任意标签进一步分类 - 每当您更改任务注释中的标签属性时,该任务都会自动移动到适当的位置。
任务管理器还与日记集成 - 笔记被克隆到日记中到 todoDate 注释和 doneDate 注释(前缀为“TODO”或“DONE”)。
实现¶
新任务是在 TODO 注释中创建的,该注释具有指向任务模板的关系(请参阅属性继承)。~child:template
属性¶
任务模板定义了多个提升的属性 - todoDate、doneDate、tags、location。重要的是,它还定义了关系 - 在属性更改时运行的事件处理程序。例如,当我们填写 doneDate 属性时,该脚本会处理 - 这意味着任务已完成,应移动到“完成”注释并从 TODO、位置和标签中删除。~runOnAttributeChange
新建任务按钮¶
还有一个“按钮”笔记,其中包含简单的脚本,该脚本添加了一个按钮以在待办事项笔记中创建新笔记(任务)。
api.addButtonToToolbar({
title: 'New task',
icon: 'check',
shortcut: 'alt+n',
action: async () => {
// creating notes is backend (server) responsibility so we need to pass
// the control there
const taskNoteId = await api.runOnBackend(async () => {
const todoRootNote = await api.getNoteWithLabel('taskTodoRoot');
const {note} = await api.createNote(todoRootNote.noteId, 'new task', '');
return note.noteId;
});
// we got an ID of newly created note and we want to immediatelly display it
await api.activateNewNote(taskNoteId);
}
});
CSS系统¶
在上面的演示屏幕截图中,您可能会注意到 TODO 任务为红色,DONE 任务为绿色。
这是通过定义额外 CSS 类的 CSS 代码注释来完成的:
span.fancytree-node.todo .fancytree-title {
color: red !important;
}
span.fancytree-node.done .fancytree-title {
color: green !important;
}
此代码说明具有标签,该标签在启动时被 Trilium 识别并作为 CSS 加载到应用程序中。#appCss
此功能的第二部分基于上述事件处理程序,该处理程序根据任务状态将标签分配给任务“完成”或“待办事项”。#cssClass