From 4a726416b8968656e3651ed437f966a329f4210e Mon Sep 17 00:00:00 2001 From: Laura Whitaker Date: Wed, 6 Nov 2024 09:44:10 -0700 Subject: [PATCH] Add KeywordList option to SearchAttributeInput --- .../schedule-search-attributes.svelte | 12 +++++-- .../workflow/add-search-attributes.svelte | 8 +++-- .../datetime-input.svelte | 2 +- .../search-attribute-input/index.svelte | 11 ++++--- .../search-attribute-input/list-input.svelte | 33 +++++++++++++++++++ .../number-input.svelte | 2 +- src/lib/services/workflow-service.ts | 4 +-- src/lib/stores/search-attributes.ts | 2 +- src/lib/utilities/encode-payload.ts | 2 +- 9 files changed, 61 insertions(+), 15 deletions(-) create mode 100644 src/lib/components/workflow/search-attribute-input/list-input.svelte diff --git a/src/lib/components/schedule/schedule-search-attributes.svelte b/src/lib/components/schedule/schedule-search-attributes.svelte index 7da235bf7..09945adbe 100644 --- a/src/lib/components/schedule/schedule-search-attributes.svelte +++ b/src/lib/components/schedule/schedule-search-attributes.svelte @@ -1,7 +1,7 @@ {#each Object.entries(indexedFields) as [searchAttrName, searchAttrValue]} + {@const value = formatValue(searchAttrValue)}
  • {searchAttrName} {searchAttrValue}{value}
  • {/each} diff --git a/src/lib/components/workflow/add-search-attributes.svelte b/src/lib/components/workflow/add-search-attributes.svelte index ade23869d..8ec0ef6c5 100644 --- a/src/lib/components/workflow/add-search-attributes.svelte +++ b/src/lib/components/workflow/add-search-attributes.svelte @@ -33,7 +33,11 @@ on:click={addSearchAttribute} disabled={!searchAttributes.length || attributesToAdd.length === searchAttributes.length || - attributesToAdd.filter((a) => a.value === '' || a.value === null).length > - 0}>{translate('workflows.add-search-attribute')} + a.value === '' || + a.value === null || + (Array.isArray(a.value) && a.value.length === 0), + ).length > 0}>{translate('workflows.add-search-attribute')} diff --git a/src/lib/components/workflow/search-attribute-input/datetime-input.svelte b/src/lib/components/workflow/search-attribute-input/datetime-input.svelte index aea2f578c..517fa6da9 100644 --- a/src/lib/components/workflow/search-attribute-input/datetime-input.svelte +++ b/src/lib/components/workflow/search-attribute-input/datetime-input.svelte @@ -16,7 +16,7 @@ let second = ''; onMount(() => { - if (value) { + if (value && (typeof value === 'string' || typeof value === 'number')) { const datetime = new Date(value); const utcDate = new Date( datetime.getUTCFullYear(), diff --git a/src/lib/components/workflow/search-attribute-input/index.svelte b/src/lib/components/workflow/search-attribute-input/index.svelte index b4aa9752d..647381d93 100644 --- a/src/lib/components/workflow/search-attribute-input/index.svelte +++ b/src/lib/components/workflow/search-attribute-input/index.svelte @@ -13,6 +13,7 @@ } from '$lib/types/workflows'; import DatetimeInput from './datetime-input.svelte'; + import ListInput from './list-input.svelte'; import NumberInput from './number-input.svelte'; import TextInput from './text-input.svelte'; @@ -22,9 +23,9 @@ export let onRemove: (attribute: string) => void; $: type = searchAttributes[attribute.attribute]; - $: searchAttributesOptions = [...Object.entries(searchAttributes)] - .map(([key, value]) => ({ label: key, value: key, type: value })) - .filter(({ type }) => type !== 'KeywordList'); + $: searchAttributesOptions = [...Object.entries(searchAttributes)].map( + ([key, value]) => ({ label: key, value: key, type: value }), + ); $: isDisabled = (value: string) => { return !!attributesToAdd.find((a) => a.attribute === value); @@ -37,7 +38,7 @@ }; -
    +