Hello,
Last week I shared my amateur task management set up with notes as tasks.
I asked whether a clickable Done button could update the Done
field, and thus remove the task from the list.
@asauceda94 helpfully suggested this could be done using MetaEdit and Dataview JS. I was able to get partway to the conversion. But I wonder if any JS experts could help finish the job, thanks in advance.
convert from standard dataview table
TABLE WITHOUT ID
file.link as File_________________________________,
do-date as "Do_Date",
Priority as Priority________,
due-date as "Due_Date",
recur-length as "Recur Length",
do-date + default(recur-length, "") as "Next_Date",
project as Project______,
FROM #✅/S/1_Active and !"⚙️ System"
WHERE done = null,
do-date < date(tomorrow)
SORT priority asc, do-date asc, file.mtime desc
to DataviewJS table
const {update} = this.app.plugins.plugins["metaedit"].api;
const buttonMaker = (pn, pv, fpath) => {
const btn = this.container.createEl('button', {"text": "Done"});
const file = this.app.vault.getAbstractFileByPath(fpath)
btn.addEventListener('click', async (evt) => {
evt.preventDefault();
await update(pn, pv, file);
});
return btn;
}
dv.table([
"Done",
"File_________________________________",
"Do_Date",
"Priority",
"Due_Date",
"Recur Length",
"Next_Date",
"Project______",
],
dv.pages("#✅/S/1_Active")
.sort(t => t["priority"], 'asc')
.sort(t => t["do-date"], 'asc')
.where(t => !t.done)
.map(t =>
[buttonMaker('Done', 'Done', t.file.path),
t.file.link,
t["do-date"],
t.priority,
t["due-date"],
t["recur-length"],
t["NEXT DATE QUERY"],
t["project"],
])
)
- Remaining tasks in converting to JS
-
WHERE command -==> ==Solved==done = null
(where done field is empty).where(t => !t.done)
- WHERE command -
WHERE do-date < date(tomorrow)
(where do-date is today or before) - FROM command - Exclude files from
System Folder
- Next Date table query -
do-date + default(recur-length, "") as "Next_Date",
- JS script - Make the ButtonMaker add the current date - possibly using this script
await update('completed-date', DateTime.local().toISODate(), file);
-