Skip to content

Commit

Permalink
Merge pull request #2637 from obsidian-tasks-group/add-dependency-tas…
Browse files Browse the repository at this point in the history
…k-properties

docs: Add docs for task properties isBlocked() and isBlocking()
  • Loading branch information
claremacrae authored Feb 2, 2024
2 parents 7a8a85d + 009b427 commit cf6ff2b
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/Quick Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ This table summarizes the filters and other options available inside a `tasks` b
| **[[Task Dependencies]]** | | | | |
| `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` |
| `has blocked by`<br>`no blocked by` | | | `hide depends on` | `task.blockedBy` |
| `is blocked`<br>`is not blocked` | | | | |
| `is blocking`<br>`is not blocking` | | | | |
| `is blocked`<br>`is not blocked` | | | | `task.isBlocked(query.allTasks)` |
| `is blocking`<br>`is not blocking` | | | | `task.isBlocking(query.allTasks)` |
| **[[Filters#Filters for Dates in Tasks\|Dates]]** | | | | |
| `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` |
| `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` |
Expand Down
4 changes: 4 additions & 0 deletions docs/Scripting/Task Properties.md
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,14 @@ For more information, including adding your own customised statuses, see [[Statu
| ----- | ----- | ----- | ----- | ----- |
| `task.id` | `string` | `'abcdef'` | `string` | `''` |
| `task.blockedBy` | `string[]` | `['123456', 'abc123']` | `any[]` | `[]` |
| `task.isBlocked(query.allTasks)` | `boolean` | `false` | `boolean` | `false` |
| `task.isBlocking(query.allTasks)` | `boolean` | `false` | `boolean` | `false` |

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

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

## Values for Other Task Properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
| ----- | ----- | ----- | ----- | ----- |
| `task.id` | `string` | `'abcdef'` | `string` | `''` |
| `task.blockedBy` | `string[]` | `['123456', 'abc123']` | `any[]` | `[]` |
| `task.isBlocked(query.allTasks)` | `boolean` | `false` | `boolean` | `false` |
| `task.isBlocking(query.allTasks)` | `boolean` | `false` | `boolean` | `false` |


<!-- placeholder to force blank line after included text -->
8 changes: 6 additions & 2 deletions tests/Scripting/TaskProperties.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { TaskBuilder } from '../TestingTools/TaskBuilder';
import { verifyMarkdownForDocs } from '../TestingTools/VerifyMarkdown';
import { parseAndEvaluateExpression } from '../../src/Scripting/TaskExpression';
import { MarkdownTable } from '../../src/lib/MarkdownTable';
import { makeQueryContextWithTasks } from '../../src/Scripting/QueryContext';
import { addBackticks, determineExpressionType, formatToRepresentType } from './ScriptingTestHelpers';

window.moment = moment;
Expand All @@ -20,9 +21,10 @@ describe('task', () => {
const markdownTable = new MarkdownTable(['Field', 'Type 1', 'Example 1', 'Type 2', 'Example 2']);
const task1 = TaskBuilder.createFullyPopulatedTask();
const task2 = new TaskBuilder().description('minimal task').status(Status.makeInProgress()).build();
const queryContext = makeQueryContextWithTasks(task1.path, [task1, task2]);
for (const field of fields) {
const value1 = parseAndEvaluateExpression(task1, field, undefined);
const value2 = parseAndEvaluateExpression(task2, field, undefined);
const value1 = parseAndEvaluateExpression(task1, field, queryContext);
const value2 = parseAndEvaluateExpression(task2, field, queryContext);
const cells = [
addBackticks(field),
addBackticks(determineExpressionType(value1)),
Expand Down Expand Up @@ -96,6 +98,8 @@ describe('task', () => {
// force line break
'task.id',
'task.blockedBy',
'task.isBlocked(query.allTasks)',
'task.isBlocking(query.allTasks)',
]);
});

Expand Down

0 comments on commit cf6ff2b

Please sign in to comment.