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

Implement "Show tasks only when they contain specified tags" setting #49

Closed
Perlunas opened this issue Mar 22, 2021 · 10 comments
Closed
Assignees
Labels
feature-request New feature or request.
Projects
Milestone

Comments

@Perlunas
Copy link

This could be a lower hanging fruit comparing to the proper per-task filtering.

This would let us use tasks as "pseudo-database-records" if we add tags to them (partly solving request #23).

Currently, there are multiple ways to do per-file filtering (e.g. folders, filename, YAML fields, tags), but not a single way to target the tasks.

You could pass "query" into renderFileTasks function, extract the required tags and simply not render the tasks if they don't have the tags. A bit of code to redo "from and/or/not" logic but still not too complicated.

@blacksmithgu
Copy link
Owner

Full task support with tag filtering, on-complete, and so on is upcoming. I'll also fix a few bugs with the view which may cause task checkboxes to not work properly, since you should be able to check them to check the original task...

@blacksmithgu blacksmithgu self-assigned this Mar 23, 2021
@blacksmithgu blacksmithgu added the feature-request New feature or request. label Mar 23, 2021
@blacksmithgu
Copy link
Owner

I have good news and bad news. The good news is this is possible; the bad news is it requires a tiny bit of JavaScript:

```dataviewjs
dv.taskList(dv.pages("#project").file.tasks.where(t => t.text.includes("#tag")));
```

@hstagner
Copy link

Is it possible to list the pages that the tasks come from as well? This works beautifully, but it is only rendering the task itself. I'd like the extra context of pages, if possible.

@hstagner
Copy link

It also only appears to re-render on file open. Is that a bug?

@hstagner
Copy link

I have good news and bad news. The good news is this is possible; the bad news is it requires a tiny bit of JavaScript:

```dataviewjs
dv.taskList(dv.pages("#project").file.tasks.where(t => t.text.includes("#tag")));

Is there a way to combine this with tasks that are not completed so that only those that are not completed show?

@blacksmithgu
Copy link
Owner

Yes.

```dataviewjs
dv.taskList(dv.pages("#project").file.tasks.where(t => t.text.includes("#tag") && !t.completed));
```

@dpurnomo
Copy link

Yes.

```dataviewjs
dv.taskList(dv.pages("#project").file.tasks.where(t => t.text.includes("#tag") && !t.completed));

I notice that this will only catch if the task is without indentation. If the task is indented (like in a nested task list) it does not work for me. Perhaps a bug?

Example:

- [ ] Test task #tag → this works
    - [ ] Test task 2 #tag → This does not work

@sheeley sheeley added this to To do in Tasks Aug 25, 2021
@blacksmithgu blacksmithgu moved this from To do to In progress in Tasks Aug 25, 2021
@blacksmithgu blacksmithgu added this to the 0.4.6 milestone Aug 25, 2021
@sheeley
Copy link
Contributor

sheeley commented Aug 26, 2021

@blacksmithgu looking at this, it appears we should have an in, includes, or contains function. Did you have a preference?

@blacksmithgu
Copy link
Owner

We should add an inline in operator: 6 in [1, 2, 6], #tag in file.tags, and so on. There is already a non-inline contains(file.tags, #tag) for people who prefer that syntax, and lists will be getting a contains method later: file.tags.contains(#tag).

@sheeley sheeley moved this from In progress to To do in Tasks Sep 1, 2021
@blacksmithgu
Copy link
Owner

Yay, this is finally doable! Thanks to @sheeley for the implementation!

TASK WHERE contains(text, "#tag")

Tasks automation moved this from To do to Done Sep 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-request New feature or request.
Projects
Tasks
Done
Development

No branches or pull requests

5 participants