mirror of
https://github.com/zadam/trilium.git
synced 2025-06-06 18:08:33 +02:00
Task manager
parent
7af17b9ff7
commit
2dce193886
1
Advanced showcases.md
Normal file
1
Advanced showcases.md
Normal file
@ -0,0 +1 @@
|
||||
Good
|
7
Attribute inheritance.md
Normal file
7
Attribute inheritance.md
Normal file
@ -0,0 +1,7 @@
|
||||
Every [[attribute|attributes]] has a flag called `isInheritable`. If this is true, then this attribute (key-value) is also applied to all its children notes, children's children notes etc.
|
||||
|
||||
## Copying inheritance
|
||||
|
||||
Different kind of inheritance is achieved using "child:" attribute name prefix. If we create a child note in a note with "child:exampleAttribute" attribute, then child note will have "exampleAttribute" created. This can be even chained, e.g. "child:child:exampleAttribute", in this case "exampleAttribute" will be created in the child of the child.
|
||||
|
||||
Which kind of attribute inheritance (or if any at all) should be used depends on specific use case.
|
@ -55,8 +55,4 @@ Attributes allow multiplicity - there can be multiple attributes with the same n
|
||||
|
||||
## Attribute inheritance
|
||||
|
||||
Every attribute has a flag called `isInheritable`. If this is true, then this attribute (key-value) is also applied to all its children notes, children's children notes etc.
|
||||
|
||||
Different kind of inheritance is achieved using "child:" attribute name prefix. If we create a child note in a note with "child:exampleAttribute" attribute, then child note will have "exampleAttribute" created. This can be even chained, e.g. "child:child:exampleAttribute", in this case "exampleAttribute" will be created in the child of the child.
|
||||
|
||||
Which kind of attribute inheritance (or if any at all) should be used depends on specific use case.
|
||||
See [[Attribute inheritance]].
|
@ -17,6 +17,6 @@ Trilium has some special support for day notes in the form of [backend Script AP
|
||||
|
||||
Day (and year, month) notes are created with a label - e.g. `@dateNote=2018-08-16` this can then be used by other scripts to add new notes to day note etc.
|
||||
|
||||
Journal has [[attributes]] `@sorted @child:sorted @child:sorted:sorted` which keeps notes sorted on all three levels of years, months and dates.
|
||||
Journal has [[attributes]] `@sorted @child:sorted @child:sorted:sorted` (see [[attribute inheritance]]) which keeps notes sorted on all three levels of years, months and dates.
|
||||
|
||||
Journal also has relation "child:child:child:template=Day template" which effectively adds [[template]] to day notes (grand-grand-grand children of Journal). The template is pretty simple - it just adds "weight" promoted attribute to keep track of our daily weight.
|
17
Events.md
Normal file
17
Events.md
Normal file
@ -0,0 +1,17 @@
|
||||
In general we may say that [[script|scripts]] notes are triggered by events. "run" represents global events:
|
||||
|
||||
* `run`
|
||||
* `frontendStartup` - executes on frontend upon startup
|
||||
* `backendStartup` - executes on backend upon startup
|
||||
* `hourly` - executes once an hour on backend
|
||||
* `daily` - executes once a day on backend
|
||||
|
||||
Other events are bound to some entity, these are defined as [[relations|Attributes]] - meaning that script is triggered only if note has this script attached to it through relations (or it can inherit it).
|
||||
|
||||
* `runOnNoteView` - executes when note is displayed on frontend
|
||||
* `runOnNoteCreation` - executes when note is created on backend
|
||||
* `runOnNoteTitleChange` - executes when note title is changed (includes note creation as well)
|
||||
* `runOnNoteChange` - executes when note is changed (includes note creation as well)
|
||||
* `runOnChildNoteCreation` - executes when new note is created under *this* note
|
||||
* `runOnAttributeCreation` - executes when new attribute is created under *this* note
|
||||
* `runOnAttributeChange` - executes when attribute is changed under *this* note
|
@ -9,7 +9,7 @@ Sometimes it can be difficult to remember all the extended family, relations and
|
||||
|
||||
## Implementation
|
||||
|
||||
Members note has `child:template` [[attribute|attributes]] defined which means that any note created as a child to Members will have `template` attribute pointing to the `Person template` note (see [[template]]).
|
||||
Members note has `child:template` [[attribute|attributes]] (see [[attribute inheritance]]) defined which means that any note created as a child to Members will have `template` attribute pointing to the `Person template` note (see [[template]]).
|
||||
|
||||
This `Person template` defines multiple [[promoted attributes]], some of which (isPartnerOf, isChildOf) allow multiplicity - there can be multiple such relations.
|
||||
|
||||
|
18
Scripts.md
18
Scripts.md
@ -47,23 +47,7 @@ The solution is marked by red circle at the bottom - this note has [[label|Attri
|
||||
|
||||
### Events
|
||||
|
||||
In general we may say that script notes are triggered by events. "run" represents global events:
|
||||
|
||||
* `run`
|
||||
* `frontendStartup` - executes on frontend upon startup
|
||||
* `backendStartup` - executes on backend upon startup
|
||||
* `hourly` - executes once an hour on backend
|
||||
* `daily` - executes once a day on backend
|
||||
|
||||
Other events are bound to some entity, these are defined as [[relations|Attributes]] - meaning that script is triggered only if note has this script attached to it through relations (or it can inherit it).
|
||||
|
||||
* `runOnNoteView` - executes when note is displayed on frontend
|
||||
* `runOnNoteCreation` - executes when note is created on backend
|
||||
* `runOnNoteTitleChange` - executes when note title is changed (includes note creation as well)
|
||||
* `runOnNoteChange` - executes when note is changed (includes note creation as well)
|
||||
* `runOnChildNoteCreation` - executes when new note is created under *this* note
|
||||
* `runOnAttributeCreation` - executes when new attribute is created under *this* note
|
||||
* `runOnAttributeChange` - executes when attribute is changed under *this* note
|
||||
See [[Events]].
|
||||
|
||||
## Script API
|
||||
|
||||
|
@ -0,0 +1,61 @@
|
||||
Task Manager is a [[promoted attributes]] and [[scripts]] showcase present in the [[demo document|Document#demo-document]].
|
||||
|
||||
## Demo
|
||||
[[images/weight-tracker.png]]
|
||||
|
||||
Task Manager manages outstanding (TODO) tasks and finished tasks (non-empty doneDate attribute). Outstanding tasks are further categorized by location and arbitrary tags - whenever you change tag attribute in the task note, this task is then automatically moved to appropriate location.
|
||||
|
||||
Task Manager also integrates with [[day notes]] - notes are [[cloned|cloning notes]] into day note to both todoDate note and doneDate note (with [[prefix|Tree concepts#prefix]] of either "TODO" or "DONE").
|
||||
|
||||
## Implementation
|
||||
|
||||
New tasks are created in the TODO note which has "child:template" [[relation|attributes]] (see [[attribute inheritance]]) pointing to the task template.
|
||||
|
||||
### Attributes
|
||||
|
||||
Task template defines several [[promoted attributes]] - todoDate, doneData, tags, location. Importantly it also defines `runOnAttributeChange` relation - [[event|events]] handler which is run on attribute change. This [[script|scripts]] handles when e.g. we fill out the doneDate attribute - meaning the task is done and should be moved to "Done" note and removed from TODO, locations and tags.
|
||||
|
||||
### New task button
|
||||
|
||||
There's also "button" note which contains simple script which adds a button to create new note (task) in the TODO note.
|
||||
|
||||
```javascript
|
||||
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.runOnServer(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
|
||||
|
||||
In the demo screenshot above you may notice that TODO tasks are in red color and DONE tasks are green.
|
||||
|
||||
This is done by having this CSS code note which defines extra CSS classes:
|
||||
|
||||
```CSS
|
||||
span.fancytree-node.todo .fancytree-title {
|
||||
color: red !important;
|
||||
}
|
||||
|
||||
span.fancytree-node.done .fancytree-title {
|
||||
color: green !important;
|
||||
}
|
||||
```
|
||||
|
||||
This code note has `appCss` [[label|attributes]] which is recognized by Trilium on startup and loaded as CSS into the application.
|
||||
|
||||
Second part of this functionality is based in event handler described above which assigns `cssClass` label to the task to either "done" or "todo" based on the task status.
|
@ -6,6 +6,6 @@ To make these attributes really obvious, we make them "promoted" so they are vis
|
||||
|
||||
Then whenever we create a new note for book we'll just link the template to the book note via [[relation|Attributes]] "template". Book note will then automatically inherit all the promoted attributes and display them.
|
||||
|
||||
To make this even more automated, we can create "child:template" attribute on common parent note of our books and whenever we create new note inside this parent, the book note will get the template relation automatically.
|
||||
To make this even more automated, we can create "child:template" (see [[attribute inheritance]]) attribute on common parent note of our books and whenever we create new note inside this parent, the book note will get the template relation automatically.
|
||||
|
||||
You can check out the concept in the [[demo document|Document#demo-document]] in e.g. [[Family tree]], [[Task manager]] or [[Day notes]].
|
BIN
images/task-manager.png
Normal file
BIN
images/task-manager.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 184 KiB |
Loading…
x
Reference in New Issue
Block a user