Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/How To/Make a query user interface.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,12 @@ We can combine:
- enable or disable other search features, such as nested tasks, short mode, backlink and buttons,
- and allow arbitrary extra instructions to be added:

<!--
The following screenshot is copied from
Manual Testing/Frontmatter/Placeholder examples to capture in tests and docs.md
in the sample vault
-->

![Meta Bind widgets to edit Query File Defaults](../images/query-file-defaults-meta-bind-controls.png)
<span class="caption">Meta Bind widgets to edit Query File Defaults</span>

Expand All @@ -39,6 +45,7 @@ Follow these steps, which assume you have already [turned off Obsidian's Restric

<!-- snippet: DocsSamplesForDefaults.test.DocsSamplesForDefaults_meta-bind-widgets-snippet.approved.md -->
```md
toolbar: `INPUT[toggle:TQ_show_toolbar]`
short mode: `INPUT[toggle:TQ_short_mode]`
tree: `INPUT[toggle:TQ_show_tree]`
tags: `INPUT[toggle:TQ_show_tags]`
Expand Down
2 changes: 2 additions & 0 deletions docs/Queries/Query File Defaults.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ TQ_show_scheduled_date:
TQ_show_start_date:
TQ_show_tags:
TQ_show_task_count:
TQ_show_toolbar:
TQ_show_tree:
TQ_show_urgency:
---
Expand Down Expand Up @@ -237,6 +238,7 @@ The `type` values are explained in the [Property types](https://help.obsidian.md
"TQ_show_start_date": "checkbox",
"TQ_show_tags": "checkbox",
"TQ_show_task_count": "checkbox",
"TQ_show_toolbar": "checkbox",
"TQ_show_tree": "checkbox",
"TQ_show_urgency": "checkbox"
}
Expand Down
2 changes: 1 addition & 1 deletion docs/What is New/Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ _In recent [Tasks releases](https://github.com/obsidian-tasks-group/obsidian-tas

- X.Y.Z:
- Add [[Status Types#ON_HOLD|ON_HOLD]] status type.
- Add 'Copy results' button: an initial implementation, which is not yet documented.
- Add toolbar containing a 'Filter by description' box and 'Copy results' button: these are not yet documented.
- 7.22.0:
- Fix [[Recurring Tasks#Priority of Dates|priority of dates in recurring tasks]] when using [[Recurring Tasks#Remove scheduled date on recurrence|Remove scheduled date on recurrence]].
- Update the [[Obsidian Properties#How does Tasks interpret Obsidian Properties?|table of examples]] to show how to use properties with nested data and object serialisation.
Expand Down
Binary file modified docs/images/query-file-defaults-meta-bind-controls.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion resources/sample_vaults/Tasks-Demo/.obsidian/types.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"TQ_show_tags": "checkbox",
"TQ_show_task_count": "checkbox",
"TQ_show_tree": "checkbox",
"TQ_show_urgency": "checkbox"
"TQ_show_urgency": "checkbox",
"TQ_show_toolbar": "checkbox"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ TQ_extra_instructions: |-
# sort by done date
# ignore global query
TQ_short_mode: false
TQ_show_backlink: true
TQ_show_backlink: false
TQ_show_cancelled_date: true
TQ_show_created_date: true
TQ_show_depends_on: true
Expand All @@ -21,9 +21,10 @@ TQ_show_recurrence_rule: true
TQ_show_scheduled_date: true
TQ_show_start_date: true
TQ_show_tags: true
TQ_show_task_count: true
TQ_show_task_count: false
TQ_show_toolbar: true
TQ_show_tree: true
TQ_show_urgency: true
TQ_show_urgency: false
TQ_sort_by:
- description
TQ_group_by:
Expand All @@ -39,6 +40,7 @@ TQ_group_by:

<!-- placeholder to force blank line before included text --><!-- include: DocsSamplesForDefaults.test.DocsSamplesForDefaults_meta-bind-widgets-include.approved.md -->

toolbar: `INPUT[toggle:TQ_show_toolbar]`
short mode: `INPUT[toggle:TQ_short_mode]`
tree: `INPUT[toggle:TQ_show_tree]`
tags: `INPUT[toggle:TQ_show_tags]`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ TQ_show_scheduled_date: false
TQ_show_start_date: false
TQ_show_tags: false
TQ_show_task_count: false
TQ_show_toolbar: false
TQ_show_tree: false
TQ_show_urgency: false
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ TQ_show_scheduled_date:
TQ_show_start_date:
TQ_show_tags:
TQ_show_task_count:
TQ_show_toolbar:
TQ_show_tree:
TQ_show_urgency:
---
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ TQ_show_scheduled_date: true
TQ_show_start_date: true
TQ_show_tags: true
TQ_show_task_count: true
TQ_show_toolbar: true
TQ_show_tree: true
TQ_show_urgency: true
---
Expand Down
24 changes: 24 additions & 0 deletions src/Query/QueryFileDefaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,31 @@ enum Handler {
AddValue = 'addValue',
}

// Steps for adding a new property to Query File Defaults:
// 1. Add the new value to queryProperties below.
// 2. Add it to metaBindPluginWidgets() below
// 3. Build the plugin and add it to the test vault: resources/sample_vaults/Tasks-Demo/
// 4. Open the test vault in Obsidian
// 5. Open each of these files, and run the 'Tasks: Add all Query File Defaults properties' command,
// and set its value to be consistent with the existing properties:
// - Test Data/query_file_defaults_all_options_false.md
// - Test Data/query_file_defaults_all_options_null.md
// - Test Data/query_file_defaults_all_options_true.md
// 6. Sort the properties in each file in alphabetical order
// 7. Run the 'Tasks: Add all Query File Defaults properties' command, to update query_file_defaults_all_options_*.json
// 8. Run the tests, to update all inline snapshots and approved files.
// 9. Run mdsnippets to update the docs and sample vault - or let the GitHub Action do it after merging to main

// Note: This file is excluded from SonarCloud duplication-checks,
// as the duplication here provides clarity.
// Instructions are listed in the order that items are displayed in Tasks search results
const queryProperties = [
{
name: 'TQ_show_toolbar',
type: 'checkbox',
display: 'toolbar',
handler: Handler.ShowAndHide,
},
{
name: 'TQ_explain',
type: 'checkbox',
Expand Down Expand Up @@ -201,11 +222,14 @@ export class QueryFileDefaults {

/**
* Return text that creates MetaBind widgets for users to edit query file defaults.
*
* This is used to generate content in the user documentation.
*/
public metaBindPluginWidgets() {
// This is initially hard-coded, though I intend to machine-generate it eventually.
// Its text is embedded in the test vault and in the user guide.
return `
toolbar: \`INPUT[toggle:TQ_show_toolbar]\`
short mode: \`INPUT[toggle:TQ_short_mode]\`
tree: \`INPUT[toggle:TQ_show_tree]\`
tags: \`INPUT[toggle:TQ_show_tags]\`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"TQ_show_start_date": "checkbox",
"TQ_show_tags": "checkbox",
"TQ_show_task_count": "checkbox",
"TQ_show_toolbar": "checkbox",
"TQ_show_tree": "checkbox",
"TQ_show_urgency": "checkbox"
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<!-- placeholder to force blank line before included text -->


toolbar: `INPUT[toggle:TQ_show_toolbar]`
short mode: `INPUT[toggle:TQ_short_mode]`
tree: `INPUT[toggle:TQ_show_tree]`
tags: `INPUT[toggle:TQ_show_tags]`
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@

toolbar: `INPUT[toggle:TQ_show_toolbar]`
short mode: `INPUT[toggle:TQ_short_mode]`
tree: `INPUT[toggle:TQ_show_tree]`
tags: `INPUT[toggle:TQ_show_tags]`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ TQ_show_scheduled_date:
TQ_show_start_date:
TQ_show_tags:
TQ_show_task_count:
TQ_show_toolbar:
TQ_show_tree:
TQ_show_urgency:
---
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ TQ_show_scheduled_date: true
TQ_show_start_date: true
TQ_show_tags: true
TQ_show_task_count: true
TQ_show_toolbar: true
TQ_show_tree: true
TQ_show_urgency: true
---
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@
"TQ_show_start_date": false,
"TQ_show_tags": false,
"TQ_show_task_count": false,
"TQ_show_toolbar": false,
"TQ_show_tree": false,
"TQ_show_urgency": false
},
"frontmatterLinks": [],
"frontmatterPosition": {
"end": {
"col": 3,
"line": 24,
"offset": 585
"line": 25,
"offset": 608
},
"start": {
"col": 0,
Expand All @@ -43,30 +44,30 @@
"position": {
"end": {
"col": 39,
"line": 26,
"offset": 626
"line": 27,
"offset": 649
},
"start": {
"col": 0,
"line": 26,
"offset": 587
"line": 27,
"offset": 610
}
}
}
],
"listItems": [
{
"parent": -28,
"parent": -29,
"position": {
"end": {
"col": 59,
"line": 28,
"offset": 687
"line": 29,
"offset": 710
},
"start": {
"col": 0,
"line": 28,
"offset": 628
"line": 29,
"offset": 651
}
},
"task": " "
Expand All @@ -77,8 +78,8 @@
"position": {
"end": {
"col": 3,
"line": 24,
"offset": 585
"line": 25,
"offset": 608
},
"start": {
"col": 0,
Expand All @@ -92,13 +93,13 @@
"position": {
"end": {
"col": 39,
"line": 26,
"offset": 626
"line": 27,
"offset": 649
},
"start": {
"col": 0,
"line": 26,
"offset": 587
"line": 27,
"offset": 610
}
},
"type": "heading"
Expand All @@ -107,13 +108,13 @@
"position": {
"end": {
"col": 59,
"line": 28,
"offset": 687
"line": 29,
"offset": 710
},
"start": {
"col": 0,
"line": 28,
"offset": 628
"line": 29,
"offset": 651
}
},
"type": "list"
Expand All @@ -124,20 +125,20 @@
"position": {
"end": {
"col": 11,
"line": 28,
"offset": 639
"line": 29,
"offset": 662
},
"start": {
"col": 6,
"line": 28,
"offset": 634
"line": 29,
"offset": 657
}
},
"tag": "#task"
}
]
},
"fileContents": "---\nTQ_explain: false\nTQ_extra_instructions: |-\n # press shift-return to add new lines\n not done\nTQ_short_mode: false\nTQ_show_backlink: false\nTQ_show_cancelled_date: false\nTQ_show_created_date: false\nTQ_show_depends_on: false\nTQ_show_done_date: false\nTQ_show_due_date: false\nTQ_show_edit_button: false\nTQ_show_id: false\nTQ_show_on_completion: false\nTQ_show_postpone_button: false\nTQ_show_priority: false\nTQ_show_recurrence_rule: false\nTQ_show_scheduled_date: false\nTQ_show_start_date: false\nTQ_show_tags: false\nTQ_show_task_count: false\nTQ_show_tree: false\nTQ_show_urgency: false\n---\n\n# query_file_defaults_all_options_false\n\n- [ ] #task Task in 'query_file_defaults_all_options_false'\n",
"fileContents": "---\nTQ_explain: false\nTQ_extra_instructions: |-\n # press shift-return to add new lines\n not done\nTQ_short_mode: false\nTQ_show_backlink: false\nTQ_show_cancelled_date: false\nTQ_show_created_date: false\nTQ_show_depends_on: false\nTQ_show_done_date: false\nTQ_show_due_date: false\nTQ_show_edit_button: false\nTQ_show_id: false\nTQ_show_on_completion: false\nTQ_show_postpone_button: false\nTQ_show_priority: false\nTQ_show_recurrence_rule: false\nTQ_show_scheduled_date: false\nTQ_show_start_date: false\nTQ_show_tags: false\nTQ_show_task_count: false\nTQ_show_toolbar: false\nTQ_show_tree: false\nTQ_show_urgency: false\n---\n\n# query_file_defaults_all_options_false\n\n- [ ] #task Task in 'query_file_defaults_all_options_false'\n",
"filePath": "Test Data/query_file_defaults_all_options_false.md",
"getAllTags": [
"#task"
Expand Down
Loading