]> git.scottworley.com Git - vopamoi/blobdiff - vopamoi.ts
Show dates on non-todo-state tasks
[vopamoi] / vopamoi.ts
index 5b1ce6be2639af395b3daa7ac61a2dd2059cc413..64799cfbdfa1cb06785d03164f5389d0df7acb4d 100644 (file)
@@ -144,9 +144,20 @@ const Model = {
 
   setState: function (stateTimestamp: string, createTimestamp: string, state: string) {
     const task = this.getTask(createTimestamp);
 
   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")}`;
   },
 };
 
   },
 };