feat: task checklist improvements #797
No reviewers
Labels
No Label
area/internal-code
changes requested
confirmed
dependencies
duplicate
good first issue
help wanted
hosting
invalid
kind/bug
kind/feature
question
wontfix
No Milestone
No project
No Assignees
2 Participants
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: vikunja/frontend#797
Loading…
Reference in New Issue
No description provided.
Delete Branch "feature/checklist-improvements"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
This PR adds checklist indicators in task detail and list views:
Based on this discussion in the forum.
Task checklist improvementsto feat: task checklist improvements@ -0,0 +43,4 @@
display: inline-flex;
align-items: center;
> svg {
No need to nest
svg
andcircle
in scoped styles.Fixed.
@ -0,0 +19,4 @@
// Searching in two different loops for each search term since that is way easier and more predicatble
// More "intelligent" solutions sometimes don't have all values or duplicates.
// Because we're sorting and removing duplicates of them, we can safely put everything in one giant array.
listPrefixes.forEach(pref => {
I might be wrong because of poor regex logic knowledge, maybe it's possible to use a simple one here:
https://regex101.com/r/WuD5uS/1
In combination with https://stackoverflow.com/a/2295681/15522256 a single loop + analysing the found match would be enough.
That said: Ignore if comment is annoying:
I'm forcefully trying to find a good usecase for regex, learn something new and am aware that the current solution is more than sufficient
I've modified it now to use a regex. The original implementation from the editor component was from a time where I didn't really knew regex, I think using one here makes it a lot simpler and easier to read.
@ -0,0 +43,4 @@
checked: number
}
export const getChecklistStatistics = (text: string): CheckboxStatistics => {
Independant of the regex: while looping through the loop we already know if a checkbox is checked or not. Why not save that info and return it by default. If you don't want to return an object in the original function you could write a second one that wraps the loop and omits all other info than
checkboxes
.I've modified that as well and moved the logic into another (unexported) function which returns the checked and unchecked independently from each other. I'm then using that function in the two other ones.
The original implementation in the editor component came out of a lot of trial and error and, because I didn't have any tests at that time either, was at the end a "do not touch, magic" kind of function. I don't even recall why I had two loops and then weren't even using the result. This new version is a lot cleaner.
Looks good :)
@ -0,0 +1,56 @@
const searchLength = 6
searchLength
,listPrefixes
andunchecked
are not used anymore. rest of this file looks good :) cool!Good catch :) I've removed them.