From: Scott Worley Date: Thu, 10 Feb 2022 00:30:47 +0000 (-0800) Subject: Tag view X-Git-Url: http://git.scottworley.com/vopamoi/commitdiff_plain/312acaa82bc2f7d8c1d0aa435f606d3e87c42e54?ds=sidebyside;hp=58b569ce38e1d658d0cdfb31d53f2cad2d00e5bd Tag view --- diff --git a/vopamoi.css b/vopamoi.css index ac29e30..c98337c 100644 --- a/vopamoi.css +++ b/vopamoi.css @@ -15,6 +15,9 @@ input.tag { width: 7em; border: none; } +.hide { + display: none; +} .task { clear: right; } diff --git a/vopamoi.ts b/vopamoi.ts index 931505b..76c2d29 100644 --- a/vopamoi.ts +++ b/vopamoi.ts @@ -369,7 +369,11 @@ function BrowserUI() { firstVisibleTask: function () { for (const task of document.getElementsByClassName("task")) { const state = task.getAttribute("data-state"); - if (task instanceof HTMLElement && (state === currentViewState || (currentViewState === "all" && state !== "deleted"))) { + if ( + task instanceof HTMLElement && + (state === currentViewState || (currentViewState === "all" && state !== "deleted")) && + !task.classList.contains("hide") + ) { return task; } } @@ -392,7 +396,10 @@ function BrowserUI() { cursor = increment > 0 ? cursor.nextElementSibling : cursor.previousElementSibling; if (!cursor || !(cursor instanceof HTMLElement)) break; const state = cursor.getAttribute("data-state")!; - if (state === currentViewState || (currentViewState === "all" && state !== "deleted")) { + if ( + (state === currentViewState || (currentViewState === "all" && state !== "deleted")) && + !cursor.classList.contains("hide") + ) { offset -= increment; valid_cursor = cursor; } @@ -452,8 +459,15 @@ function BrowserUI() { ui.removeTag(target.parentElement!.getAttribute("data-created")!, target.textContent!); }, + resetTagView: function () { + for (const task of document.getElementsByClassName("task")) { + task.classList.remove("hide"); + } + }, + resetView: function () { this.setView("todo"); + this.resetTagView(); }, returnFocusAfterInput: function (): boolean { @@ -490,6 +504,19 @@ function BrowserUI() { return ui.setState(createTimestamp, newState, oldState); }, + setTagView: function () { + const target = this.currentTag(); + if (!target) return; + const tag = target.textContent!; + for (const task of document.getElementsByClassName("task")) { + if (Model.hasTag(task, tag)) { + task.classList.remove("hide"); + } else { + task.classList.add("hide"); + } + } + }, + setView: function (state: string) { const sheet = (document.getElementById("viewStyle") as HTMLStyleElement).sheet!; if (state === "all") { @@ -584,6 +611,8 @@ function handleKey(event: any) { if (event.key == "d") return browserUI.setView("done"); if (event.key == "q") return browserUI.setView("todo"); if (event.key == "s") return (inputState = InputState.VS); + if (event.key == "T") return browserUI.resetTagView(); + if (event.key == "t") return browserUI.setTagView(); if (event.key == "v") return browserUI.resetView(); if (event.key == "w") return browserUI.setView("waiting"); if (event.key == "x") return browserUI.setView("deleted");