]> git.scottworley.com Git - vopamoi/commitdiff
Undo tag
authorScott Worley <scottworley@scottworley.com>
Fri, 28 Jan 2022 03:15:37 +0000 (19:15 -0800)
committerScott Worley <scottworley@scottworley.com>
Fri, 28 Jan 2022 03:15:37 +0000 (19:15 -0800)
vopamoi.ts

index 366edd6c3fc6803f0e4de311184d36f5d67d7e39..c17a2f00139a51ad44af27269f6ade1e1f80519c 100644 (file)
@@ -119,6 +119,14 @@ const Model = {
     }
   },
 
+  removeTag: function (createTimestamp: string, tagName: string) {
+    const task = this.getTask(createTimestamp);
+    if (!task) return null;
+    const tag = this.hasTag(task, tagName);
+    if (!tag) return;
+    task.removeChild(tag);
+  },
+
   setPriority: function (createTimestamp: string, priority: number): Element | null {
     const target = this.getTask(createTimestamp);
     if (!target) return null;
@@ -165,6 +173,10 @@ function Log(prefix: string = "vp-") {
         const [createTimestamp, tag] = splitN(data, " ", 1);
         return Model.addTag(createTimestamp, tag);
       }
+      if (command == "Untag") {
+        const [createTimestamp, tag] = splitN(data, " ", 1);
+        return Model.removeTag(createTimestamp, tag);
+      }
     },
 
     record: function (entry: string) {
@@ -199,7 +211,7 @@ function UI() {
       return <Element>log.recordAndApply(`${now} Create ${description}`);
     },
     addTag: function (createTimestamp: string, tag: string) {
-      // TODO: undo
+      undoLog.push(`Untag ${createTimestamp} ${tag}`);
       return log.recordAndApply(`${clock.now()} Tag ${createTimestamp} ${tag}`);
     },
     edit: function (createTimestamp: string, newDescription: string, oldDescription: string) {