From bf2ca4b475ecddc4227dec25297b3d4105c2aaaf Mon Sep 17 00:00:00 2001 From: Lance Edgar Date: Fri, 23 Aug 2024 14:38:02 -0500 Subject: [PATCH] fix: use autocomplete for grid filter verb choices --- src/wuttaweb/templates/base.mako | 5 +- src/wuttaweb/templates/wutta-components.mako | 95 ++++++++++++++++++-- 2 files changed, 88 insertions(+), 12 deletions(-) diff --git a/src/wuttaweb/templates/base.mako b/src/wuttaweb/templates/base.mako index c8557ca..a85bc2d 100644 --- a/src/wuttaweb/templates/base.mako +++ b/src/wuttaweb/templates/base.mako @@ -164,12 +164,9 @@ gap: 0.5rem; } - .wutta-filter .button.filter-toggle { - justify-content: left; - } - .wutta-filter .button.filter-toggle, .wutta-filter .filter-verb { + justify-content: left; min-width: 15rem; } diff --git a/src/wuttaweb/templates/wutta-components.mako b/src/wuttaweb/templates/wutta-components.mako index 3145c1f..888944e 100644 --- a/src/wuttaweb/templates/wutta-components.mako +++ b/src/wuttaweb/templates/wutta-components.mako @@ -88,16 +88,26 @@
- - - + {{ verbLabel }} + + + { + let label = option.label.toLowerCase() + for (let term of terms) { + if (label.indexOf(term) < 0) { + return false + } + } + return true + }) + + return options + }, + }, + methods: { focusValue() { this.$refs.filterValue.focus() }, + formatVerb(option) { + return option.label || option.verb + }, + + verbChoiceInit(option) { + this.verbKnown = false + this.$nextTick(() => { + this.$refs.verbAutocomplete.focus() + }) + }, + + verbChoiceSelect(option) { + this.filter.verb = option.verb + this.verbLabel = option.label + this.verbKnown = true + this.verbTerm = '' + this.focusValue() + }, + valuedVerb() { /* return true if the current verb should expose value input(s) */