Allow to add and delete fields (#10990)

- Allow to add a new field
- On field click, display a delete button
- Use id instead of names for fields



https://github.com/user-attachments/assets/4ebffe22-225a-4bae-aa49-99e66170181a
This commit is contained in:
Thomas Trompette
2025-03-18 17:24:52 +01:00
committed by GitHub
parent 6d517360d1
commit 0ce91d84c1
7 changed files with 139 additions and 38 deletions

View File

@ -6,17 +6,17 @@ describe('generateFakeFormResponse', () => {
it('should generate fake responses for a form schema', () => {
const schema = [
{
name: 'name',
id: '96939213-49ac-4dee-949d-56e6c7be98e6',
type: FieldMetadataType.TEXT,
label: 'Name',
},
{
name: 'age',
id: '96939213-49ac-4dee-949d-56e6c7be98e7',
type: FieldMetadataType.NUMBER,
label: 'Age',
},
{
name: 'email',
id: '96939213-49ac-4dee-949d-56e6c7be98e8',
type: FieldMetadataType.EMAILS,
label: 'Email',
},
@ -25,7 +25,7 @@ describe('generateFakeFormResponse', () => {
const result = generateFakeFormResponse(schema);
expect(result).toEqual({
email: {
'96939213-49ac-4dee-949d-56e6c7be98e8': {
isLeaf: false,
label: 'Email',
value: {
@ -44,14 +44,14 @@ describe('generateFakeFormResponse', () => {
},
icon: undefined,
},
name: {
'96939213-49ac-4dee-949d-56e6c7be98e6': {
isLeaf: true,
label: 'Name',
type: FieldMetadataType.TEXT,
value: 'My text',
icon: undefined,
},
age: {
'96939213-49ac-4dee-949d-56e6c7be98e7': {
isLeaf: true,
label: 'Age',
type: FieldMetadataType.NUMBER,

View File

@ -9,7 +9,7 @@ export const generateFakeFormResponse = (
formMetadata: FormFieldMetadata[],
): Record<string, Leaf | Node> => {
return formMetadata.reduce((acc, formFieldMetadata) => {
acc[formFieldMetadata.name] = generateFakeField({
acc[formFieldMetadata.id] = generateFakeField({
type: formFieldMetadata.type,
label: formFieldMetadata.label,
});

View File

@ -505,14 +505,14 @@ export class WorkflowVersionStepWorkspaceService {
...BASE_STEP_DEFINITION,
input: [
{
id: v4(),
label: 'Company',
name: 'company',
placeholder: 'Select a company',
type: FieldMetadataType.TEXT,
},
{
id: v4(),
label: 'Number',
name: 'number',
placeholder: '1000',
type: FieldMetadataType.NUMBER,
},

View File

@ -3,8 +3,8 @@ import { FieldMetadataType } from 'twenty-shared';
import { BaseWorkflowActionSettings } from 'src/modules/workflow/workflow-executor/workflow-actions/types/workflow-action-settings.type';
export type FormFieldMetadata = {
id: string;
label: string;
name: string;
type: FieldMetadataType;
placeholder?: string;
settings?: Record<string, any>;