Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter Tasks by Properties Frontmatter #2480

Closed
4 of 5 tasks
Foffo96 opened this issue Dec 6, 2023 · 12 comments
Closed
4 of 5 tasks

Filter Tasks by Properties Frontmatter #2480

Foffo96 opened this issue Dec 6, 2023 · 12 comments
Assignees
Labels
priority: high A high priority/important request scope: filters Additions and modifications to the search filters scope: parsing markdown See also 'scope: global filter' scope: tags Anything to do with tags, both as `#` and in YAML frontmatter status: in progress At least a partial implementation exists, either work-in-progress or some implementation ideas type: enhancement New feature or request

Comments

@Foffo96
Copy link

Foffo96 commented Dec 6, 2023

⚠️ Please check that this feature request hasn't been suggested before.

  • I searched previous Ideas in Discussions didn't find any similar feature requests.
  • I searched previous Issues didn't find any similar feature requests.
  • I am only requesting a single feature. Multiple changes should be split into individual requests, with links between them.
  • I believe my requested feature will be generally applicable to other users, not just me: it is not uniquely tied to my personal workflow.

🔖 Feature description

It will be useful to filter tasks from the file properties frontmatter by {key} and {value}.

✔️ Solution

In my case, i’m trying to use this plugin to handle tasks coming from work meetings.
Since I have multiple work projects, it would be useful to filter them with info from the file properties frontmatter.

For example
‘ ‘ ‘tasks
Properties.{key} includes {value}
‘ ‘ ‘
Or

‘ ‘ ‘tasks
Filter by function task.file.properties.{key} = {value}
‘ ‘ ‘

I know that a workaround is to insert a tag in the task description like follows, but that would mean to write it for every task in that particular meeting and to have less readable tasks.

  • #AI #Project1 This is a task coming from a meeting for Project1

‘ ‘ ‘tasks
Description includes Project1
‘ ‘ ‘

❓ Alternatives

No response

📝 Additional Context

Added by @claremacrae:

See #2480 (comment) below for remaining steps for the implementation.

@Foffo96 Foffo96 added the type: enhancement New feature or request label Dec 6, 2023
@claremacrae
Copy link
Collaborator

Hi, thanks for using Tasks.

Indeed, this would be useful.

Searching the docs for 'Frontmatter' shows this:

https://publish.obsidian.md/tasks/Getting+Started/Tags#Using+tags+in+YAML%2C+Frontmatter+or+file+Properties
image

So feel free to upvote #232 and I'll close this as a duplicate.

@claremacrae claremacrae closed this as not planned Won't fix, can't repro, duplicate, stale Dec 6, 2023
@claremacrae claremacrae added scope: filters Additions and modifications to the search filters scope: tags Anything to do with tags, both as `#` and in YAML frontmatter scope: parsing markdown See also 'scope: global filter' duplicate This issue, pull request or discussion already exists labels Dec 6, 2023
@claremacrae claremacrae pinned this issue Jun 23, 2024
@claremacrae
Copy link
Collaborator

I'm reopening this so that I can track its progress - which cannot be done in Discussions.

@claremacrae claremacrae reopened this Jul 1, 2024
@claremacrae claremacrae added priority: high A high priority/important request status: in progress At least a partial implementation exists, either work-in-progress or some implementation ideas and removed duplicate This issue, pull request or discussion already exists labels Jul 1, 2024
@claremacrae claremacrae self-assigned this Jul 1, 2024
@claremacrae
Copy link
Collaborator

claremacrae commented Jul 11, 2024

Remaining actions for first release

  • Add support for task.file.frontmatter
  • Standardise TasksFile.frontmatter.tags
  • Add support for task.file.hasProperty('property name')
  • Add support for task.file.property('property name')
  • Add support for task.file.propertyAsDate('property name')
  • Ensure that Tasks updates its cache when frontmatter is edited
    • For files containing tasks
  • Address the TODO in this code section to ensure always correct handling of frontmatter when a file is renamed.
    • Or add debug logging
  • Decide what to do with any null values in frontmatter values and arrays - on non-tags list properties
    • Probably convert [null] to []
    • Test with array of numbers
    • If fixing it is less work than documenting working around the main!
  • Decide whether any tag global filter should be removed from lists of tags - YES
  • Review and remove all the TODO comments in code for this facility

Testing

  • Test filter by function query.file.hasProperty('property name')
  • Test filter by function query.file.property('property name')
  • Test with JSON frontmatter

Documentation

  • Document filter by function task.file.hasProperty()
  • Document filter by function task.file.property()
  • Document level of support for nested properties
  • How to put a default due date as a property in a file, for tasks that don't have due dates
  • Tasks in Kanban plugin boards
  • Tasks not in Kanban plugin boards

Example for documentation

group by function \
    '`[' + task.file.property('tags').join('').split('/')[1] + ']`' + \
    ' [[' + task.file.filenameWithoutExtension + ']]'

