X-Git-Url: http://git.scottworley.com/vopamoi/blobdiff_plain/a6268469ffa825e27c6ade6e38772ca307c52742..b5ac5cc3c1a2da8491c220c43183e1a35cb8bc54:/vopamoi.ts?ds=sidebyside 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")}`; }, };