diff --git a/src/lib/components/workflow/filter-search/conditional-menu.svelte b/src/lib/components/workflow/filter-search/conditional-menu.svelte index 5e5561ca4..1c52f7b67 100644 --- a/src/lib/components/workflow/filter-search/conditional-menu.svelte +++ b/src/lib/components/workflow/filter-search/conditional-menu.svelte @@ -24,25 +24,36 @@ defaultConditionOptions; export let disabled = false; export let inputId: string; + export let noBorderLeft = false; + export let noBorderRight = false; - $: options, ($filter.conditional = options[0].value); - - $: selectedOption = - options.find((o) => o.value === $filter.conditional) ?? options[0]; + $: filterConditionalOption = options.find( + (o) => o.value === $filter.conditional, + ); + $: options, updateFilterConditional(); + $: selectedOption = filterConditionalOption ?? options[0]; $: selectedLabel = selectedOption?.label ?? selectedOption?.value; + + function updateFilterConditional() { + if (!filterConditionalOption) { + $filter.conditional = options[0].value; + } + } {selectedLabel} - + {#each options as { value, label }} { diff --git a/src/lib/components/workflow/filter-search/datetime-filter.svelte b/src/lib/components/workflow/filter-search/datetime-filter.svelte index 6593dea08..605e8085f 100644 --- a/src/lib/components/workflow/filter-search/datetime-filter.svelte +++ b/src/lib/components/workflow/filter-search/datetime-filter.svelte @@ -126,6 +126,8 @@ { value: 'BETWEEN', label: translate('between') }, { value: '>=', label: translate('after') }, ]} + noBorderLeft + noBorderRight />
- + (FILTER_CONTEXT); - function getFocusedElementId(attribute: string) { - if (isStatusFilter(attribute)) return 'status-filter'; - - if (isTextFilter(attribute)) return 'text-filter-search'; - - if (isListFilter(attribute)) return 'list-filter-search'; - - if (isNumberFilter(attribute) || isDateTimeFilter(attribute)) - return 'conditional-menu-button'; - - if (isBooleanFilter(attribute)) return 'boolean-filter'; - - return ''; - } - function isOptionDisabled(value: string, filters: WorkflowFilter[]) { return filters.some( - (filter) => filter.conditional === '=' && filter.attribute === value, + (filter) => + (filter.conditional === '=' || filter.conditional === '!=') && + filter.attribute === value, ); } diff --git a/src/lib/components/workflow/filter-search/text-filter.svelte b/src/lib/components/workflow/filter-search/text-filter.svelte index 1b914dc08..a83e1f9af 100644 --- a/src/lib/components/workflow/filter-search/text-filter.svelte +++ b/src/lib/components/workflow/filter-search/text-filter.svelte @@ -4,6 +4,7 @@ import Input from '$lib/holocene/input/input.svelte'; import { translate } from '$lib/i18n/translate'; + import ConditionalMenu from './conditional-menu.svelte'; import { FILTER_CONTEXT, type FilterContext } from './index.svelte'; const { filter, handleSubmit } = getContext(FILTER_CONTEXT); @@ -19,6 +20,14 @@ } +