Allow to select full object and object id in filters (#14083)
Today WorkflowVariablesDropdownAllItems is used for variable picker in all workflow steps, and for step field picker in filters. Using that component in filters prevent us from knowing if a full record or only the id has been selected. This PR: - creates a new component WorkflowDropdownStepOutputItems, mostly copying the logic of WorkflowVariablesDropdownAllItems - call it WorkflowStepFilterFieldSelect, removing the display logic from that parent component - store isFullRecord in filter. So we now know if we should display a record picker or a uuid picker Before - selecting id makes picker behaves like when we select an object https://github.com/user-attachments/assets/bde34dc5-8011-4983-8d0f-d8cb0cb3c045 After - selecting object and id are two different things https://github.com/user-attachments/assets/49289990-3e6d-4ad7-abc1-e3ade2a821bb
This commit is contained in:
-2
@@ -37,10 +37,8 @@ export type FieldOutputSchema =
|
||||
|
||||
export type RecordOutputSchema = {
|
||||
object: {
|
||||
nameSingular: string;
|
||||
fieldIdName: string;
|
||||
objectMetadataId: string;
|
||||
isRelationField?: boolean;
|
||||
} & Leaf;
|
||||
fields: Record<string, FieldOutputSchema>;
|
||||
_outputSchemaType: 'RECORD';
|
||||
|
||||
-1
@@ -116,7 +116,6 @@ describe('generateFakeFormResponse', () => {
|
||||
icon: 'test-company-icon',
|
||||
isLeaf: true,
|
||||
label: 'Company',
|
||||
nameSingular: 'company',
|
||||
objectMetadataId: '20202020-c03c-45d6-a4b0-04afe1357c5c',
|
||||
value: 'A company',
|
||||
},
|
||||
|
||||
-4
@@ -61,7 +61,6 @@ describe('generateFakeObjectRecordEvent', () => {
|
||||
icon: 'test-company-icon',
|
||||
label: 'Company',
|
||||
value: 'A company',
|
||||
nameSingular: 'company',
|
||||
fieldIdName: 'properties.after.id',
|
||||
objectMetadataId: '20202020-c03c-45d6-a4b0-04afe1357c5c',
|
||||
},
|
||||
@@ -93,7 +92,6 @@ describe('generateFakeObjectRecordEvent', () => {
|
||||
icon: 'test-company-icon',
|
||||
label: 'Company',
|
||||
value: 'A company',
|
||||
nameSingular: 'company',
|
||||
fieldIdName: 'properties.after.id',
|
||||
objectMetadataId: '20202020-c03c-45d6-a4b0-04afe1357c5c',
|
||||
},
|
||||
@@ -125,7 +123,6 @@ describe('generateFakeObjectRecordEvent', () => {
|
||||
icon: 'test-company-icon',
|
||||
label: 'Company',
|
||||
value: 'A company',
|
||||
nameSingular: 'company',
|
||||
fieldIdName: 'properties.before.id',
|
||||
objectMetadataId: '20202020-c03c-45d6-a4b0-04afe1357c5c',
|
||||
},
|
||||
@@ -157,7 +154,6 @@ describe('generateFakeObjectRecordEvent', () => {
|
||||
icon: 'test-company-icon',
|
||||
label: 'Company',
|
||||
value: 'A company',
|
||||
nameSingular: 'company',
|
||||
fieldIdName: 'properties.before.id',
|
||||
objectMetadataId: '20202020-c03c-45d6-a4b0-04afe1357c5c',
|
||||
},
|
||||
|
||||
-1
@@ -41,7 +41,6 @@ describe('generateFakeObjectRecord', () => {
|
||||
icon: 'test-company-icon',
|
||||
label: 'Company',
|
||||
value: 'A company',
|
||||
nameSingular: 'company',
|
||||
fieldIdName: 'id',
|
||||
objectMetadataId: '20202020-c03c-45d6-a4b0-04afe1357c5c',
|
||||
},
|
||||
|
||||
-2
@@ -30,8 +30,6 @@ const generateFakeObjectRecordEventWithPrefix = ({
|
||||
objectMetadataInfo.objectMetadataItemWithFieldsMaps.icon ?? undefined,
|
||||
label: objectMetadataInfo.objectMetadataItemWithFieldsMaps.labelSingular,
|
||||
value: objectMetadataInfo.objectMetadataItemWithFieldsMaps.description,
|
||||
nameSingular:
|
||||
objectMetadataInfo.objectMetadataItemWithFieldsMaps.nameSingular,
|
||||
fieldIdName: `${prefix}.id`,
|
||||
objectMetadataId: objectMetadataInfo.objectMetadataItemWithFieldsMaps.id,
|
||||
},
|
||||
|
||||
-5
@@ -5,11 +5,9 @@ import { generateObjectRecordFields } from 'src/modules/workflow/workflow-builde
|
||||
export const generateFakeObjectRecord = ({
|
||||
objectMetadataInfo,
|
||||
depth = 0,
|
||||
isRelationField,
|
||||
}: {
|
||||
objectMetadataInfo: ObjectMetadataInfo;
|
||||
depth?: number;
|
||||
isRelationField?: boolean;
|
||||
}): RecordOutputSchema => {
|
||||
return {
|
||||
object: {
|
||||
@@ -18,11 +16,8 @@ export const generateFakeObjectRecord = ({
|
||||
objectMetadataInfo.objectMetadataItemWithFieldsMaps.icon ?? undefined,
|
||||
label: objectMetadataInfo.objectMetadataItemWithFieldsMaps.labelSingular,
|
||||
value: objectMetadataInfo.objectMetadataItemWithFieldsMaps.description,
|
||||
nameSingular:
|
||||
objectMetadataInfo.objectMetadataItemWithFieldsMaps.nameSingular,
|
||||
fieldIdName: 'id',
|
||||
objectMetadataId: objectMetadataInfo.objectMetadataItemWithFieldsMaps.id,
|
||||
isRelationField,
|
||||
},
|
||||
fields: generateObjectRecordFields({
|
||||
objectMetadataInfo,
|
||||
|
||||
-1
@@ -60,7 +60,6 @@ export const generateObjectRecordFields = ({
|
||||
objectMetadataMaps: objectMetadataInfo.objectMetadataMaps,
|
||||
},
|
||||
depth: depth + 1,
|
||||
isRelationField: true,
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
-42
@@ -21,10 +21,8 @@ describe('evaluateFilterConditions', () => {
|
||||
): ResolvedFilter => ({
|
||||
id: 'filter1',
|
||||
type: type,
|
||||
label: 'Test Filter',
|
||||
rightOperand,
|
||||
operand,
|
||||
displayValue: String(rightOperand),
|
||||
stepFilterGroupId: 'group1',
|
||||
leftOperand,
|
||||
});
|
||||
@@ -784,10 +782,8 @@ describe('evaluateFilterConditions', () => {
|
||||
const filter: ResolvedFilter = {
|
||||
id: 'filter1',
|
||||
type: 'CURRENCY',
|
||||
label: 'Currency Filter',
|
||||
rightOperand: 'USD',
|
||||
operand: ViewFilterOperand.Is,
|
||||
displayValue: 'USD',
|
||||
stepFilterGroupId: 'group1',
|
||||
leftOperand: 'USD',
|
||||
compositeFieldSubFieldName: 'currencyCode',
|
||||
@@ -800,10 +796,8 @@ describe('evaluateFilterConditions', () => {
|
||||
const filter: ResolvedFilter = {
|
||||
id: 'filter1',
|
||||
type: 'CURRENCY',
|
||||
label: 'Currency Filter',
|
||||
rightOperand: 100,
|
||||
operand: ViewFilterOperand.GreaterThanOrEqual,
|
||||
displayValue: '100',
|
||||
stepFilterGroupId: 'group1',
|
||||
leftOperand: 150,
|
||||
compositeFieldSubFieldName: 'amountMicros',
|
||||
@@ -1215,20 +1209,16 @@ describe('evaluateFilterConditions', () => {
|
||||
{
|
||||
id: 'filter1',
|
||||
type: 'RELATION',
|
||||
label: 'Name Filter',
|
||||
rightOperand: 'John',
|
||||
operand: ViewFilterOperand.Is,
|
||||
displayValue: 'John',
|
||||
stepFilterGroupId: 'group1',
|
||||
leftOperand: 'John',
|
||||
},
|
||||
{
|
||||
id: 'filter2',
|
||||
type: 'NUMBER',
|
||||
label: 'Age Filter',
|
||||
rightOperand: 25,
|
||||
operand: ViewFilterOperand.GreaterThanOrEqual,
|
||||
displayValue: '25',
|
||||
stepFilterGroupId: 'group1',
|
||||
leftOperand: 30,
|
||||
},
|
||||
@@ -1244,20 +1234,16 @@ describe('evaluateFilterConditions', () => {
|
||||
{
|
||||
id: 'filter1',
|
||||
type: 'RELATION',
|
||||
label: 'Name Filter',
|
||||
rightOperand: 'John',
|
||||
operand: ViewFilterOperand.Is,
|
||||
displayValue: 'John',
|
||||
stepFilterGroupId: 'group1',
|
||||
leftOperand: 'John',
|
||||
},
|
||||
{
|
||||
id: 'filter2',
|
||||
type: 'NUMBER',
|
||||
label: 'Age Filter',
|
||||
rightOperand: 25,
|
||||
operand: ViewFilterOperand.GreaterThanOrEqual,
|
||||
displayValue: '25',
|
||||
stepFilterGroupId: 'group1',
|
||||
leftOperand: 20, // This will fail
|
||||
},
|
||||
@@ -1283,20 +1269,16 @@ describe('evaluateFilterConditions', () => {
|
||||
{
|
||||
id: 'filter1',
|
||||
type: 'RELATION',
|
||||
label: 'Name Filter',
|
||||
rightOperand: 'John',
|
||||
operand: ViewFilterOperand.Is,
|
||||
displayValue: 'John',
|
||||
stepFilterGroupId: 'group1',
|
||||
leftOperand: 'John',
|
||||
},
|
||||
{
|
||||
id: 'filter2',
|
||||
type: 'NUMBER',
|
||||
label: 'Age Filter',
|
||||
rightOperand: 25,
|
||||
operand: ViewFilterOperand.GreaterThanOrEqual,
|
||||
displayValue: '25',
|
||||
stepFilterGroupId: 'group1',
|
||||
leftOperand: 30,
|
||||
},
|
||||
@@ -1319,20 +1301,16 @@ describe('evaluateFilterConditions', () => {
|
||||
{
|
||||
id: 'filter1',
|
||||
type: 'RELATION',
|
||||
label: 'Name Filter',
|
||||
rightOperand: 'John',
|
||||
operand: ViewFilterOperand.Is,
|
||||
displayValue: 'John',
|
||||
stepFilterGroupId: 'group1',
|
||||
leftOperand: 'Jane', // This will fail
|
||||
},
|
||||
{
|
||||
id: 'filter2',
|
||||
type: 'NUMBER',
|
||||
label: 'Age Filter',
|
||||
rightOperand: 25,
|
||||
operand: ViewFilterOperand.GreaterThanOrEqual,
|
||||
displayValue: '25',
|
||||
stepFilterGroupId: 'group1',
|
||||
leftOperand: 30,
|
||||
},
|
||||
@@ -1357,20 +1335,16 @@ describe('evaluateFilterConditions', () => {
|
||||
{
|
||||
id: 'filter1',
|
||||
type: 'RELATION',
|
||||
label: 'Name Filter',
|
||||
rightOperand: 'John',
|
||||
operand: ViewFilterOperand.Is,
|
||||
displayValue: 'John',
|
||||
stepFilterGroupId: 'group1',
|
||||
leftOperand: 'Jane', // This will fail
|
||||
},
|
||||
{
|
||||
id: 'filter2',
|
||||
type: 'NUMBER',
|
||||
label: 'Age Filter',
|
||||
rightOperand: 25,
|
||||
operand: ViewFilterOperand.GreaterThanOrEqual,
|
||||
displayValue: '25',
|
||||
stepFilterGroupId: 'group1',
|
||||
leftOperand: 30, // This will pass
|
||||
},
|
||||
@@ -1393,20 +1367,16 @@ describe('evaluateFilterConditions', () => {
|
||||
{
|
||||
id: 'filter1',
|
||||
type: 'RELATION',
|
||||
label: 'Name Filter',
|
||||
rightOperand: 'John',
|
||||
operand: ViewFilterOperand.Is,
|
||||
displayValue: 'John',
|
||||
stepFilterGroupId: 'group1',
|
||||
leftOperand: 'Jane', // This will fail
|
||||
},
|
||||
{
|
||||
id: 'filter2',
|
||||
type: 'NUMBER',
|
||||
label: 'Age Filter',
|
||||
rightOperand: 25,
|
||||
operand: ViewFilterOperand.GreaterThanOrEqual,
|
||||
displayValue: '25',
|
||||
stepFilterGroupId: 'group1',
|
||||
leftOperand: 20, // This will fail
|
||||
},
|
||||
@@ -1435,20 +1405,16 @@ describe('evaluateFilterConditions', () => {
|
||||
{
|
||||
id: 'filter1',
|
||||
type: 'RELATION',
|
||||
label: 'Name Filter',
|
||||
rightOperand: 'John',
|
||||
operand: ViewFilterOperand.Is,
|
||||
displayValue: 'John',
|
||||
stepFilterGroupId: 'group1',
|
||||
leftOperand: 'John',
|
||||
},
|
||||
{
|
||||
id: 'filter2',
|
||||
type: 'NUMBER',
|
||||
label: 'Age Filter',
|
||||
rightOperand: 25,
|
||||
operand: ViewFilterOperand.GreaterThanOrEqual,
|
||||
displayValue: '25',
|
||||
stepFilterGroupId: 'group2',
|
||||
leftOperand: 30,
|
||||
},
|
||||
@@ -1485,30 +1451,24 @@ describe('evaluateFilterConditions', () => {
|
||||
{
|
||||
id: 'filter1',
|
||||
type: 'RELATION',
|
||||
label: 'Filter 1',
|
||||
rightOperand: 'John',
|
||||
operand: ViewFilterOperand.Is,
|
||||
displayValue: 'John',
|
||||
stepFilterGroupId: 'child1',
|
||||
leftOperand: 'Jane', // This will fail
|
||||
},
|
||||
{
|
||||
id: 'filter2',
|
||||
type: 'RELATION',
|
||||
label: 'Filter 2',
|
||||
rightOperand: 'Smith',
|
||||
operand: ViewFilterOperand.Is,
|
||||
displayValue: 'Smith',
|
||||
stepFilterGroupId: 'child1',
|
||||
leftOperand: 'Smith', // This will pass (OR group passes)
|
||||
},
|
||||
{
|
||||
id: 'filter3',
|
||||
type: 'NUMBER',
|
||||
label: 'Filter 3',
|
||||
rightOperand: 25,
|
||||
operand: ViewFilterOperand.GreaterThanOrEqual,
|
||||
displayValue: '25',
|
||||
stepFilterGroupId: 'child2',
|
||||
leftOperand: 30, // This will pass (AND group passes)
|
||||
},
|
||||
@@ -1548,10 +1508,8 @@ describe('evaluateFilterConditions', () => {
|
||||
{
|
||||
id: 'filter1',
|
||||
type: 'RELATION',
|
||||
label: 'Name Filter',
|
||||
rightOperand: 'John',
|
||||
operand: ViewFilterOperand.Is,
|
||||
displayValue: 'John',
|
||||
stepFilterGroupId: 'nonexistent',
|
||||
leftOperand: 'John',
|
||||
},
|
||||
|
||||
-1
@@ -49,7 +49,6 @@ const settings: WorkflowFormActionSettings = {
|
||||
value: 'A company',
|
||||
isLeaf: true,
|
||||
fieldIdName: 'id',
|
||||
nameSingular: 'company',
|
||||
objectMetadataId: '123e4567-e89b-12d3-a456-426614174000',
|
||||
},
|
||||
_outputSchemaType: 'RECORD',
|
||||
|
||||
Reference in New Issue
Block a user