Handle relations for filters (#13654)
- Refacto variable dropdown so it can display both objects and fields - we do not filter on object name anymore to simplify the code - add relation handler in filters https://github.com/user-attachments/assets/e4f03f11-45cb-4d3f-b628-e996129dd996
This commit is contained in:
+1
@@ -40,6 +40,7 @@ export type RecordOutputSchema = {
|
||||
nameSingular: string;
|
||||
fieldIdName: string;
|
||||
objectMetadataId: string;
|
||||
isRelationField?: boolean;
|
||||
} & Leaf;
|
||||
fields: Record<string, FieldOutputSchema>;
|
||||
_outputSchemaType: 'RECORD';
|
||||
|
||||
+73
-81
@@ -56,92 +56,84 @@ describe('generateFakeFormResponse', () => {
|
||||
objectMetadataMaps: mockObjectMetadataMaps,
|
||||
});
|
||||
|
||||
expect(result).toMatchInlineSnapshot(`
|
||||
{
|
||||
"age": {
|
||||
"fieldMetadataId": undefined,
|
||||
"icon": undefined,
|
||||
"isLeaf": true,
|
||||
"label": "Age",
|
||||
"type": "NUMBER",
|
||||
"value": 20,
|
||||
},
|
||||
"company": {
|
||||
"isLeaf": false,
|
||||
"label": "Company",
|
||||
"value": {
|
||||
"_outputSchemaType": "RECORD",
|
||||
"fields": {
|
||||
"domainName": {
|
||||
"fieldMetadataId": "domainNameFieldMetadataId",
|
||||
"icon": "test-field-icon",
|
||||
"isLeaf": false,
|
||||
"label": "Domain Name",
|
||||
"type": "LINKS",
|
||||
"value": {
|
||||
"primaryLinkLabel": {
|
||||
"fieldMetadataId": "domainNameFieldMetadataId",
|
||||
"isCompositeSubField": true,
|
||||
"isLeaf": true,
|
||||
"label": "Primary Link Label",
|
||||
"type": "TEXT",
|
||||
"value": "My text",
|
||||
expect(result).toEqual({
|
||||
age: {
|
||||
isLeaf: true,
|
||||
label: 'Age',
|
||||
type: 'NUMBER',
|
||||
value: 20,
|
||||
},
|
||||
company: {
|
||||
isLeaf: false,
|
||||
label: 'Company',
|
||||
value: {
|
||||
_outputSchemaType: 'RECORD',
|
||||
fields: {
|
||||
domainName: {
|
||||
fieldMetadataId: 'domainNameFieldMetadataId',
|
||||
icon: 'test-field-icon',
|
||||
isLeaf: false,
|
||||
label: 'Domain Name',
|
||||
type: 'LINKS',
|
||||
value: {
|
||||
primaryLinkLabel: {
|
||||
fieldMetadataId: 'domainNameFieldMetadataId',
|
||||
isCompositeSubField: true,
|
||||
isLeaf: true,
|
||||
label: 'Primary Link Label',
|
||||
type: 'TEXT',
|
||||
value: 'My text',
|
||||
},
|
||||
primaryLinkUrl: {
|
||||
fieldMetadataId: 'domainNameFieldMetadataId',
|
||||
isCompositeSubField: true,
|
||||
isLeaf: true,
|
||||
label: 'Primary Link Url',
|
||||
type: 'TEXT',
|
||||
value: 'My text',
|
||||
},
|
||||
secondaryLinks: {
|
||||
fieldMetadataId: 'domainNameFieldMetadataId',
|
||||
isCompositeSubField: true,
|
||||
isLeaf: true,
|
||||
label: 'Secondary Links',
|
||||
type: 'RAW_JSON',
|
||||
value: null,
|
||||
},
|
||||
},
|
||||
},
|
||||
"primaryLinkUrl": {
|
||||
"fieldMetadataId": "domainNameFieldMetadataId",
|
||||
"isCompositeSubField": true,
|
||||
"isLeaf": true,
|
||||
"label": "Primary Link Url",
|
||||
"type": "TEXT",
|
||||
"value": "My text",
|
||||
},
|
||||
"secondaryLinks": {
|
||||
"fieldMetadataId": "domainNameFieldMetadataId",
|
||||
"isCompositeSubField": true,
|
||||
"isLeaf": true,
|
||||
"label": "Secondary Links",
|
||||
"type": "RAW_JSON",
|
||||
"value": null,
|
||||
name: {
|
||||
fieldMetadataId: 'nameFieldMetadataId',
|
||||
icon: 'test-field-icon',
|
||||
isLeaf: true,
|
||||
label: 'Name',
|
||||
type: 'TEXT',
|
||||
value: 'My text',
|
||||
},
|
||||
},
|
||||
},
|
||||
"name": {
|
||||
"fieldMetadataId": "nameFieldMetadataId",
|
||||
"icon": "test-field-icon",
|
||||
"isLeaf": true,
|
||||
"label": "Name",
|
||||
"type": "TEXT",
|
||||
"value": "My text",
|
||||
object: {
|
||||
fieldIdName: 'id',
|
||||
icon: 'test-company-icon',
|
||||
isLeaf: true,
|
||||
label: 'Company',
|
||||
nameSingular: 'company',
|
||||
objectMetadataId: '20202020-c03c-45d6-a4b0-04afe1357c5c',
|
||||
value: 'A company',
|
||||
},
|
||||
},
|
||||
},
|
||||
"object": {
|
||||
"fieldIdName": "id",
|
||||
"icon": "test-company-icon",
|
||||
"isLeaf": true,
|
||||
"label": "Company",
|
||||
"nameSingular": "company",
|
||||
"objectMetadataId": "20202020-c03c-45d6-a4b0-04afe1357c5c",
|
||||
"value": "A company",
|
||||
date: {
|
||||
isLeaf: true,
|
||||
label: 'Date',
|
||||
type: 'DATE',
|
||||
value: 'mm/dd/yyyy',
|
||||
},
|
||||
},
|
||||
},
|
||||
"date": {
|
||||
"fieldMetadataId": undefined,
|
||||
"icon": undefined,
|
||||
"isLeaf": true,
|
||||
"label": "Date",
|
||||
"type": "DATE",
|
||||
"value": "mm/dd/yyyy",
|
||||
},
|
||||
"name": {
|
||||
"fieldMetadataId": undefined,
|
||||
"icon": undefined,
|
||||
"isLeaf": true,
|
||||
"label": "Name",
|
||||
"type": "TEXT",
|
||||
"value": "My text",
|
||||
},
|
||||
}
|
||||
`);
|
||||
name: {
|
||||
isLeaf: true,
|
||||
label: 'Name',
|
||||
type: 'TEXT',
|
||||
value: 'My text',
|
||||
},
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
+3
@@ -5,9 +5,11 @@ import { generateObjectRecordFields } from 'src/modules/workflow/workflow-builde
|
||||
export const generateFakeObjectRecord = ({
|
||||
objectMetadataInfo,
|
||||
depth = 0,
|
||||
isRelationField,
|
||||
}: {
|
||||
objectMetadataInfo: ObjectMetadataInfo;
|
||||
depth?: number;
|
||||
isRelationField?: boolean;
|
||||
}): RecordOutputSchema => {
|
||||
return {
|
||||
object: {
|
||||
@@ -20,6 +22,7 @@ export const generateFakeObjectRecord = ({
|
||||
objectMetadataInfo.objectMetadataItemWithFieldsMaps.nameSingular,
|
||||
fieldIdName: 'id',
|
||||
objectMetadataId: objectMetadataInfo.objectMetadataItemWithFieldsMaps.id,
|
||||
isRelationField,
|
||||
},
|
||||
fields: generateObjectRecordFields({
|
||||
objectMetadataInfo,
|
||||
|
||||
+2
@@ -52,6 +52,7 @@ export const generateObjectRecordFields = ({
|
||||
isLeaf: false,
|
||||
icon: field.icon ?? undefined,
|
||||
label: field.label,
|
||||
type: field.type,
|
||||
fieldMetadataId: field.id,
|
||||
value: generateFakeObjectRecord({
|
||||
objectMetadataInfo: {
|
||||
@@ -59,6 +60,7 @@ export const generateObjectRecordFields = ({
|
||||
objectMetadataMaps: objectMetadataInfo.objectMetadataMaps,
|
||||
},
|
||||
depth: depth + 1,
|
||||
isRelationField: true,
|
||||
}),
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user