Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Implement Task Dependencies #2568

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
164 commits
Select commit Hold shift + click to select a range
fd782d4
basic chip
DanielTMolloy919 Aug 2, 2023
a274f40
deletable chips
DanielTMolloy919 Aug 5, 2023
66d5fda
addable chips
DanielTMolloy919 Aug 5, 2023
d0d6f08
filters out already added tasks from search results
DanielTMolloy919 Aug 5, 2023
64ba641
better input floating
DanielTMolloy919 Aug 12, 2023
77f3941
selectable with keyboard
DanielTMolloy919 Aug 13, 2023
a2ac816
ui and keyboard fixes
DanielTMolloy919 Aug 13, 2023
258398a
lefthook
DanielTMolloy919 Aug 13, 2023
7360173
Old sequential boolean code
DanielTMolloy919 Aug 16, 2023
30815c6
rename to id
DanielTMolloy919 Aug 16, 2023
8fb3197
implement id serializing
DanielTMolloy919 Aug 16, 2023
7a922c7
implement id deserializing
DanielTMolloy919 Aug 16, 2023
3ae4862
search results favour tasks in same file
DanielTMolloy919 Aug 20, 2023
cbf48a2
svelte commenting
DanielTMolloy919 Aug 20, 2023
04554b7
depends on field
DanielTMolloy919 Aug 20, 2023
d2de91b
blocking field
DanielTMolloy919 Aug 21, 2023
826c33e
Adds dependency on existing id
DanielTMolloy919 Aug 24, 2023
40762e9
addDependency returns parent and child
DanielTMolloy919 Aug 24, 2023
7582cf2
Add id to child task if needed
DanielTMolloy919 Aug 24, 2023
96a65ca
Doesn't create new task unless it needs to
DanielTMolloy919 Aug 24, 2023
86ca8cd
simplify code
DanielTMolloy919 Aug 24, 2023
9bc155d
should not create duplicate dependency
DanielTMolloy919 Aug 24, 2023
182b0b4
doesn't create new parent unless it needs to
DanielTMolloy919 Aug 24, 2023
afadb69
simplify code
DanielTMolloy919 Aug 24, 2023
b44edad
can remove dependency
DanielTMolloy919 Aug 24, 2023
5e21124
break out id checker`
DanielTMolloy919 Aug 24, 2023
568daf1
setDependencies test
DanielTMolloy919 Aug 24, 2023
b3ef459
dont create unnecessary new parent
DanielTMolloy919 Aug 24, 2023
e5c2a10
rename deps function
DanielTMolloy919 Aug 24, 2023
c8989e3
ensure task has id tests
DanielTMolloy919 Aug 24, 2023
fa5bf93
Refactor task dependency logic
DanielTMolloy919 Aug 27, 2023
0ed295b
Passing in existing ids
DanielTMolloy919 Aug 27, 2023
16b39b7
new (probably unique) id can be generated
DanielTMolloy919 Aug 27, 2023
462b407
todo finish id generation
DanielTMolloy919 Aug 27, 2023
846f77f
Merge branch 'task_dependency_backend' into diy_chips
DanielTMolloy919 Aug 27, 2023
334cc5b
persist new task id working
DanielTMolloy919 Aug 27, 2023
b6ca8b6
writing depends on is working!
DanielTMolloy919 Aug 27, 2023
11b3b2e
fixed depends on regex
DanielTMolloy919 Aug 27, 2023
7c34216
svelte loads task dependencies
DanielTMolloy919 Aug 27, 2023
80347ff
refactor id generation to only happen on submit
DanielTMolloy919 Aug 27, 2023
dce63aa
add duplicate id checking
DanielTMolloy919 Aug 27, 2023
96ca8e7
EditTask modal shows blocking
DanielTMolloy919 Aug 27, 2023
8fb2981
EditTask can add and remove blocking
DanielTMolloy919 Aug 27, 2023
38309c2
remove unnecessary change to cache.ts
DanielTMolloy919 Aug 27, 2023
dc0e211
small formatting fixes
DanielTMolloy919 Aug 27, 2023
002687c
Query checkboxes look clickable
DanielTMolloy919 Aug 29, 2023
fd747ac
Fixed id generation
DanielTMolloy919 Aug 29, 2023
d19d38b
fixed indexes not being correctly reset
DanielTMolloy919 Aug 29, 2023
e8be1cd
variable name shortening
DanielTMolloy919 Aug 29, 2023
c0125d5
fixed blocking dependency not being serialized
DanielTMolloy919 Aug 29, 2023
2910be5
fixed waitingOn dependency not being serialized
DanielTMolloy919 Aug 29, 2023
7e0754e
Working dropdown fullwidth
DanielTMolloy919 Aug 29, 2023
fdfd287
Fix console error spams
DanielTMolloy919 Aug 29, 2023
70b7796
task results proximity sorting
DanielTMolloy919 Aug 30, 2023
c7277f3
highlights first result onfocus
DanielTMolloy919 Aug 30, 2023
2d0b868
filters out itself from results
DanielTMolloy919 Aug 30, 2023
e0fec91
reorder file
DanielTMolloy919 Aug 30, 2023
9ef73e0
call correct line number parameter
DanielTMolloy919 Sep 2, 2023
baa52e6
fiddling with styles
DanielTMolloy919 Sep 2, 2023
2205927
convert dropdowns to buttons
DanielTMolloy919 Sep 3, 2023
c57709b
Add access keys
DanielTMolloy919 Sep 3, 2023
7e79baa
Ignore accessibility warning instead
DanielTMolloy919 Sep 4, 2023
369805e
fix: dropdown now clickable
DanielTMolloy919 Sep 4, 2023
ae918cb
test blocking filter using id
DanielTMolloy919 Oct 2, 2023
420af1a
test blocking filter using dependsOn
DanielTMolloy919 Oct 2, 2023
6123228
make it better with some()
DanielTMolloy919 Oct 2, 2023
2522560
refactor blockingField to own file
DanielTMolloy919 Oct 2, 2023
dc34886
created new getFilterParser() function
DanielTMolloy919 Oct 2, 2023
6f7c1b6
make fieldCreators private
DanielTMolloy919 Oct 2, 2023
29a81ff
add allTasks attribute
DanielTMolloy919 Oct 2, 2023
3017cb7
move fieldCreators inside function
DanielTMolloy919 Oct 2, 2023
a70d289
connect is blocking in query
DanielTMolloy919 Oct 2, 2023
49546f5
fix: Add @ts-expect-error comments on 3 lines that currently don't co…
claremacrae Oct 2, 2023
d86a6da
test: Add comment explaining why I think EditTask.test.ts tests are f…
claremacrae Oct 2, 2023
78c46ff
comment: Add some TODOs with areas to fix...
claremacrae Oct 2, 2023
b6ad1c4
re-enable lefthook
DanielTMolloy919 Oct 2, 2023
f790aca
fix: Can now add dependencies via Pencil icon in Tasks search results
claremacrae Oct 2, 2023
59b7f61
Make the cache private again in TasksPlugin
claremacrae Oct 2, 2023
ccab227
fix: Remove need for @ts-expect-error
claremacrae Oct 2, 2023
b2cc283
fix: Remove need for @ts-expect-error
claremacrae Oct 2, 2023
120225a
Merge branch 'main' into diy_chips
DanielTMolloy919 Oct 3, 2023
786464a
Passed allTasks into FilterParser.ts functions
DanielTMolloy919 Oct 3, 2023
bb9a9f1
Query.ts accepts allTasks param
DanielTMolloy919 Oct 3, 2023
fda3548
Starting to modify QueryRendererHelper.ts
DanielTMolloy919 Oct 3, 2023
eaac0a0
refactor: Make call to filter.filterFunction() explicit in Query.appl…
claremacrae Oct 3, 2023
d9d3063
refactor: Make more calls to filter.filterFunction() explicit
claremacrae Oct 3, 2023
af58382
refactor: Make more calls to filter.filterFunction() explicit
claremacrae Oct 3, 2023
9598c02
test: Extract new custom matcher toMatchTaskWithTaskList()
claremacrae Oct 3, 2023
6f2e708
refactor: 'is blocking' command now uses the allTasks list passed in …
claremacrae Oct 3, 2023
aa235c7
refactor: BlockingField no longer needs to receive allTasks via const…
claremacrae Oct 3, 2023
46057ac
refactor: No longer need to pass allTasks in to FilterParser functions
claremacrae Oct 3, 2023
41a4630
refactor: No longer need to pass allTasks in Query constructor
claremacrae Oct 3, 2023
300fa84
test: Add a test of 'is blocking' with circular dependencies
claremacrae Oct 3, 2023
a244da4
test: Reduce scope of variables
claremacrae Oct 3, 2023
9b7d398
test: Rename shared filter to clarify its meaning
claremacrae Oct 3, 2023
19bae09
test: Add missing task to the allTasks list
claremacrae Oct 3, 2023
db63951
fix: Make BooleanField work with BlockingField
claremacrae Oct 3, 2023
53d00ca
create is not blocked filter
DanielTMolloy919 Oct 8, 2023
6fee764
Filters task with no deps
DanielTMolloy919 Oct 8, 2023
594e236
Filters task if there is an incomplete dep
DanielTMolloy919 Oct 8, 2023
ca20491
Case-insensitive deps search
DanielTMolloy919 Oct 8, 2023
414ae84
Fix failing svelte test suite
DanielTMolloy919 Oct 8, 2023
114b345
Remove unnecessary packages
DanielTMolloy919 Oct 8, 2023
827ea03
Indicate which blocked on are complete and incomplete
DanielTMolloy919 Oct 9, 2023
175bcf7
fix: search results filters out blocked by and blocking
DanielTMolloy919 Oct 9, 2023
8aa59ae
docs: Beginning of task dependencies explanation
DanielTMolloy919 Oct 11, 2023
b75149f
docs: Add blocked by image
DanielTMolloy919 Oct 11, 2023
db997db
fix: dependency results self-filtering
DanielTMolloy919 Oct 11, 2023
06f1835
add show/hide for new dependency fields
DanielTMolloy919 Oct 11, 2023
50f2a4f
Add status to task search results and chips
DanielTMolloy919 Oct 11, 2023
d56a7d3
Merge branch 'main' into diy_chips
DanielTMolloy919 Oct 11, 2023
97bd3e8
vault: Add 'Dependencies Samples.md' for exploratory testing
claremacrae Oct 11, 2023
44ce45a
test: Add 'is not blocked' to Query.test.ts
claremacrae Oct 11, 2023
5bd2727
vault: Add examples of all the new query instructions
claremacrae Oct 11, 2023
808c1bb
feat: Add CSS for id and dependsOn fields
claremacrae Oct 11, 2023
54d43f2
vault: Add more sample searches in Dependencies Samples.md
claremacrae Oct 11, 2023
d127a9d
docs: Document the generic CSS classes for new fields 'id' and 'depen…
claremacrae Oct 11, 2023
e895d74
comment: Note required documentation if adding CSS classes & data att…
claremacrae Oct 11, 2023
6a7bd1f
docs: first draft of deps documentation
DanielTMolloy919 Nov 7, 2023
aa4f4c4
fix: Move 'only future dates' up to rest of dates options
DanielTMolloy919 Nov 11, 2023
ad63963
fix: long task names are clipped, with popover containing full name
DanielTMolloy919 Nov 11, 2023
e228b6c
fix: long task names/file names are clipped in dropdown
DanielTMolloy919 Nov 11, 2023
f7ebc16
fix: small dropdown behaviour issues
DanielTMolloy919 Nov 11, 2023
219f5c6
fix: more responsive dropdown, removed delay
DanielTMolloy919 Nov 11, 2023
a1117ec
fix: blocking dropdown not hiding
DanielTMolloy919 Nov 11, 2023
5bd339d
feat: disable dependency fields if task list is empty
DanielTMolloy919 Nov 18, 2023
65c449f
fix: Edge case dropdown visual bug
DanielTMolloy919 Nov 18, 2023
a4275c6
fix: Grid display bug on mobile widths
DanielTMolloy919 Nov 18, 2023
3e75570
Migrate wording from waiting on to blocked by
DanielTMolloy919 Nov 19, 2023
6072da2
fix: small visual glitches
DanielTMolloy919 Nov 19, 2023
ef6a42c
fix: task names in same file are full width
DanielTMolloy919 Dec 2, 2023
754c2f7
feat: search results file name and location popups
DanielTMolloy919 Dec 2, 2023
462549f
feat: expand dropdown to 20 results
DanielTMolloy919 Dec 2, 2023
9de4112
refactor: DRY up dropdown code
DanielTMolloy919 Dec 3, 2023
55caf82
Merge branch 'main_after_SearchInfo_created' into diy_chips_merge_mai…
claremacrae Dec 6, 2023
0210ae8
fix: Edits that should have been included in the merge commit
claremacrae Dec 6, 2023
5da7471
Merge branch 'main' into diy_chips_merge_main_take_2
claremacrae Dec 6, 2023
1d3db9c
fix: Edits that should have been included in the merge commit but got…
claremacrae Dec 6, 2023
271ba4a
fix: Remove empty file VerifyMarkdownTable.ts - remnant of merge
claremacrae Dec 6, 2023
eb10c68
comment: Remove some HTML I accidentally copied from an error message
claremacrae Dec 6, 2023
305a6df
chore: Update yarn.lock
claremacrae Dec 6, 2023
0cb2311
chore: migrate from dependsOn to blockedBy
DanielTMolloy919 Dec 13, 2023
ce752a6
chore: migrate blockedBy symbol to ⛔️
DanielTMolloy919 Dec 13, 2023
a4686f2
Merge remote-tracking branch 'upstream/main' into diy_chips_merge_mai…
claremacrae Jan 5, 2024
682d962
tests: Reinstate tests I disabled during the merge of 'upstream/main'
claremacrae Jan 5, 2024
8c4c6be
fix: Correct the layout of Created, Done and Cancelled fields
claremacrae Jan 5, 2024
3b07bca
docs: Update snippets for addition of dependency emojis
claremacrae Jan 5, 2024
ef21e7e
refactor: . Extract function symbolAndDateValue()
claremacrae Jan 5, 2024
2f66cf9
refactor: . Extract function
claremacrae Jan 5, 2024
e5a2eb9
refactor: . Extract function symbolAndStringValue()
claremacrae Jan 5, 2024
763dbfc
refactor: . Fix misleading parameter name startDateSymbol
claremacrae Jan 5, 2024
e4845cf
refactor: - Simplify the serialisation of task.blockedBy
claremacrae Jan 5, 2024
9be16a8
fix: Don't render task.blockedBy values in 'short mode'
claremacrae Jan 5, 2024
69f4672
fix: Don't render task.id value in 'short mode'
claremacrae Jan 5, 2024
1a2f1c9
refactor: . Remove some wasted work in symbolAndDateValue()
claremacrae Jan 5, 2024
d633628
refactor: - Simplify code for serialising recurrence rule
claremacrae Jan 5, 2024
e832bcb
test: Generate sample files of dependency fields in markdown
claremacrae Jan 6, 2024
9ffbc87
docs: Add samples of dependency fields to Format reference docs
claremacrae Jan 6, 2024
0ea3ec1
docs: Minor updates to 'Task Dependencies.md'
claremacrae Jan 6, 2024
020ac00
docs: Add limitations of dependency feature to 'Known Limitations' page
claremacrae Jan 6, 2024
ce83d24
test: Create table of Task Property values for documentation
claremacrae Jan 6, 2024
68c8cfa
docs: Document task properties available for scripting.
claremacrae Jan 6, 2024
f44f4ba
test: Fix duplicate test names
claremacrae Jan 6, 2024
4203bc6
Merge branch 'main' into fork/DanielTMolloy919-diy_chips_merge_main_t…
claremacrae Jan 20, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions docs/Advanced/Styling.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ The generic classes are:
- `task-cancelled`
- `task-done`
- `task-recurring`
- `task-id`
- `task-blockedBy`

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.

Expand Down
91 changes: 91 additions & 0 deletions docs/Getting Started/Task Dependencies.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
---
publish: true
---

# Task Dependencies

> [!released]
> Introduced in Tasks X.Y.Z.

## Introduction

At a high level, task dependencies define the order in which you want to work on a set of tasks.
This can be useful for mapping out projects, where one part needs to be completed before the other.
By specifying these dependencies, Obsidian Tasks can streamline your workflow by displaying only the tasks that are actionable at any given moment.

> [!NOTE]
> 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)).

## Example

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:

```text
- [ ] Build a first draft
- [ ] Test with users
```

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.

1. Open the 'Build a first draft' task in the Edit Task Modal and specify 'Test with users' as a 'Blocking' task
2. Alternatively, open the 'Test with users' task in the Edit Task Modal and add 'Build a first draft' as a 'Blocked By' task
![[task-dependencies-blocked-by-example.png]]

By implementing either of these methods, the task list is updated to reflect the dependency relationship:

```text
- [ ] Build a first draft 🆔 4ijuhy
- [ ] Test with users ⛔️ 4ijuhy
```

Then, if the query `is not blocked` is used

```tasks
is not blocked
```

We only see 'Build a first draft'

```text
- [ ] Build a first draft 🆔 4ijuhy
```

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

```text
- [x] Build a first draft 🆔 4ijuhy
- [ ] Test with users ⛔️ 4ijuhyz
```

## Nomenclature

Fields:

- `blockedBy`
- `id`

UI:

- Blocked by [implies an id of another task]
- Blocks

Query

- blocking
- blocked

## Adding Dependencies

## Searching For Dependencies

`is not blocked`

`is blocking`

![[Pasted image 20231011181837.png]]

## Known Limitations

- It's not yet possible to directly navigate from a task to the tasks it depends on.
- Outside of the edit task modal, it is not possible to see the descriptions of the blocking tasks.
- It is not yet possible to visualise the relationships in a graph viewer.
2 changes: 1 addition & 1 deletion docs/How To/Find tasks with invalid data.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ The following tasks block lists any tasks that have emoji in the description, wh
````text
```tasks
# These description instructions need to be all on one line:
(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 🔁)
(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 🆔)

