Skip to content

Commit 3c9383b

Browse files
feat: Implement Task Dependencies (#2568)
* basic chip * deletable chips * addable chips * filters out already added tasks from search results * better input floating * selectable with keyboard * ui and keyboard fixes * lefthook * Old sequential boolean code * rename to id * implement id serializing * implement id deserializing * search results favour tasks in same file * svelte commenting * depends on field * blocking field * Adds dependency on existing id * addDependency returns parent and child * Add id to child task if needed * Doesn't create new task unless it needs to * simplify code * should not create duplicate dependency * doesn't create new parent unless it needs to * simplify code * can remove dependency * break out id checker` * setDependencies test * dont create unnecessary new parent * rename deps function * ensure task has id tests * Refactor task dependency logic * Passing in existing ids * new (probably unique) id can be generated * todo finish id generation * persist new task id working * writing depends on is working! * fixed depends on regex * svelte loads task dependencies * refactor id generation to only happen on submit * add duplicate id checking * EditTask modal shows blocking * EditTask can add and remove blocking * remove unnecessary change to cache.ts * small formatting fixes * Query checkboxes look clickable * Fixed id generation * fixed indexes not being correctly reset * variable name shortening * fixed blocking dependency not being serialized * fixed waitingOn dependency not being serialized * Working dropdown fullwidth * Fix console error spams * task results proximity sorting * highlights first result onfocus * filters out itself from results * reorder file * call correct line number parameter * fiddling with styles * convert dropdowns to buttons * Add access keys * Ignore accessibility warning instead * fix: dropdown now clickable * test blocking filter using id * test blocking filter using dependsOn * make it better with some() * refactor blockingField to own file * created new getFilterParser() function * make fieldCreators private * add allTasks attribute * move fieldCreators inside function * connect is blocking in query * fix: Add @ts-expect-error comments on 3 lines that currently don't compile So I can fix them in separate steps. * test: Add comment explaining why I think EditTask.test.ts tests are failing * comment: Add some TODOs with areas to fix... * re-enable lefthook * fix: Can now add dependencies via Pencil icon in Tasks search results * Make the cache private again in TasksPlugin * fix: Remove need for @ts-expect-error * fix: Remove need for @ts-expect-error * Passed allTasks into FilterParser.ts functions * Query.ts accepts allTasks param * Starting to modify QueryRendererHelper.ts * refactor: Make call to filter.filterFunction() explicit in Query.applyQueryToTasks() * refactor: Make more calls to filter.filterFunction() explicit * refactor: Make more calls to filter.filterFunction() explicit * test: Extract new custom matcher toMatchTaskWithTaskList() * refactor: 'is blocking' command now uses the allTasks list passed in to the filter * refactor: BlockingField no longer needs to receive allTasks via constructor * refactor: No longer need to pass allTasks in to FilterParser functions * refactor: No longer need to pass allTasks in Query constructor * test: Add a test of 'is blocking' with circular dependencies * test: Reduce scope of variables * test: Rename shared filter to clarify its meaning * test: Add missing task to the allTasks list * fix: Make BooleanField work with BlockingField * create is not blocked filter * Filters task with no deps * Filters task if there is an incomplete dep * Case-insensitive deps search * Fix failing svelte test suite * Remove unnecessary packages * Indicate which blocked on are complete and incomplete * fix: search results filters out blocked by and blocking * docs: Beginning of task dependencies explanation * docs: Add blocked by image * fix: dependency results self-filtering * add show/hide for new dependency fields * Add status to task search results and chips * vault: Add 'Dependencies Samples.md' for exploratory testing * test: Add 'is not blocked' to Query.test.ts * vault: Add examples of all the new query instructions * feat: Add CSS for id and dependsOn fields * vault: Add more sample searches in Dependencies Samples.md * docs: Document the generic CSS classes for new fields 'id' and 'dependsOn' * comment: Note required documentation if adding CSS classes & data attributes * docs: first draft of deps documentation * fix: Move 'only future dates' up to rest of dates options * fix: long task names are clipped, with popover containing full name * fix: long task names/file names are clipped in dropdown * fix: small dropdown behaviour issues * fix: more responsive dropdown, removed delay * fix: blocking dropdown not hiding * feat: disable dependency fields if task list is empty * fix: Edge case dropdown visual bug * fix: Grid display bug on mobile widths * Migrate wording from waiting on to blocked by * fix: small visual glitches * fix: task names in same file are full width * feat: search results file name and location popups * feat: expand dropdown to 20 results * refactor: DRY up dropdown code * fix: Edits that should have been included in the merge commit * fix: Edits that should have been included in the merge commit but got lost * fix: Remove empty file VerifyMarkdownTable.ts - remnant of merge * comment: Remove some HTML I accidentally copied from an error message * chore: Update yarn.lock * chore: migrate from dependsOn to blockedBy * chore: migrate blockedBy symbol to ⛔️ * tests: Reinstate tests I disabled during the merge of 'upstream/main' * fix: Correct the layout of Created, Done and Cancelled fields Their CSS classes needed updating, when they were merged in from main. * docs: Update snippets for addition of dependency emojis * refactor: . Extract function symbolAndDateValue() * refactor: . Extract function * refactor: . Extract function symbolAndStringValue() * refactor: . Fix misleading parameter name startDateSymbol * refactor: - Simplify the serialisation of task.blockedBy * fix: Don't render task.blockedBy values in 'short mode' * fix: Don't render task.id value in 'short mode' * refactor: . Remove some wasted work in symbolAndDateValue() * refactor: - Simplify code for serialising recurrence rule * test: Generate sample files of dependency fields in markdown * docs: Add samples of dependency fields to Format reference docs * docs: Minor updates to 'Task Dependencies.md' * docs: Add limitations of dependency feature to 'Known Limitations' page * test: Create table of Task Property values for documentation * docs: Document task properties available for scripting. * test: Fix duplicate test names --------- Co-authored-by: Clare Macrae <github@cfmacrae.fastmail.co.uk>
1 parent a3663e9 commit 3c9383b

File tree

59 files changed

+1439
-69
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

59 files changed

+1439
-69
lines changed

docs/Advanced/Styling.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ The generic classes are:
8282
- `task-cancelled`
8383
- `task-done`
8484
- `task-recurring`
85+
- `task-id`
86+
- `task-blockedBy`
8587

8688
In addition to the generic classes, there are [**data attributes**](https://developer.mozilla.org/en-US/docs/Learn/HTML/Howto/Use_data_attributes) that represent the content of the various task components.
8789

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
---
2+
publish: true
3+
---
4+
5+
# Task Dependencies
6+
7+
> [!released]
8+
> Introduced in Tasks X.Y.Z.
9+
10+
## Introduction
11+
12+
At a high level, task dependencies define the order in which you want to work on a set of tasks.
13+
This can be useful for mapping out projects, where one part needs to be completed before the other.
14+
By specifying these dependencies, Obsidian Tasks can streamline your workflow by displaying only the tasks that are actionable at any given moment.
15+
16+
> [!NOTE]
17+
> Obsidian tasks exclusively allows for Finish to start (FS) dependencies, meaning Task A needs to be finished before you start on Task B. You can learn more about this concept [on Wikipedia](https://en.wikipedia.org/wiki/Dependency_(project_management)).
18+
19+
## Example
20+
21+
To illustrate the concept of task dependencies, let's consider a scenario where we are outlining the tasks required to develop an application. Two tasks are identified:
22+
23+
```text
24+
- [ ] Build a first draft
25+
- [ ] Test with users
26+
```
27+
28+
In this scenario, testing with users can only occur after the initial draft is completed. To establish this relationship, you can create a dependency between the two tasks using either of the following methods.
29+
30+
1. Open the 'Build a first draft' task in the Edit Task Modal and specify 'Test with users' as a 'Blocking' task
31+
2. Alternatively, open the 'Test with users' task in the Edit Task Modal and add 'Build a first draft' as a 'Blocked By' task
32+
![[task-dependencies-blocked-by-example.png]]
33+
34+
By implementing either of these methods, the task list is updated to reflect the dependency relationship:
35+
36+
```text
37+
- [ ] Build a first draft 🆔 4ijuhy
38+
- [ ] Test with users ⛔️ 4ijuhy
39+
```
40+
41+
Then, if the query `is not blocked` is used
42+
43+
```tasks
44+
is not blocked
45+
```
46+
47+
We only see 'Build a first draft'
48+
49+
```text
50+
- [ ] Build a first draft 🆔 4ijuhy
51+
```
52+
53+
Until this task is marked as complete, at which time Obsidian Tasks sees that 'Test with users' is no longer blocked, and displays it as well
54+
55+
```text
56+
- [x] Build a first draft 🆔 4ijuhy
57+
- [ ] Test with users ⛔️ 4ijuhyz
58+
```
59+
60+
## Nomenclature
61+
62+
Fields:
63+
64+
- `blockedBy`
65+
- `id`
66+
67+
UI:
68+
69+
- Blocked by [implies an id of another task]
70+
- Blocks
71+
72+
Query
73+
74+
- blocking
75+
- blocked
76+
77+
## Adding Dependencies
78+
79+
## Searching For Dependencies
80+
81+
`is not blocked`
82+
83+
`is blocking`
84+
85+
![[Pasted image 20231011181837.png]]
86+
87+
## Known Limitations
88+
89+
- It's not yet possible to directly navigate from a task to the tasks it depends on.
90+
- Outside of the edit task modal, it is not possible to see the descriptions of the blocking tasks.
91+
- It is not yet possible to visualise the relationships in a graph viewer.

docs/How To/Find tasks with invalid data.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ The following tasks block lists any tasks that have emoji in the description, wh
3232
````text
3333
```tasks
3434
# These description instructions need to be all on one line:
35-
(description includes 🔺) OR (description includes ⏫) OR (description includes 🔼) OR (description includes 🔽) OR (description includes ⏬) OR (description includes 🛫) OR (description includes ➕) OR (description includes ⏳) OR (description includes 📅) OR (description includes ✅) OR (description includes ❌) OR (description includes 🔁)
35+
(description includes 🔺) OR (description includes ⏫) OR (description includes 🔼) OR (description includes 🔽) OR (description includes ⏬) OR (description includes 🛫) OR (description includes ➕) OR (description includes ⏳) OR (description includes 📅) OR (description includes ✅) OR (description includes ❌) OR (description includes 🔁) OR (description includes ⛔️) OR (description includes 🆔)
3636
3737
# Optionally, uncomment this line and exclude your templates location
3838
# path does not include _templates

docs/Reference/Task Formats/Dataview Format.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,17 @@ For more information, see [[Priority]].
131131

132132
For more information, see [[Recurring Tasks]].
133133

134+
### Dataview Format for Dependencies
135+
136+
<!-- snippet: DocsSamplesForTaskFormats.test.Serializer_Dependencies_dataview-snippet.approved.md -->
137+
```md
138+
- [ ] do this first [id:: dcf64c]
139+
- [ ] do this after first and some other task [blockedBy:: dcf64c,0h17ye]
140+
```
141+
<!-- endSnippet -->
142+
143+
For more information, see [[Task Dependencies]].
144+
134145
## Auto-Suggest and Dataview format
135146

136147
The Dataview format fully supports Tasks' [[Auto-Suggest]] feature, but requires users to manually type out surrounding brackets (`[]` or `()`). This works best with `Settings > Editor > Autopair Brackets` enabled.

docs/Reference/Task Formats/Tasks Emoji Format.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,17 @@ For more information, see [[Priority]].
4848

4949
For more information, see [[Recurring Tasks]].
5050

51+
## Tasks Emoji Format for Dependencies
52+
53+
<!-- snippet: DocsSamplesForTaskFormats.test.Serializer_Dependencies_tasksPluginEmoji-snippet.approved.md -->
54+
```md
55+
- [ ] do this first 🆔 dcf64c
56+
- [ ] do this after first and some other task ⛔️ dcf64c,0h17ye
57+
```
58+
<!-- endSnippet -->
59+
60+
For more information, see [[Task Dependencies]].
61+
5162
## Limitations of Tasks Emoji Format
5263

5364
### Non-breaking spaces: NBSP characters

docs/Scripting/Task Properties.md

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,20 @@ For more information, including adding your own customised statuses, see [[Statu
113113
- The `Invalid date` category was added in Tasks 6.0.0.
114114
1. The `fromNow` properties were added in Tasks 4.9.0.
115115

116+
## Values for Task Dependencies
117+
118+
<!-- placeholder to force blank line before included text --><!-- include: TaskProperties.test.task_dependency_fields.approved.md -->
119+
120+
| Field | Type 1 | Example 1 | Type 2 | Example 2 |
121+
| ----- | ----- | ----- | ----- | ----- |
122+
| `task.id` | `string` | `'abcdef'` | `string` | `''` |
123+
| `task.blockedBy` | `string[]` | `['123456', 'abc123']` | `any[]` | `[]` |
124+
125+
<!-- placeholder to force blank line after included text --><!-- endInclude -->
126+
127+
1. See the page [[Task Dependencies]], which explains the dependencies facility.
128+
1. Task Dependencies were released in Tasks X.Y.Z.
129+
116130
## Values for Other Task Properties
117131

118132
<!-- placeholder to force blank line before included text --><!-- include: TaskProperties.test.task_other_fields.approved.md -->
@@ -128,7 +142,7 @@ For more information, including adding your own customised statuses, see [[Statu
128142
| `task.isRecurring` | `boolean` | `true` | `boolean` | `false` |
129143
| `task.recurrenceRule` | `string` | `'every day when done'` | `string` | `''` |
130144
| `task.tags` | `string[]` | `['#todo', '#health']` | `any[]` | `[]` |
131-
| `task.originalMarkdown` | `string` | `' - [ ] Do exercises #todo #health 🔼 🔁 every day when done ➕ 2023-07-01 🛫 2023-07-02 ⏳ 2023-07-03 📅 2023-07-04 ❌ 2023-07-06 ✅ 2023-07-05 ^dcf64c'` | `string` | `'- [/] minimal task'` |
145+
| `task.originalMarkdown` | `string` | `' - [ ] Do exercises #todo #health 🔼 🔁 every day when done ➕ 2023-07-01 🛫 2023-07-02 ⏳ 2023-07-03 📅 2023-07-04 ❌ 2023-07-06 ✅ 2023-07-05 ⛔️ 123456,abc123 🆔 abcdef ^dcf64c'` | `string` | `'- [/] minimal task'` |
132146

133147
<!-- placeholder to force blank line after included text --><!-- endInclude -->
134148

docs/Support and Help/Known Limitations.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ This page gathers together all the documentation on known limitations of the plu
3131

3232
![[Getting Started#Limitations and warnings]]
3333

34+
## Writing Tasks: Dependencies
35+
36+
![[Task Dependencies#Known Limitations]]
37+
3438
## Writing Tasks: Task Formats
3539

3640
![[About Task Formats#Limitations of task format support]]
17.2 KB
Loading
Loading

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@
6363
"typescript": "^5.0.4"
6464
},
6565
"dependencies": {
66+
"@floating-ui/dom": "^1.5.3",
6667
"boon-js": "^2.0.4",
6768
"chrono-node": "2.3.9",
6869
"eventemitter2": "^6.4.5",

0 commit comments

Comments
 (0)