mabeyj / trilium-collection-views

An extension for Trilium Notes that implements different ways of viewing collections of notes.
MIT License
76 stars 5 forks source link

Regarding "Complete" label (builtin date expressions) #53

Open m1xds opened 9 months ago

m1xds commented 9 months ago

image Hi maybeyj:

is that possible that by some method we can make this "complete" update automatically? Now it's like "#complete=5" "#total=100", is that possible that we can make it like "#complete=$daycreated" "#total=timeleft"?

mabeyj commented 9 months ago

I'm not 100% sure what you're asking. Can you provide more details on how this would work?

Are you asking for Collection Views to have some way of setting certain labels on a note? In this case, do you want it to set #complete to $daycreated (a creation date of something?) and #total to timeleft (the current value of a #timeleft label?)? For it to do this automatically, when would it do this and how would it know what notes need to be updated?

m1xds commented 9 months ago

For example, this note: image For example, in this note, the tag "#completed" can only be set to a fixed number, and then the following completed progress bar can be displayed in the total cellection view: image This "progress bar" function is very very very very nice, but now it can only be manually updated every day, I don't know how to make it automatically update, which makes the usefulness greatly reduced, can you make "completed" and total equal to the value in a note, in this example, I just give an example, such as: "#competed=the days differences between the day of creating note with today". Thank you for your time!

mabeyj commented 9 months ago

Makes sense. Currently, this should be possible using Trilium's daily global event. A script could run daily that calculates and updates #completed and #total on each note.

I think it would be feasible to introduce some builtin date expressions like daysSince($dateCreated) and daysBetween($dateCreated,dueDate) that would allow Collection Views to perform these calculations.

If today is 2024-02-12 and a note was created on 2024-02-09, then daysSince($dateCreated) would return 3.
If #dueDate is 2029-02-11, then daysBetween($dateCreated,dueDate) would return 1825.

Then combined with a progress bar #attribute=daysSince($dateCreated),progressBar=daysBetween($dateCreated,dueDate) would show a bar with "3 / 1,825" today, "4 / 1,825" tomorrow, etc.

m1xds commented 9 months ago

Again, thank you so much for your time and detailed explanation!