From e6233f12436044886145e775d5498e167973024a Mon Sep 17 00:00:00 2001 From: Martha King Date: Thu, 21 Nov 2024 10:17:46 +0000 Subject: [PATCH] use equals when only one item is selcted in filter dropdown --- .../components/visualizations/tableVizToolbar.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/gui/src/project-view/components/visualizations/tableVizToolbar.ts b/app/gui/src/project-view/components/visualizations/tableVizToolbar.ts index 93982352ab..74e8d7a911 100644 --- a/app/gui/src/project-view/components/visualizations/tableVizToolbar.ts +++ b/app/gui/src/project-view/components/visualizations/tableVizToolbar.ts @@ -5,6 +5,7 @@ import { Ast } from '@/util/ast' import { Pattern } from '@/util/ast/match' import type { ToValue } from '@/util/reactivity' import { computed, type ComputedRef, type Ref, toValue } from 'vue' +import { Expression, MutableExpression } from 'ydoc-shared/ast' type SortDirection = 'asc' | 'desc' export type SortModel = { @@ -78,6 +79,16 @@ function useSortFilterNodesButton({ ]) } const valueFormatter = getColumnValueToEnso(columnName) + if (items?.length === 1) { + const item = items[0] + if (item) { + return filterPattern.value.instantiateCopied([ + Ast.TextLiteral.new(columnName), + Ast.parseExpression('..Equal')!, + valueFormatter(item, module) as Expression | MutableExpression, + ]) + } + } const itemList = items.map((i) => valueFormatter(i, module)) return filterPattern.value.instantiateCopied([ Ast.TextLiteral.new(columnName),