Refacto filter action + handle missing composite fields (#13557)
- handle missing composite fields - refacto filter action to be more reliable Remaining improvements: - filter out some field types - improve relations
This commit is contained in:
+5
@@ -5,6 +5,7 @@ import { useWorkflowStepContextOrThrow } from '@/workflow/states/context/Workflo
|
||||
import { stepsOutputSchemaFamilySelector } from '@/workflow/states/selectors/stepsOutputSchemaFamilySelector';
|
||||
import { useUpsertStepFilterSettings } from '@/workflow/workflow-steps/workflow-actions/filter-action/hooks/useUpsertStepFilterSettings';
|
||||
import { WorkflowStepFilterContext } from '@/workflow/workflow-steps/workflow-actions/filter-action/states/context/WorkflowStepFilterContext';
|
||||
import { getViewFilterOperands } from '@/workflow/workflow-steps/workflow-actions/filter-action/utils/getStepFilterOperands';
|
||||
import { WorkflowVariablesDropdown } from '@/workflow/workflow-variables/components/WorkflowVariablesDropdown';
|
||||
import { useAvailableVariablesInWorkflowStep } from '@/workflow/workflow-variables/hooks/useAvailableVariablesInWorkflowStep';
|
||||
import { extractRawVariableNamePart } from '@/workflow/workflow-variables/utils/extractRawVariableNamePart';
|
||||
@@ -89,6 +90,10 @@ export const WorkflowStepFilterFieldSelect = ({
|
||||
value: '',
|
||||
fieldMetadataId,
|
||||
compositeFieldSubFieldName,
|
||||
operand: getViewFilterOperands({
|
||||
filterType,
|
||||
subFieldName: compositeFieldSubFieldName,
|
||||
})?.[0],
|
||||
},
|
||||
});
|
||||
},
|
||||
|
||||
+4
-1
@@ -18,7 +18,10 @@ export const WorkflowStepFilterOperandSelect = ({
|
||||
const { readonly } = useContext(WorkflowStepFilterContext);
|
||||
|
||||
const { upsertStepFilterSettings } = useUpsertStepFilterSettings();
|
||||
const operands = getViewFilterOperands({ filterType: stepFilter.type });
|
||||
const operands = getViewFilterOperands({
|
||||
filterType: stepFilter.type,
|
||||
subFieldName: stepFilter.compositeFieldSubFieldName,
|
||||
});
|
||||
|
||||
const options = operands.map((operand) => ({
|
||||
value: operand,
|
||||
|
||||
+32
-1
@@ -76,14 +76,45 @@ export const FILTER_OPERANDS_MAP = {
|
||||
],
|
||||
};
|
||||
|
||||
export const COMPOSITE_FIELD_FILTER_OPERANDS_MAP = {
|
||||
CURRENCY: {
|
||||
currencyCode: [
|
||||
ViewFilterOperand.Is,
|
||||
ViewFilterOperand.IsNot,
|
||||
...emptyOperands,
|
||||
],
|
||||
amountMicros: [
|
||||
ViewFilterOperand.GreaterThanOrEqual,
|
||||
ViewFilterOperand.LessThanOrEqual,
|
||||
ViewFilterOperand.Is,
|
||||
ViewFilterOperand.IsNot,
|
||||
...emptyOperands,
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
export const getViewFilterOperands = ({
|
||||
filterType,
|
||||
subFieldName,
|
||||
}: {
|
||||
filterType: string;
|
||||
filterType: string | undefined;
|
||||
subFieldName: string | undefined;
|
||||
}): readonly ViewFilterOperand[] => {
|
||||
switch (filterType) {
|
||||
case 'TEXT':
|
||||
case 'EMAILS':
|
||||
case 'FULL_NAME':
|
||||
case 'ADDRESS':
|
||||
case 'LINKS':
|
||||
case 'PHONES':
|
||||
return FILTER_OPERANDS_MAP.TEXT;
|
||||
case 'CURRENCY': {
|
||||
if (subFieldName === 'currencyCode') {
|
||||
return COMPOSITE_FIELD_FILTER_OPERANDS_MAP.CURRENCY.currencyCode;
|
||||
} else {
|
||||
return COMPOSITE_FIELD_FILTER_OPERANDS_MAP.CURRENCY.amountMicros;
|
||||
}
|
||||
}
|
||||
case 'NUMBER':
|
||||
return FILTER_OPERANDS_MAP.NUMBER;
|
||||
case 'RAW_JSON':
|
||||
|
||||
Reference in New Issue
Block a user