From: Scott Worley Date: Fri, 28 Jan 2022 03:15:37 +0000 (-0800) Subject: Undo tag X-Git-Url: http://git.scottworley.com/vopamoi/commitdiff_plain/0726872b8e043c19883d26492ce42d3411505179?ds=inline Undo tag --- 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) {