-
-
Notifications
You must be signed in to change notification settings - Fork 286
feat: Allow additional tasks states and filtering by states #675 #670
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
Conversation
Add dev setup to contributing Add tags as a property of task Add query by tag in query language Add sort by tag Added unit tests for coverage
Implement feedback on filter and tag sorting, ready for next release obsidian-tasks-group#632
docs: add documentation on tag sorting fix: handle lack of tag in the comparison for tag sorting test: add increased test coverage to tags
@schemar & @claremacrae here is the draft of adding new status types, will make the task management and tracking more flexible. I am using it locally and working fine. |
A task with a character between the square brackets should be marked as checked and have the is-checked class on the parent LI
Allows optional or features in development to be enabled conditionally, there is a second commit coming to move the new functionality under the relevant flags which will make the PR review and check in simpler as code can go in but not be used until the flag is set.
Thank you, @sytone. It appears this PR includs changes that are not relevant to this PR, or am I seeing that wrong? Does this PR depend on earlier PRs? |
It was only dependent on the tags pr. I have added the features capabilities as I am planning on adding the menu option which will be in a preview based mode to see how other users would want to use it. What extra did you see. |
oh it is the append global filter. I meant to push that to a separate branch on top of this and forgot to run command. Will pull it out |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks for doing this. I know the functionality will be greatly appreciated.
Some initial comments.
esbuild.config.mjs
Outdated
|
||
const banner = | ||
`/* | ||
import process from 'process'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file has been reformatted, which makes it impossible to see if or where the content has changed.
And also, not possible to know whether any change was related to the topic of this PR, or something independent that could/should have been in a separate PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ill reset the structure, ironically this is now formatted using the same settings as lint 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see #683
.gitattributes
Outdated
@@ -0,0 +1,2 @@ | |||
*.js text eol=lf |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does changing line endings relate to "feat: Allow additional tasks states and filtering by states"?
Could this be a separate PR, with a statement about motivation?
What impact will this have on anyone who already has a clone of this repo on Windows? In the past, when these attributes have changed, I think I have struggled to get a clean repo, because it sees any local CRLF as differences. I seem to recall being confused, in any case.
From my own experience, I feel that mixing (seemingly) unrelated changes inside one PR generally makes it harder for reviews. The more focussed a PR is, the quicker it can be reviewed, and the quicker separate PRs for later features can be started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This reduces noise in windows, if you have CRLF and then add them in the file will just go away as git is smart enough to know that they are the same on commit/push. However in a IDE they will be different as CRLF <> LF and you will get reg conflicts.
Adding this in just lets the IDE/git know they should always be LF on all operating systems and to ignore the git config settings for LF/CRLF for these files.
I can add this to a very small PR if needed, typically we would not make a separate PR for something like this and place it in a change going in as it is small and easily identified.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Made #682, so when it goes in an I merge with main this file will go away from this PR.
package.json
Outdated
"lint": "eslint ./src --fix && eslint ./tests --fix && tsc --noEmit --pretty && svelte-check", | ||
"test": "jest --ci", | ||
"test:dev": "jest --watch" | ||
"test:dev": "jest --watch", | ||
"test:obsidian": "pwsh -ExecutionPolicy Unrestricted -NoProfile -File ./scripts/Test-TasksInLocalObsidian.ps1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ooh, using PowerShell to drive Obsidian. This is very intriguing!
Will it work on Linux and Mac? (I know that PowerShell has been released on those platforms, but I don't know whether it can drive Obsidian on those platforms.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Later: it doesn't drive obsidian, it copies a distribution in to a vault.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it works across platforms. I use it on my linux machine and in WSL on windows. I am using it as bash sends me around the twist these days with string manipulation. Being able to work with objects in the shell is much better.
I am slowly playing with a PowerShell module that will work with obsidian and the shell plugin also supports running PowerShell scripts. This will setup synlinks to the vault you specify in a environment variable or via the command line and then start the build watch process. Makes the dev cycle faster.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
see #683
@@ -0,0 +1,53 @@ | |||
[CmdletBinding()] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, based on the file name, I misunderstood the purpose of this file. I though it was actually testing Obsidian, but it is copying the built plugin in to an Obsidian vault.
That's still very useful, but also a candidate for being in a separate PR please (alongside the associated change to package.json
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am using it to help me work on this PR. So there will be a chicken egg scenario. Ill make a separate PR and if it goes in first then this will disappear from this PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See #683
@@ -64,11 +66,10 @@ const taskFromLine = ({ line, path }: { line: string; path: string }): Task => { | |||
// Should never happen; everything in the regex is optional. | |||
console.error('Tasks: Cannot create task on line:', line); | |||
return new Task({ | |||
status: Status.Todo, | |||
status: Status.TODO, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my own education, I'm curious as to why Todo
-> TODO
?
Asking as it increases the number of changes to review, not because I want to change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Consistency in code, as these are constants I have seen they should be upper case in TS/JS. Also makes it super easy to see when reading code that these are not a normal variable.
* Compare to the fromString() method, which deserializes the object. | ||
*/ | ||
public toJSON() { | ||
return this.internalName; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is internalName?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is the string name or key that is used to identify the feature. This makes sense now, seeing how Feature is used in the settings code.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it is the key, separate to the nicer one that users see.
@@ -1,18 +1,31 @@ | |||
import { Feature, FeatureFlag } from './Feature'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seeing the feature flag code mixed in here makes me wonder if it would be possible for the feature flag feature to be pulled out and implemented as its own PR first?
I realised it may be too late for that now, but them being combined does mean a full review is going to take a while.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I could, see how much of a issue it is.
}; | ||
|
||
let settings: Settings = { ...defaultSettings }; | ||
|
||
export const getSettings = (): Settings => { | ||
// Check to see if there is a new flag and if so add it to the users settings. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this mean that if this code is released, users who look at their settings will see the feature flag and be inclined to turn it on, not realising that the feature is not fully tested, and so initially disabled by default for a good reason?
I think that's probably fine, but it would still be helpful to understand....
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is in the settings at the bottom with indicators to its stability.
@@ -21,3 +34,15 @@ export const updateSettings = (newSettings: Partial<Settings>): Settings => { | |||
|
|||
return getSettings(); | |||
}; | |||
|
|||
export const isFeatureEnabled = (internalName: string): boolean => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh interesting - I had looked for this kind of convenience method in the Feature code, not realising it would be in the Settings code.
Totally happy for it to be here... If there isn't a comment in the Feature code mentioning these accessors, it would probably be worth adding one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will updated comments, the settings is responsible for what is on and off, feature just lets the plugin in know about a feature and its internal state.
const defaultTasksWithStatus = [ | ||
'- [ ] Something to do', | ||
'- [/] Something I am doing', | ||
'- [x] Something I have done', | ||
'- [-] Something I will no longer do', | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the thinking behind changing the default statuses?
Will there be any change in behaviour from the current?
Oh, this is test code. I was confused by the variable name...
Closing. As well as containing unrelated changes, this is superseded by #799. |
In #2 (comment) @sytone proposed some changes that made it possible to have more than two state values and toggle them with clicks. Was this pull request that change? I think after all the closed PRs the user got demotivated to further tackle this feature merge 😰 It was a great idea though! |
Bummer this was closed. It's exactly what I'm looking for. Maybe I'll create a standalone plugin to accomplish this. |
Yes, this PR was closed for good reasons at the time. BUT I have been spending 3 weeks working approximately full time on incorporating the code from this PR in to the latest Tasks code base, fixing bugs and usability and backwards compatibility issues. I still have lots of work to do on the documentation. Then it will be released soon. Feel free to create another plugin if you wish @rinogo - but to get it releasable quality you will find it is a lot of work. |
That's great news! I was actually referring to specifically being able to cycle through each valid state (i.e. more than just unchecked/checked) of a checkbox Certainly, it's a lot more work incorporating changes like this into a larger codebase! Need any help testing? Happy to help out. |
Feel free: #1530 Do read the last two comments before spending ages setting up lots of custom statuses. |
A heavily modified, fixed and documented version of this PR was released in Tasks 1.24.0 - with major credit given to the author of this PR both in the docs and the announcement. |
Description
When toggling a task, it should be able to move through more states than Todo (- [ ]) or Done (- [x]). This new feature will allow users to provide additional states with - [-] and - [/] being available by default.
The users will also be able to add their own status types and transistions between them to allow further customization.
Changes
Motivation and Context
There have been multiple asks to have additional staus types in the discussions and other plugins now support this. To ensure the Tasks plugin can support all these requests and features the new status model has been created.
How has this been tested?
This has been tested via the new unit tests for the status and status registry. This will cover the existing functionality as well as the new ability to add new status types and transisii0ons. Currently there is no automated UI testing. That is being done manually.
As this change also impacts the Task object, UI and settings all related tests have been validated and updated as needed.
Screenshots (if appropriate):
Types of changes
Checklist:
yarn run lint
.By creating a Pull Request you agree to our Code of Conduct. For further guidance on contributing please see contributing guide