Actions for later releases

  • Provide access to all tags in a file (body and frontmatter)
  • Remove any tag global filter from list of all tags in the file
  • Standardise aliases
  • Add support for query.file.hasProperty('property name) and query.file.property('property name)
    • Query constructor needs ability to take TasksFile, not just path
  • Show how to use a multi-line property in the query file to place common text in any Tasks queries in the file
    • Note that Mustache does not support logic, so we cannot call functions inside placeholders like {{query.file....}}

Searching

  • Implement property-name includes/does not include etc - to be able to do searches without knowing JavaScript
    • Need to figure out to supply property names that have spaces in.

@claremacrae
Copy link
Collaborator

Hi, we have an implementation of this that is very close to release - I am hoping it will go out this coming weekend....

It would really, really help us out if people here could test it out please.

It's been a lot of work to implement this and get it to a usable state. Testing like this is a fantastic way for you to contribute back to the plugin and help out both the developers and other users, please....

I am specifically looking for:

  1. Comments if any particular bits of the documentation are unclear
  2. Real-world examples of use to add to the documentation.

To try it out:

  1. Read the documentation.
    • Read the warning about the known bug that will be fixed before release.
  2. Download a test build, from here
    • The Tasks-Demo... link is a test vault
    • Or you can expand dist-verified and overwrite the Tasks plugin installation in your vault.

Thanks to @ilandikov for help on this feature.

@claremacrae
Copy link
Collaborator

Please record any feedback or examples in this ticket. Thank you!

@claremacrae
Copy link
Collaborator

I've shared the above post in #232, where we have received comments from multiple people in the past...

@ilandikov
Copy link
Collaborator

@claremacrae couple of comments after reading the docs. I'm nitpicking here...

Снимок экрана 2024-08-01 в 16 54 53

  • Note the [Quote!] at the start of the quote. I don't think it should be there.
  • I think front matter is spelled in 2 words. But in any case, I think we should not be talking about front matter at all. I suggest changing In the Tasks documentation, we refer to these as Frontmatter Properties, to distinguish them from Task and Query properties. to In the Tasks documentation, we refer to these as File Properties, to distinguish them from Task and Query properties.. (I replaced Frontmatter to File)
  • The # prefix is added to all tag values in frontmatter -> The # prefix is added to all tag values in the output
  • Tasks reads both YAML and [JSON](https://help.obsidian.md/Editing+and+formatting/Properties#JSON+Properties) properties. -> Tasks reads both YAML and [JSON](https://help.obsidian.md/Editing+and+formatting/Properties#JSON+Properties) formats. (properties -> formats)
  • Are you sure there is space after !: filter by function ! task.file.property('tags').includes('#notasks')? (There is another line like that later)

@claremacrae
Copy link
Collaborator

Thanks!

@claremacrae
Copy link
Collaborator

  • Note the [Quote!] at the start of the quote. I don't think it should be there.

Done.

  • I think front matter is spelled in 2 words. But in any case, I think we should not be talking about front matter at all. I suggest changing In the Tasks documentation, we refer to these as Frontmatter Properties, to distinguish them from Task and Query properties. to In the Tasks documentation, we refer to these as File Properties, to distinguish them from Task and Query properties.. (I replaced Frontmatter to File)

I should have explained earlier - my concern about calling them File Properties is how to distinguish them from all the existing File Properties:

image

I feel that using 'File Properties' for two different types of thing is potentially rather confusing.

Also, in future we will likely provide access to the OS' file creation date and modification date, and some users store that kind of data in front-matter too... So that's another thing that could be confusing if this new feature uses 'File Properties'.

I initially used 'Obsidian Properties' but felt it was unclear or unspecific...

  • The # prefix is added to all tag values in frontmatter -> The # prefix is added to all tag values in the output

I wasn't sure that output was clear, so went for:

  • The # prefix is added to all tag values returned by this function.
  • Tasks reads both YAML and [JSON](https://help.obsidian.md/Editing+and+formatting/Properties#JSON+Properties) properties. -> Tasks reads both YAML and [JSON](https://help.obsidian.md/Editing+and+formatting/Properties#JSON+Properties) formats. (properties -> formats)

Done

  • Are you sure there is space after !: filter by function ! task.file.property('tags').includes('#notasks')? (There is another line like that later)

Yes, it definitely works, and I thought that the space character might make the ! stand out a bit more clearly....

@claremacrae
Copy link
Collaborator

I opted for "Obsidian Properties" in the end, having found some articles online calling them that:

@claremacrae
Copy link
Collaborator

This has just been released in Tasks 7.7.0.

For details and examples, see the Obsidian Properties documentation page.

@ilandikov
Copy link
Collaborator

Awesome! =)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: high A high priority/important request scope: filters Additions and modifications to the search filters scope: parsing markdown See also 'scope: global filter' scope: tags Anything to do with tags, both as `#` and in YAML frontmatter status: in progress At least a partial implementation exists, either work-in-progress or some implementation ideas type: enhancement New feature or request
Projects
Status: 🎉 Released
Development

No branches or pull requests

3 participants