From 0726872b8e043c19883d26492ce42d3411505179 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 27 Jan 2022 19:15:37 -0800 Subject: [PATCH] Undo tag --- vopamoi.ts | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/vopamoi.ts b/vopamoi.ts index 366edd6..c17a2f0 100644 --- a/vopamoi.ts +++ b/vopamoi.ts @@ -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 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) { -- 2.44.1