Skip to content

Commit cf6ff2b

Browse files
authored
Merge pull request #2637 from obsidian-tasks-group/add-dependency-task-properties
docs: Add docs for task properties isBlocked() and isBlocking()
2 parents 7a8a85d + 009b427 commit cf6ff2b

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

docs/Quick Reference.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ This table summarizes the filters and other options available inside a `tasks` b
2121
| **[[Task Dependencies]]** | | | | |
2222
| `id (includes, does not include) <string>`<br>`id (regex matches, regex does not match) /regex/i`<br>`has id`<br>`no id` | `sort by id` | `group by id` | `hide id` | `task.id` |
2323
| `has blocked by`<br>`no blocked by` | | | `hide depends on` | `task.blockedBy` |
24-
| `is blocked`<br>`is not blocked` | | | | |
25-
| `is blocking`<br>`is not blocking` | | | | |
24+
| `is blocked`<br>`is not blocked` | | | | `task.isBlocked(query.allTasks)` |
25+
| `is blocking`<br>`is not blocking` | | | | `task.isBlocking(query.allTasks)` |
2626
| **[[Filters#Filters for Dates in Tasks\|Dates]]** | | | | |
2727
| `done (on, before, after, on or before, on or after) <date>`<br>`done (in, before, after, in or before, in or after) ...`<br>`... YYYY-MM-DD YYYY-MM-DD`<br>`... (last, this, next) (week, month, quarter, year)`<br>`... (YYYY-Www,YYYY-mm, YYYY-Qq, YYYY)`<br>`has done date`<br>`no done date`<br>`done date is invalid` | `sort by done` | `group by done` | `hide done date` | `task.done` |
2828
| `created (on, before, after, on or before, on or after) <date>`<br>`created (in, before, after, in or before, in or after) ...`<br>`... YYYY-MM-DD YYYY-MM-DD`<br>`... (last, this, next) (week, month, quarter, year)`<br>`... (YYYY-Www,YYYY-mm, YYYY-Qq, YYYY)`<br>`has created date`<br>`no created date`<br>`created date is invalid` | `sort by created` | `group by created` | `hide created date` | `task.created` |

docs/Scripting/Task Properties.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,10 +121,14 @@ For more information, including adding your own customised statuses, see [[Statu
121121
| ----- | ----- | ----- | ----- | ----- |
122122
| `task.id` | `string` | `'abcdef'` | `string` | `''` |
123123
| `task.blockedBy` | `string[]` | `['123456', 'abc123']` | `any[]` | `[]` |
124+
| `task.isBlocked(query.allTasks)` | `boolean` | `false` | `boolean` | `false` |
125+
| `task.isBlocking(query.allTasks)` | `boolean` | `false` | `boolean` | `false` |
124126

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

127129
1. See the page [[Task Dependencies]], which explains the dependencies facility.
130+
1. `Task.isBlocked()` behaves the same as `is blocked`: see [[Filters#Blocked Tasks]].
131+
1. `Task.isBlocking()` behaves the same as `is blocking`: see [[Filters#Blocking Tasks]].
128132
1. Task Dependencies were released in Tasks X.Y.Z.
129133

130134
## Values for Other Task Properties

tests/Scripting/TaskProperties.test.task_dependency_fields.approved.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
| ----- | ----- | ----- | ----- | ----- |
55
| `task.id` | `string` | `'abcdef'` | `string` | `''` |
66
| `task.blockedBy` | `string[]` | `['123456', 'abc123']` | `any[]` | `[]` |
7+
| `task.isBlocked(query.allTasks)` | `boolean` | `false` | `boolean` | `false` |
8+
| `task.isBlocking(query.allTasks)` | `boolean` | `false` | `boolean` | `false` |
79

810

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

tests/Scripting/TaskProperties.test.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import { TaskBuilder } from '../TestingTools/TaskBuilder';
99
import { verifyMarkdownForDocs } from '../TestingTools/VerifyMarkdown';
1010
import { parseAndEvaluateExpression } from '../../src/Scripting/TaskExpression';
1111
import { MarkdownTable } from '../../src/lib/MarkdownTable';
12+
import { makeQueryContextWithTasks } from '../../src/Scripting/QueryContext';
1213
import { addBackticks, determineExpressionType, formatToRepresentType } from './ScriptingTestHelpers';
1314

1415
window.moment = moment;
@@ -20,9 +21,10 @@ describe('task', () => {
2021
const markdownTable = new MarkdownTable(['Field', 'Type 1', 'Example 1', 'Type 2', 'Example 2']);
2122
const task1 = TaskBuilder.createFullyPopulatedTask();
2223
const task2 = new TaskBuilder().description('minimal task').status(Status.makeInProgress()).build();
24+
const queryContext = makeQueryContextWithTasks(task1.path, [task1, task2]);
2325
for (const field of fields) {
24-
const value1 = parseAndEvaluateExpression(task1, field, undefined);
25-
const value2 = parseAndEvaluateExpression(task2, field, undefined);
26+
const value1 = parseAndEvaluateExpression(task1, field, queryContext);
27+
const value2 = parseAndEvaluateExpression(task2, field, queryContext);
2628
const cells = [
2729
addBackticks(field),
2830
addBackticks(determineExpressionType(value1)),
@@ -96,6 +98,8 @@ describe('task', () => {
9698
// force line break
9799
'task.id',
98100
'task.blockedBy',
101+
'task.isBlocked(query.allTasks)',
102+
'task.isBlocking(query.allTasks)',
99103
]);
100104
});
101105

0 commit comments

Comments
 (0)