# Optionally, uncomment this line and exclude your templates location
# path does not include _templates
Expand Down
11 changes: 11 additions & 0 deletions docs/Reference/Task Formats/Dataview Format.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,17 @@ For more information, see [[Priority]].

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

### Dataview Format for Dependencies

<!-- snippet: DocsSamplesForTaskFormats.test.Serializer_Dependencies_dataview-snippet.approved.md -->
```md
- [ ] do this first [id:: dcf64c]
- [ ] do this after first and some other task [blockedBy:: dcf64c,0h17ye]
```
<!-- endSnippet -->

For more information, see [[Task Dependencies]].

## Auto-Suggest and Dataview format

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.
Expand Down
11 changes: 11 additions & 0 deletions docs/Reference/Task Formats/Tasks Emoji Format.md
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,17 @@ For more information, see [[Priority]].

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

## Tasks Emoji Format for Dependencies

<!-- snippet: DocsSamplesForTaskFormats.test.Serializer_Dependencies_tasksPluginEmoji-snippet.approved.md -->
```md
- [ ] do this first 🆔 dcf64c
- [ ] do this after first and some other task ⛔️ dcf64c,0h17ye
```
<!-- endSnippet -->

For more information, see [[Task Dependencies]].

## Limitations of Tasks Emoji Format

