obsidian-tasks-group / obsidian-tasks

Task management for the Obsidian knowledge base.
https://publish.obsidian.md/tasks/
MIT License
2.49k stars 231 forks source link

There should be a filter for a file's links #1812

Open Zataghni opened 1 year ago

Zataghni commented 1 year ago

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

🔖 Feature description

Currently, it is possible to filter tasks using 'filename', 'path' and 'heading'. I suggest the addition of a 'filelinks' filter, which will filter tasks from files that contains a link to some other file.

✔️ Solution

Here's an example of how that query looks like in my imagination:

'''tasks filelinks include project1.md due today not done '''

This would, for instance, allow the user to create a template for Project files with a query that will locate the tasks from files that mention said project, like so:

'''tasks filelinks include {{title}} tags contain habit not done '''

It would be useful for maintaining a recurring task (say, for instance, a 'habit' task) within it's own note, among other 'habit' note files inside a 'Habits' folder or database. For instance, my project file "Learn digital art" includes many types of tasks, some of them within the project's file, and some of them are categorized as habits (e.g. "- [ ] Practice drawing 🔁 everyday when done") and live within their own note files.

❓ Alternatives

No response

📝 Additional Context

No response

claremacrae commented 1 year ago

Can you please give some complete examples of task and filenames, and queries - that demonstrate exactly what you have in mind?

I am trying to work out how this differs from other existing similar requests, and a picture few lines of markdown paints a thousand words.

Zataghni commented 1 year ago

No problem. I was going to do so before posting this request, but I had to attend to something else but didn't want to just leave the tab open without posting. So I'll elaborate a bit more.

So, below is an example of a 'habit' note which contains links to: 1) A 'project' note -- as in, a note where one-time tasks can be captured to, and where there is a query to display the recurring tasks from notes that contain a link to the project note itself 2) A few 'area'-type notes -- as in, notes that organize information (in the form of notes, tasks, habits, people, you name it) related to the subject of the note (in this example, "Home" and "Cleaning"

filelinksfromhabittask

Now, there should be other similar habit notes to "Take out the trash" -- Do the dishes, Wash clothes etc. Each of these notes contain a single recurring task, but several links and may pertain to one or more projects and one or several areas.

The image below represents a 'project' note, which, as mentioned before, contains one-time tasks and wants to pull the recurring tasks from the 'habit' notes that contain a link to it.

filelinksfilterprojectnoteexample

Now, the currently existing filters related to file properties (path, filename and heading) won't suffice for this kind of application, since the user would have to add each note individually. They could use tags instead, but it would not be desirable when dealing with temporary projects that will eventually be archived or deleted once they're finished.

Other similar requests that I've seen were asking for the ability to filter for tasks from the same note as the query, but that's not what I have in mind since it's dealing with file properties of the file where the query was written. Instead, I want to filter for a file property of where the task is written, namely, the notes that are referenced by the file where the task is.

Hopefully I made it somewhat clearer. If not, ask away :)

claremacrae commented 1 year ago

Thank you. I am struggling to quickly parse the actual intended behaviour out of the long motivation description, in a short amount of time.

This is what I have spotted:

Instead, I want to filter for a file property of where the task is written, namely, the notes that are referenced by the file where the task is.

Edit: I have read that sentence several times and sorry but I do not understand what it is asking for.

Please can you translate that into Markdown (not screenshot) examples.

An example might be:

File1.md contains my tasks

- [ ] Task 1 [[File 2]]

And also links to [[File 3]]

Then show me what your query would look like.

I am trying to tell whether you are searching for tasks that

Zataghni commented 1 year ago

Thank you.

I am trying to tell whether you are searching for tasks that

  • link to a particular note
  • Or are in file that links anywhere to a particular note
  • Something else entirely

I am searching for the second option: tasks that are in a file that links anywhere to a particular note.

File1.md contains my tasks

- [ ] Task 1 [[File 2]]

And also links to [[File 3]]

Using this example, I would have the following query in File 4.md:

'''tasks
filelinks include "File 3"
'''

Which would give me Task 1 and all other tasks in File1.md.

claremacrae commented 1 year ago

Thank you for the explanation. I am still not totally sure that I understand it correctly.

This would be rather a complex facility to provide clear user documentation for.

I also think the name filelinks does not at all convey what the behaviour would be, so a much clearer name would be needed, if this were every to be implemented.

It might help to know whether the dataview plugin allowed this facility, and if so, what its query would look like.

EdJoJob commented 5 months ago

A use-case for this would be having tasks written in daily-notes, but wanting a view in a project note:

2024-06-04.md

    - [ ] things for [[project-foo]]
        - [ ] one
        - [ ] two
        - [ ] three
    - [ ] another task not for any project
    - [ ] get better for [[health and wellness]]

project-foo.md

'''tasks
filelinks include {{query.file.filename}}
'''

which would render the below tasks for 2024-06-04:

    - [ ] things for [[project-foo]]
        - [ ] one
        - [ ] two
        - [ ] three

Although this may be different from @Zataghni's request, which to my understanding would render all the tasks defined in 2024-06-04 into project-foo.

If we require a task, or a parent task of the task by sub-items, to have a link to the file being filtered on then tasklinks might be a useful filter name. These would be similar to the file.inlinks,file.outlinks, or task.outlinks properties in dataview.

These would be to view where the task collection happening as a primary detail, rather than where a task is defined. The Filters for File Properties would be the other way around (i.e. where the task is defined is usually more important than where tasks are being collected to)