From: Scott Worley Date: Fri, 28 Jan 2022 06:54:22 +0000 (-0800) Subject: Show dates on non-todo-state tasks X-Git-Url: http://git.scottworley.com/vopamoi/commitdiff_plain/b5ac5cc3c1a2da8491c220c43183e1a35cb8bc54?hp=a6268469ffa825e27c6ade6e38772ca307c52742 Show dates on non-todo-state tasks Eg, this is the completion date for completed tasks, etc. --- diff --git a/vopamoi.css b/vopamoi.css index 31d439d..68d4773 100644 --- a/vopamoi.css +++ b/vopamoi.css @@ -18,6 +18,9 @@ input.tag { .task { clear: right; } +.statedate { + margin-right: 0.5em; +} #ui { padding: 15px 10px; } diff --git a/vopamoi.ts b/vopamoi.ts index 5b1ce6b..64799cf 100644 --- a/vopamoi.ts +++ b/vopamoi.ts @@ -144,9 +144,20 @@ const Model = { setState: function (stateTimestamp: string, createTimestamp: string, state: string) { const task = this.getTask(createTimestamp); - if (task) { - task.setAttribute("data-state", state); + if (!task) return; + task.setAttribute("data-state", state); + var date = task.getElementsByClassName("statedate")[0]; + if (state === "todo") { + task.removeChild(date); + return; } + if (!date) { + date = document.createElement("span"); + date.classList.add("statedate"); + task.insertBefore(date, task.firstChild); + } + const d = new Date(parseInt(stateTimestamp)); + date.textContent = `${d.getFullYear()}-${`${d.getMonth() + 1}`.padStart(2, "0")}-${`${d.getDate()}`.padStart(2, "0")}`; }, };