### Non-breaking spaces: NBSP characters
Expand Down
16 changes: 15 additions & 1 deletion docs/Scripting/Task Properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,20 @@ For more information, including adding your own customised statuses, see [[Statu
- The `Invalid date` category was added in Tasks 6.0.0.
1. The `fromNow` properties were added in Tasks 4.9.0.

## Values for Task Dependencies

<!-- placeholder to force blank line before included text --><!-- include: TaskProperties.test.task_dependency_fields.approved.md -->

| Field | Type 1 | Example 1 | Type 2 | Example 2 |
| ----- | ----- | ----- | ----- | ----- |
| `task.id` | `string` | `'abcdef'` | `string` | `''` |
| `task.blockedBy` | `string[]` | `['123456', 'abc123']` | `any[]` | `[]` |

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

1. See the page [[Task Dependencies]], which explains the dependencies facility.
1. Task Dependencies were released in Tasks X.Y.Z.

## Values for Other Task Properties

<!-- placeholder to force blank line before included text --><!-- include: TaskProperties.test.task_other_fields.approved.md -->
Expand All @@ -128,7 +142,7 @@ For more information, including adding your own customised statuses, see [[Statu
| `task.isRecurring` | `boolean` | `true` | `boolean` | `false` |
| `task.recurrenceRule` | `string` | `'every day when done'` | `string` | `''` |
| `task.tags` | `string[]` | `['#todo', '#health']` | `any[]` | `[]` |
| `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'` |
| `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'` |

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

Expand Down
4 changes: 4 additions & 0 deletions docs/Support and Help/Known Limitations.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ This page gathers together all the documentation on known limitations of the plu

![[Getting Started#Limitations and warnings]]

## Writing Tasks: Dependencies

![[Task Dependencies#Known Limitations]]

## Writing Tasks: Task Formats

![[About Task Formats#Limitations of task format support]]
Expand Down
Binary file added docs/images/Pasted image 20231011181837.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
"typescript": "^5.0.4"
},
"dependencies": {
"@floating-ui/dom": "^1.5.3",
"boon-js": "^2.0.4",
"chrono-node": "2.3.9",
"eventemitter2": "^6.4.5",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
# Dependencies Samples

- [ ] #task Choose a topic 🆔 ya44g5
- [ ] #task Research the subject ⛔️ ya44g5 🆔 g7317o
- [ ] #task Create an outline ⛔️ g7317o 🆔 rot7gb
- [ ] #task Develop main points ⛔️ rot7gb 🆔 mvplec
- [ ] #task Craft a conclusion ⛔️ mvplec 🆔 0wigip
- [ ] #task Proofread and edit ⛔️ 0wigip 🆔 5ti6bf
- [ ] #task Publish the article ⛔️ 5ti6bf

---

## Do Next

```tasks
((is blocking) AND (is not blocked)) OR (is not blocked)
not done

path includes {{query.file.path}}
explain
```

---

## Blocking Tasks

### Blocking Tasks - Any Status

```tasks
is blocking

path includes {{query.file.path}}
explain
```

### Blocking Tasks - Not Done

```tasks
is blocking
not done

path includes {{query.file.path}}
explain
```

---

## Blocked Tasks

### Blocked Tasks - Any Status

```tasks
is not blocked

path includes {{query.file.path}}
explain
```

### Blocked Tasks - Not Done

```tasks
is not blocked
not done

path includes {{query.file.path}}
explain
```

---

## Show/Hide Instructions

### Hide Id

```tasks
hide id
path includes {{query.file.path}}
explain
```

### Hide blockedBy

```tasks
hide depends on
path includes {{query.file.path}}
explain
```
9 changes: 8 additions & 1 deletion src/Api/createTaskLineModalHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,12 @@ export const defaultTaskModalFactory: taskModalFactory = (
onSubmit: (updatedTasks: Task[]) => void,
): ITaskModal => {
const task = taskFromLine({ line: '', path: '' });
return new TaskModal({ app, task, onSubmit }) as ITaskModal;
// TODO This is going to need some thought. It is missing the Cache argument.
// This file is part of the Tasks API that allows users to open the Edit Task modal from JavaScript:
// https://publish.obsidian.md/tasks/Advanced/Tasks+Api
// As a published API, to change the parameters would be a breaking change.
// One option is to make the allTasks parameter to the Edit task modal be optional,
// and if it's not provided, then hide the dependency fields in the modal.
// For now, we pass in an empty list of tasks.
return new TaskModal({ app, task, onSubmit, allTasks: [] }) as ITaskModal;
};
3 changes: 2 additions & 1 deletion src/Commands/CreateOrEdit.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import type { Task } from '../Task';
import { DateFallback } from '../DateFallback';
import { taskFromLine } from './CreateOrEditTaskParser';

export const createOrEdit = (checking: boolean, editor: Editor, view: View, app: App) => {
export const createOrEdit = (checking: boolean, editor: Editor, view: View, app: App, allTasks: Task[]) => {
if (checking) {
return view instanceof MarkdownView;
}
Expand Down Expand Up @@ -36,6 +36,7 @@ export const createOrEdit = (checking: boolean, editor: Editor, view: View, app:
app,
task,
onSubmit,
allTasks,
});
taskModal.open();
};
4 changes: 4 additions & 0 deletions src/Commands/CreateOrEditTaskParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ export const taskFromLine = ({ line, path }: { line: string; path: string }): Ta
doneDate: null,
cancelledDate: null,
recurrence: null,
blockedBy: [],
id: '',
blockLink: '',
tags: [],
originalMarkdown: '',
Expand Down Expand Up @@ -131,5 +133,7 @@ export const taskFromLine = ({ line, path }: { line: string; path: string }): Ta
originalMarkdown: '',
// Not needed since the inferred status is always re-computed after submitting.
scheduledDateIsInferred: false,
id: '',
blockedBy: [],
});
};
10 changes: 6 additions & 4 deletions src/Commands/index.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
import type { App, Editor, MarkdownFileInfo, MarkdownView, Plugin, View } from 'obsidian';
import type { App, Editor, MarkdownFileInfo, MarkdownView, View } from 'obsidian';
import type TasksPlugin from '../main';
import { createOrEdit } from './CreateOrEdit';

import { toggleDone } from './ToggleDone';

export class Commands {
private readonly plugin: Plugin;
private readonly plugin: TasksPlugin;

private get app(): App {
return this.plugin.app;
}

constructor({ plugin }: { plugin: Plugin }) {
constructor({ plugin }: { plugin: TasksPlugin }) {
this.plugin = plugin;

plugin.addCommand({
id: 'edit-task',
name: 'Create or edit task',
icon: 'pencil',
editorCheckCallback: (checking: boolean, editor: Editor, view: MarkdownView | MarkdownFileInfo) => {
return createOrEdit(checking, editor, view as View, this.app);
// TODO Need to explore what happens if a tasks code block is rendered before the Cache has been created.
return createOrEdit(checking, editor, view as View, this.app, this.plugin.getTasks()!);
},
});

Expand Down
32 changes: 32 additions & 0 deletions src/Query/Filter/BlockingField.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import type { SearchInfo } from '../SearchInfo';
import { FilterInstructionsBasedField } from './FilterInstructionsBasedField';

export class BlockingField extends FilterInstructionsBasedField {
constructor() {
super();
this._filters.add('is blocking', (task, searchInfo: SearchInfo) => {
if (task.id === '') return false;

return searchInfo.allTasks.some((cacheTask) => {
return cacheTask.blockedBy.includes(task.id);
});
});
this._filters.add('is not blocked', (task, searchInfo: SearchInfo) => {
if (task.blockedBy.length === 0) return true;

for (const depId of task.blockedBy) {
const depTask = searchInfo.allTasks.find((task) => task.id === depId);

if (!depTask) continue;

if (!depTask.status.isCompleted()) return false;
}

return true;
});
}

fieldName(): string {
return 'blocking';
}
}