|
| 1 | +--- |
| 2 | +publish: true |
| 3 | +--- |
| 4 | + |
| 5 | +# How to make a query user interface |
| 6 | + |
| 7 | +<span class="related-pages">#plugin/meta-bind</span> |
| 8 | + |
| 9 | +## Meta Bind Tasks User Interface to Query File Defaults |
| 10 | + |
| 11 | +> [!released] |
| 12 | +> Query File Defaults were introduced in Tasks X.Y.Z. |
| 13 | +
|
| 14 | +The [[Meta Bind Plugin]] allows Obsidian users to make their notes interactive with inline input fields, metadata displays, and buttons. |
| 15 | + |
| 16 | +We can combine: |
| 17 | + |
| 18 | +1. The Tasks plugin's [[Query File Defaults]] facility, based on specific properties named `TQ_*`, |
| 19 | +2. The Meta Bind plugin's ability to create widgets to modify note properties. |
| 20 | + |
| 21 | +... to create a User Interface to easily adjust your Tasks searches, that can: |
| 22 | + |
| 23 | +- show and hide each of the task properties, |
| 24 | +- enable or disable other search features, such as nested tasks, short mode, backlink and buttons, |
| 25 | +- and allow arbitrary extra instructions to be added: |
| 26 | + |
| 27 | + |
| 28 | +<span class="caption">Meta Bind widgets to edit Query File Defaults</span> |
| 29 | + |
| 30 | +## How to set it up |
| 31 | + |
| 32 | +Follow these steps, which assume you have already [turned off Obsidian's Restricted mode](https://help.obsidian.md/Extending+Obsidian/Plugin+security): |
| 33 | + |
| 34 | +1. Install and enable the [Meta Bind](https://obsidian.md/plugins?search=Meta%20Bind) plugin. |
| 35 | +2. Copy the Markdown code-block below. |
| 36 | +3. Paste the Markdown in to a note in Obsidian that has one or more Tasks searches. |
| 37 | +4. Switch to Live Preview or Reading modes, to see the widgets. |
| 38 | +5. After experimenting, delete any labels and widgets that you do not need. |
| 39 | + |
| 40 | +<!-- snippet: DocsSamplesForDefaults.test.DocsSamplesForDefaults_meta-bind-widgets-snippet.approved.md --> |
| 41 | +```md |
| 42 | +short mode: `INPUT[toggle:TQ_short_mode]` |
| 43 | +tree: `INPUT[toggle:TQ_show_tree]` |
| 44 | +tags: `INPUT[toggle:TQ_show_tags]` |
| 45 | +id: `INPUT[toggle:TQ_show_id]` depends on: `INPUT[toggle:TQ_show_depends_on]` |
| 46 | +priority: `INPUT[toggle:TQ_show_priority]` |
| 47 | +recurrence rule: `INPUT[toggle:TQ_show_recurrence_rule]` on completion: `INPUT[toggle:TQ_show_on_completion]` |
| 48 | +start date: `INPUT[toggle:TQ_show_start_date]` scheduled date: `INPUT[toggle:TQ_show_scheduled_date]` due date: `INPUT[toggle:TQ_show_due_date]` |
| 49 | +created date: `INPUT[toggle:TQ_show_created_date]` cancelled date: `INPUT[toggle:TQ_show_cancelled_date]` done date: `INPUT[toggle:TQ_show_done_date]` |
| 50 | +urgency: `INPUT[toggle:TQ_show_urgency]` |
| 51 | +backlink: `INPUT[toggle:TQ_show_backlink]` |
| 52 | +edit button: `INPUT[toggle:TQ_show_edit_button]` postpone button: `INPUT[toggle:TQ_show_postpone_button]` |
| 53 | +task count: `INPUT[toggle:TQ_show_task_count]` |
| 54 | +extra instructions: `INPUT[textArea:TQ_extra_instructions]` |
| 55 | +explain: `INPUT[toggle:TQ_explain]` |
| 56 | +``` |
| 57 | +<!-- endSnippet --> |
| 58 | + |
| 59 | +## Why provide this? |
| 60 | + |
| 61 | +Some might say that this mechanism is perhaps a little awkward, and wouldn't it be good for Tasks to provide its own user interface? |
| 62 | + |
| 63 | +We agree, and we are tracking this in [issue #2579](https://github.com/obsidian-tasks-group/obsidian-tasks/issues/2579). |
| 64 | + |
| 65 | +However, the development process went something like this: |
| 66 | + |
| 67 | +1. Teach Tasks to use [[Obsidian Properties#Using Query Properties in Searches|query properties in searches]]. |
| 68 | +2. Discover that generating Tasks instructions from simple `true`/`false` properties required some really rather complex JavaScript code inside user queries, which was: |
| 69 | + - horrible for us to document, |
| 70 | + - horrible for users to have to copy and understand, cluttering up their searches. |
| 71 | +3. Implement the [[Query File Defaults]] mechanism. |
| 72 | +4. Discover that using Obsidian's [Properties view](https://help.obsidian.md/Plugins/Properties+view) core plugin was *sort-of-OK*, but: |
| 73 | + - it was a little tedious opening and closing that side-panel, |
| 74 | + - it does not do a very good job editing multi-line strings, which are useful with `TQ_extra_instructions`. |
| 75 | +5. Experiment with [[Meta Bind Plugin]] and decide this use of it is a relatively easy and big step forward, until such time as Obsidian has its own user interface! |
0 commit comments