Skip to content

Commit e0caf80

Browse files
authored
Merge pull request #3710 from obsidian-tasks-group/feat-query-file-defaults-toolbar
feat: Add show/hide toolbar to Query File Defaults facility
2 parents 51c2078 + 97692ff commit e0caf80

20 files changed

+138
-85
lines changed

docs/How To/Make a query user interface.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ We can combine:
2424
- enable or disable other search features, such as nested tasks, short mode, backlink and buttons,
2525
- and allow arbitrary extra instructions to be added:
2626

27+
<!--
28+
The following screenshot is copied from
29+
Manual Testing/Frontmatter/Placeholder examples to capture in tests and docs.md
30+
in the sample vault
31+
-->
32+
2733
![Meta Bind widgets to edit Query File Defaults](../images/query-file-defaults-meta-bind-controls.png)
2834
<span class="caption">Meta Bind widgets to edit Query File Defaults</span>
2935

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

4046
<!-- snippet: DocsSamplesForDefaults.test.DocsSamplesForDefaults_meta-bind-widgets-snippet.approved.md -->
4147
```md
48+
toolbar: `INPUT[toggle:TQ_show_toolbar]`
4249
short mode: `INPUT[toggle:TQ_short_mode]`
4350
tree: `INPUT[toggle:TQ_show_tree]`
4451
tags: `INPUT[toggle:TQ_show_tags]`

docs/Queries/Query File Defaults.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ TQ_show_scheduled_date:
193193
TQ_show_start_date:
194194
TQ_show_tags:
195195
TQ_show_task_count:
196+
TQ_show_toolbar:
196197
TQ_show_tree:
197198
TQ_show_urgency:
198199
---
@@ -237,6 +238,7 @@ The `type` values are explained in the [Property types](https://help.obsidian.md
237238
"TQ_show_start_date": "checkbox",
238239
"TQ_show_tags": "checkbox",
239240
"TQ_show_task_count": "checkbox",
241+
"TQ_show_toolbar": "checkbox",
240242
"TQ_show_tree": "checkbox",
241243
"TQ_show_urgency": "checkbox"
242244
}

docs/What is New/Changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ _In recent [Tasks releases](https://github.com/obsidian-tasks-group/obsidian-tas
1414

1515
- X.Y.Z:
1616
- Add [[Status Types#ON_HOLD|ON_HOLD]] status type.
17-
- Add 'Copy results' button: an initial implementation, which is not yet documented.
17+
- Add toolbar containing a 'Filter by description' box and 'Copy results' button: these are not yet documented.
1818
- 7.22.0:
1919
- 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]].
2020
- 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.
-2.67 KB
Loading

resources/sample_vaults/Tasks-Demo/.obsidian/types.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
"TQ_show_tags": "checkbox",
3939
"TQ_show_task_count": "checkbox",
4040
"TQ_show_tree": "checkbox",
41-
"TQ_show_urgency": "checkbox"
41+
"TQ_show_urgency": "checkbox",
42+
"TQ_show_toolbar": "checkbox"
4243
}
4344
}

resources/sample_vaults/Tasks-Demo/Manual Testing/Frontmatter/Placeholder examples to capture in tests and docs.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ TQ_extra_instructions: |-
66
# sort by done date
77
# ignore global query
88
TQ_short_mode: false
9-
TQ_show_backlink: true
9+
TQ_show_backlink: false
1010
TQ_show_cancelled_date: true
1111
TQ_show_created_date: true
1212
TQ_show_depends_on: true
@@ -21,9 +21,10 @@ TQ_show_recurrence_rule: true
2121
TQ_show_scheduled_date: true
2222
TQ_show_start_date: true
2323
TQ_show_tags: true
24-
TQ_show_task_count: true
24+
TQ_show_task_count: false
25+
TQ_show_toolbar: true
2526
TQ_show_tree: true
26-
TQ_show_urgency: true
27+
TQ_show_urgency: false
2728
TQ_sort_by:
2829
- description
2930
TQ_group_by:
@@ -39,6 +40,7 @@ TQ_group_by:
3940

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

43+
toolbar: `INPUT[toggle:TQ_show_toolbar]`
4244
short mode: `INPUT[toggle:TQ_short_mode]`
4345
tree: `INPUT[toggle:TQ_show_tree]`
4446
tags: `INPUT[toggle:TQ_show_tags]`

resources/sample_vaults/Tasks-Demo/Test Data/query_file_defaults_all_options_false.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ TQ_show_scheduled_date: false
2020
TQ_show_start_date: false
2121
TQ_show_tags: false
2222
TQ_show_task_count: false
23+
TQ_show_toolbar: false
2324
TQ_show_tree: false
2425
TQ_show_urgency: false
2526
---

resources/sample_vaults/Tasks-Demo/Test Data/query_file_defaults_all_options_null.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ TQ_show_scheduled_date:
1818
TQ_show_start_date:
1919
TQ_show_tags:
2020
TQ_show_task_count:
21+
TQ_show_toolbar:
2122
TQ_show_tree:
2223
TQ_show_urgency:
2324
---

resources/sample_vaults/Tasks-Demo/Test Data/query_file_defaults_all_options_true.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ TQ_show_scheduled_date: true
2020
TQ_show_start_date: true
2121
TQ_show_tags: true
2222
TQ_show_task_count: true
23+
TQ_show_toolbar: true
2324
TQ_show_tree: true
2425
TQ_show_urgency: true
2526
---

src/Query/QueryFileDefaults.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,31 @@ enum Handler {
88
AddValue = 'addValue',
99
}
1010

11+
// Steps for adding a new property to Query File Defaults:
12+
// 1. Add the new value to queryProperties below.
13+
// 2. Add it to metaBindPluginWidgets() below
14+
// 3. Build the plugin and add it to the test vault: resources/sample_vaults/Tasks-Demo/
15+
// 4. Open the test vault in Obsidian
16+
// 5. Open each of these files, and run the 'Tasks: Add all Query File Defaults properties' command,
17+
// and set its value to be consistent with the existing properties:
18+
// - Test Data/query_file_defaults_all_options_false.md
19+
// - Test Data/query_file_defaults_all_options_null.md
20+
// - Test Data/query_file_defaults_all_options_true.md
21+
// 6. Sort the properties in each file in alphabetical order
22+
// 7. Run the 'Tasks: Add all Query File Defaults properties' command, to update query_file_defaults_all_options_*.json
23+
// 8. Run the tests, to update all inline snapshots and approved files.
24+
// 9. Run mdsnippets to update the docs and sample vault - or let the GitHub Action do it after merging to main
25+
1126
// Note: This file is excluded from SonarCloud duplication-checks,
1227
// as the duplication here provides clarity.
1328
// Instructions are listed in the order that items are displayed in Tasks search results
1429
const queryProperties = [
30+
{
31+
name: 'TQ_show_toolbar',
32+
type: 'checkbox',
33+
display: 'toolbar',
34+
handler: Handler.ShowAndHide,
35+
},
1536
{
1637
name: 'TQ_explain',
1738
type: 'checkbox',
@@ -201,11 +222,14 @@ export class QueryFileDefaults {
201222

202223
/**
203224
* Return text that creates MetaBind widgets for users to edit query file defaults.
225+
*
226+
* This is used to generate content in the user documentation.
204227
*/
205228
public metaBindPluginWidgets() {
206229
// This is initially hard-coded, though I intend to machine-generate it eventually.
207230
// Its text is embedded in the test vault and in the user guide.
208231
return `
232+
toolbar: \`INPUT[toggle:TQ_show_toolbar]\`
209233
short mode: \`INPUT[toggle:TQ_short_mode]\`
210234
tree: \`INPUT[toggle:TQ_show_tree]\`
211235
tags: \`INPUT[toggle:TQ_show_tags]\`

0 commit comments

Comments
 (0)