The open alternative to Salesforce, designed for AI.
TypeScript crmcrm-systemcustomergood-first-issuegraphqlhacktoberfestjavascriptmarketingmonoreponestjsopen-sourcepostgresqlreactreactjssalestypescriptweb
Use array fields in filter steps (#15256)
Thomas Trompettec04b3722b312
diff --git a/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/FormArrayFieldInput.tsx b/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/FormArrayFieldInput.tsxindex da85cd5f43a..724577eb5e4 100644--- a/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/FormArrayFieldInput.tsx+++ b/packages/twenty-front/src/modules/object-record/record-field/ui/form-types/components/FormArrayFieldInput.tsx@@ -25,6 +25,7 @@ import { isStandaloneVariableString } from '@/workflow/utils/isStandaloneVariablimport { useTheme } from '@emotion/react';import styled from '@emotion/styled';import { useLingui } from '@lingui/react/macro';+import { isNonEmptyArray } from '@sniptt/guards';import { useId, useRef, useState } from 'react';import { isDefined } from 'twenty-shared/utils';import { IconPlus } from 'twenty-ui/display';@@ -111,7 +112,10 @@ export const FormArrayFieldInput = ({}: {type: 'static',- value: isDefined(defaultValue) ? defaultValue : [],+ value:+ isDefined(defaultValue) && isNonEmptyArray(defaultValue)+ ? defaultValue+ : [],},);diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/filter-action/components/WorkflowStepFilterFieldSelect.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/filter-action/components/WorkflowStepFilterFieldSelect.tsxindex ad10e93ac56..629447bf5a0 100644--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/filter-action/components/WorkflowStepFilterFieldSelect.tsx+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/filter-action/components/WorkflowStepFilterFieldSelect.tsx@@ -25,7 +25,6 @@ type WorkflowStepFilterFieldSelectProps = {const NON_SELECTABLE_FIELD_TYPES = [FieldMetadataType.ACTOR,FieldMetadataType.RICH_TEXT_V2,- FieldMetadataType.ARRAY,FieldMetadataType.RATING,];diff --git a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/filter-action/components/WorkflowStepFilterValueInput.tsx b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/filter-action/components/WorkflowStepFilterValueInput.tsxindex 06d852d0ccf..3889d239b0c 100644--- a/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/filter-action/components/WorkflowStepFilterValueInput.tsx+++ b/packages/twenty-front/src/modules/workflow/workflow-steps/workflow-actions/filter-action/components/WorkflowStepFilterValueInput.tsx@@ -1,6 +1,7 @@import { useFieldMetadataItemById } from '@/object-metadata/hooks/useFieldMetadataItemById';import { configurableViewFilterOperands } from '@/object-record/object-filter-dropdown/utils/configurableViewFilterOperands';import { FormFieldInput } from '@/object-record/record-field/ui/components/FormFieldInput';+import { FormArrayFieldInput } from '@/object-record/record-field/ui/form-types/components/FormArrayFieldInput';import { FormMultiSelectFieldInput } from '@/object-record/record-field/ui/form-types/components/FormMultiSelectFieldInput';import { FormRelativeDatePicker } from '@/object-record/record-field/ui/form-types/components/FormRelativeDatePicker';import { FormSingleRecordPicker } from '@/object-record/record-field/ui/form-types/components/FormSingleRecordPicker';@@ -19,7 +20,7 @@ import {ViewFilterOperand,type StepFilter,} from 'twenty-shared/types';-import { isDefined } from 'twenty-shared/utils';+import { isDefined, parseJson } from 'twenty-shared/utils';import { type JsonValue } from 'type-fest';type WorkflowStepFilterValueInputProps = {@@ -173,6 +174,18 @@ export const WorkflowStepFilterValueInput = ({);}+ if (variableType === FieldMetadataType.ARRAY) {+ const arrayValue = parseJson<string[]>(stepFilter.value) ?? [];++ return (+ <FormArrayFieldInput+ defaultValue={arrayValue}+ onChange={handleValueChange}+ readonly={readonly}+ />+ );+ }+const field = {type: variableType as FieldMetadataType,label: '',