Allow workflow field update when custom (#11619)
- Allow workflow field update when custom - Also handle the case where object name is not defined in actions
This commit is contained in:
@ -18,5 +18,6 @@ export const useIsFieldValueReadOnly = ({
|
||||
fieldName: metadata.fieldName,
|
||||
fieldType: type,
|
||||
isRecordReadOnly,
|
||||
isCustom: metadata.isCustom,
|
||||
});
|
||||
};
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
|
||||
import { FieldMetadata } from './FieldMetadata';
|
||||
import { IconComponent } from 'twenty-ui/display';
|
||||
import { FieldMetadata } from './FieldMetadata';
|
||||
|
||||
export type FieldDefinition<T extends FieldMetadata> = {
|
||||
fieldMetadataId: string;
|
||||
|
||||
@ -1,46 +1,42 @@
|
||||
import { RATING_VALUES } from '@/object-record/record-field/meta-types/constants/RatingValues';
|
||||
import { ZodHelperLiteral } from '@/object-record/record-field/types/ZodHelperLiteral';
|
||||
import { ObjectRecord } from '@/object-record/types/ObjectRecord';
|
||||
import { ConnectedAccountProvider } from 'twenty-shared/types';
|
||||
import { ThemeColor } from 'twenty-ui/theme';
|
||||
import * as z from 'zod';
|
||||
import { RelationDefinitionType } from '~/generated-metadata/graphql';
|
||||
import { CurrencyCode } from './CurrencyCode';
|
||||
import { ConnectedAccountProvider } from 'twenty-shared/types';
|
||||
import { ThemeColor } from 'twenty-ui/theme';
|
||||
|
||||
export type FieldUuidMetadata = {
|
||||
objectMetadataNameSingular?: string;
|
||||
type BaseFieldMetadata = {
|
||||
fieldName: string;
|
||||
objectMetadataNameSingular?: string;
|
||||
isCustom?: boolean;
|
||||
};
|
||||
|
||||
export type FieldUuidMetadata = BaseFieldMetadata & {
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldBooleanMetadata = {
|
||||
objectMetadataNameSingular?: string;
|
||||
fieldName: string;
|
||||
export type FieldBooleanMetadata = BaseFieldMetadata & {
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldTextMetadata = {
|
||||
objectMetadataNameSingular?: string;
|
||||
export type FieldTextMetadata = BaseFieldMetadata & {
|
||||
placeHolder: string;
|
||||
fieldName: string;
|
||||
settings?: {
|
||||
displayedMaxRows?: number;
|
||||
};
|
||||
};
|
||||
|
||||
export type FieldDateTimeMetadata = {
|
||||
objectMetadataNameSingular?: string;
|
||||
export type FieldDateTimeMetadata = BaseFieldMetadata & {
|
||||
placeHolder: string;
|
||||
fieldName: string;
|
||||
settings?: {
|
||||
displayAsRelativeDate?: boolean;
|
||||
};
|
||||
};
|
||||
|
||||
export type FieldDateMetadata = {
|
||||
objectMetadataNameSingular?: string;
|
||||
export type FieldDateMetadata = BaseFieldMetadata & {
|
||||
placeHolder: string;
|
||||
fieldName: string;
|
||||
settings?: {
|
||||
displayAsRelativeDate?: boolean;
|
||||
};
|
||||
@ -48,9 +44,7 @@ export type FieldDateMetadata = {
|
||||
|
||||
export type FieldNumberVariant = 'number' | 'percentage';
|
||||
|
||||
export type FieldNumberMetadata = {
|
||||
objectMetadataNameSingular?: string;
|
||||
fieldName: string;
|
||||
export type FieldNumberMetadata = BaseFieldMetadata & {
|
||||
placeHolder: string;
|
||||
isPositive?: boolean;
|
||||
settings?: {
|
||||
@ -59,95 +53,67 @@ export type FieldNumberMetadata = {
|
||||
};
|
||||
};
|
||||
|
||||
export type FieldLinkMetadata = {
|
||||
objectMetadataNameSingular?: string;
|
||||
export type FieldLinkMetadata = BaseFieldMetadata & {
|
||||
placeHolder: string;
|
||||
fieldName: string;
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldLinksMetadata = {
|
||||
objectMetadataNameSingular?: string;
|
||||
fieldName: string;
|
||||
export type FieldLinksMetadata = BaseFieldMetadata & {
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldCurrencyMetadata = {
|
||||
objectMetadataNameSingular?: string;
|
||||
fieldName: string;
|
||||
export type FieldCurrencyMetadata = BaseFieldMetadata & {
|
||||
placeHolder: string;
|
||||
isPositive?: boolean;
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldFullNameMetadata = {
|
||||
objectMetadataNameSingular?: string;
|
||||
placeHolder: string;
|
||||
fieldName: string;
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldEmailMetadata = {
|
||||
objectMetadataNameSingular?: string;
|
||||
placeHolder: string;
|
||||
fieldName: string;
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldEmailsMetadata = {
|
||||
objectMetadataNameSingular?: string;
|
||||
fieldName: string;
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldPhoneMetadata = {
|
||||
objectMetadataNameSingular?: string;
|
||||
placeHolder: string;
|
||||
fieldName: string;
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldRatingMetadata = {
|
||||
objectMetadataNameSingular?: string;
|
||||
fieldName: string;
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldAddressMetadata = {
|
||||
objectMetadataNameSingular?: string;
|
||||
placeHolder: string;
|
||||
fieldName: string;
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldRawJsonMetadata = {
|
||||
objectMetadataNameSingular?: string;
|
||||
fieldName: string;
|
||||
export type FieldFullNameMetadata = BaseFieldMetadata & {
|
||||
placeHolder: string;
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldRichTextV2Metadata = {
|
||||
objectMetadataNameSingular?: string;
|
||||
fieldName: string;
|
||||
export type FieldEmailMetadata = BaseFieldMetadata & {
|
||||
placeHolder: string;
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldRichTextMetadata = {
|
||||
objectMetadataNameSingular?: string;
|
||||
fieldName: string;
|
||||
export type FieldEmailsMetadata = BaseFieldMetadata & {
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldPositionMetadata = {
|
||||
objectMetadataNameSingular?: string;
|
||||
fieldName: string;
|
||||
export type FieldPhoneMetadata = BaseFieldMetadata & {
|
||||
placeHolder: string;
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldRelationMetadata = {
|
||||
fieldName: string;
|
||||
objectMetadataNameSingular?: string;
|
||||
export type FieldRatingMetadata = BaseFieldMetadata & {
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldAddressMetadata = BaseFieldMetadata & {
|
||||
placeHolder: string;
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldRawJsonMetadata = BaseFieldMetadata & {
|
||||
placeHolder: string;
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldRichTextV2Metadata = BaseFieldMetadata & {
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldRichTextMetadata = BaseFieldMetadata & {
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldPositionMetadata = BaseFieldMetadata & {
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldRelationMetadata = BaseFieldMetadata & {
|
||||
relationFieldMetadataId: string;
|
||||
relationObjectMetadataNamePlural: string;
|
||||
relationObjectMetadataNameSingular: string;
|
||||
@ -157,43 +123,31 @@ export type FieldRelationMetadata = {
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldSelectMetadata = {
|
||||
objectMetadataNameSingular?: string;
|
||||
fieldName: string;
|
||||
export type FieldSelectMetadata = BaseFieldMetadata & {
|
||||
options: { label: string; color: ThemeColor; value: string }[];
|
||||
isNullable: boolean;
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldMultiSelectMetadata = {
|
||||
objectMetadataNameSingular?: string;
|
||||
fieldName: string;
|
||||
export type FieldMultiSelectMetadata = BaseFieldMetadata & {
|
||||
options: { label: string; color: ThemeColor; value: string }[];
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldActorMetadata = {
|
||||
objectMetadataNameSingular?: string;
|
||||
fieldName: string;
|
||||
export type FieldActorMetadata = BaseFieldMetadata & {
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldArrayMetadata = {
|
||||
objectMetadataNameSingular?: string;
|
||||
fieldName: string;
|
||||
export type FieldArrayMetadata = BaseFieldMetadata & {
|
||||
values: { label: string; value: string }[];
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldPhonesMetadata = {
|
||||
objectMetadataNameSingular?: string;
|
||||
fieldName: string;
|
||||
export type FieldPhonesMetadata = BaseFieldMetadata & {
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
export type FieldTsVectorMetadata = {
|
||||
objectMetadataNameSingular?: string;
|
||||
fieldName: string;
|
||||
export type FieldTsVectorMetadata = BaseFieldMetadata & {
|
||||
settings?: null;
|
||||
};
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@ type isFieldValueReadOnlyParams = {
|
||||
fieldName?: string;
|
||||
fieldType?: FieldMetadataType;
|
||||
isRecordReadOnly?: boolean;
|
||||
isCustom?: boolean;
|
||||
};
|
||||
|
||||
export const isFieldValueReadOnly = ({
|
||||
@ -18,6 +19,7 @@ export const isFieldValueReadOnly = ({
|
||||
fieldName,
|
||||
fieldType,
|
||||
isRecordReadOnly = false,
|
||||
isCustom = false,
|
||||
}: isFieldValueReadOnlyParams) => {
|
||||
if (isRecordReadOnly) {
|
||||
return true;
|
||||
@ -40,7 +42,8 @@ export const isFieldValueReadOnly = ({
|
||||
|
||||
if (
|
||||
objectNameSingular === CoreObjectNameSingular.Workflow &&
|
||||
fieldName !== 'name'
|
||||
fieldName !== 'name' &&
|
||||
!isCustom
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -4,8 +4,8 @@ import { mapArrayToObject } from '~/utils/array/mapArrayToObject';
|
||||
import { moveArrayItem } from '~/utils/array/moveArrayItem';
|
||||
import { isUndefinedOrNull } from '~/utils/isUndefinedOrNull';
|
||||
|
||||
import { ViewField } from '../types/ViewField';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { ViewField } from '../types/ViewField';
|
||||
|
||||
export const mapViewFieldsToColumnDefinitions = ({
|
||||
columnDefinitions,
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
import { useFilteredObjectMetadataItems } from '@/object-metadata/hooks/useFilteredObjectMetadataItems';
|
||||
import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
|
||||
import { useObjectMetadataItems } from '@/object-metadata/hooks/useObjectMetadataItems';
|
||||
import { formatFieldMetadataItemAsFieldDefinition } from '@/object-metadata/utils/formatFieldMetadataItemAsFieldDefinition';
|
||||
import { FormFieldInput } from '@/object-record/record-field/components/FormFieldInput';
|
||||
import { Select } from '@/ui/input/components/Select';
|
||||
@ -13,11 +13,11 @@ import { getActionIcon } from '@/workflow/workflow-steps/workflow-actions/utils/
|
||||
import { WorkflowVariablePicker } from '@/workflow/workflow-variables/components/WorkflowVariablePicker';
|
||||
import { useEffect, useState } from 'react';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { HorizontalSeparator, useIcons } from 'twenty-ui/display';
|
||||
import { SelectOption } from 'twenty-ui/input';
|
||||
import { JsonValue } from 'type-fest';
|
||||
import { useDebouncedCallback } from 'use-debounce';
|
||||
import { FieldMetadataType } from '~/generated/graphql';
|
||||
import { HorizontalSeparator, useIcons } from 'twenty-ui/display';
|
||||
import { SelectOption } from 'twenty-ui/input';
|
||||
|
||||
type WorkflowEditActionCreateRecordProps = {
|
||||
action: WorkflowCreateRecordAction;
|
||||
@ -78,17 +78,19 @@ export const WorkflowEditActionCreateRecord = ({
|
||||
|
||||
const objectNameSingular = formData.objectName;
|
||||
|
||||
const { objectMetadataItem } = useObjectMetadataItem({
|
||||
objectNameSingular,
|
||||
});
|
||||
const { objectMetadataItems } = useObjectMetadataItems();
|
||||
|
||||
const objectMetadataItem = objectMetadataItems.find(
|
||||
(item) => item.nameSingular === objectNameSingular,
|
||||
);
|
||||
|
||||
const { view: indexView } = useViewOrDefaultViewFromPrefetchedViews({
|
||||
objectMetadataItemId: objectMetadataItem.id ?? '',
|
||||
objectMetadataItemId: objectMetadataItem?.id ?? '',
|
||||
});
|
||||
|
||||
const viewFields = indexView?.viewFields ?? [];
|
||||
|
||||
const inlineFieldMetadataItems = objectMetadataItem.fields
|
||||
const inlineFieldMetadataItems = objectMetadataItem?.fields
|
||||
.filter(
|
||||
(fieldMetadataItem) =>
|
||||
fieldMetadataItem.type !== FieldMetadataType.RELATION &&
|
||||
@ -106,15 +108,16 @@ export const WorkflowEditActionCreateRecord = ({
|
||||
})
|
||||
.sort(sortByViewFieldPosition);
|
||||
|
||||
const inlineFieldDefinitions = inlineFieldMetadataItems.map(
|
||||
(fieldMetadataItem) =>
|
||||
formatFieldMetadataItemAsFieldDefinition({
|
||||
field: fieldMetadataItem,
|
||||
objectMetadataItem,
|
||||
showLabel: true,
|
||||
labelWidth: 90,
|
||||
}),
|
||||
);
|
||||
const inlineFieldDefinitions = isDefined(objectMetadataItem)
|
||||
? inlineFieldMetadataItems?.map((fieldMetadataItem) =>
|
||||
formatFieldMetadataItemAsFieldDefinition({
|
||||
field: fieldMetadataItem,
|
||||
objectMetadataItem,
|
||||
showLabel: true,
|
||||
labelWidth: 90,
|
||||
}),
|
||||
)
|
||||
: [];
|
||||
|
||||
const handleFieldChange = (
|
||||
fieldName: keyof CreateRecordFormData,
|
||||
@ -205,7 +208,7 @@ export const WorkflowEditActionCreateRecord = ({
|
||||
|
||||
<HorizontalSeparator noMargin />
|
||||
|
||||
{inlineFieldDefinitions.map((field) => {
|
||||
{inlineFieldDefinitions?.map((field) => {
|
||||
const currentValue = formData[field.metadata.fieldName] as JsonValue;
|
||||
|
||||
return (
|
||||
|
||||
@ -11,10 +11,10 @@ import { useActionIconColorOrThrow } from '@/workflow/workflow-steps/workflow-ac
|
||||
import { getActionIcon } from '@/workflow/workflow-steps/workflow-actions/utils/getActionIcon';
|
||||
import { WorkflowVariablePicker } from '@/workflow/workflow-variables/components/WorkflowVariablePicker';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { JsonValue } from 'type-fest';
|
||||
import { useDebouncedCallback } from 'use-debounce';
|
||||
import { HorizontalSeparator, useIcons } from 'twenty-ui/display';
|
||||
import { SelectOption } from 'twenty-ui/input';
|
||||
import { JsonValue } from 'type-fest';
|
||||
import { useDebouncedCallback } from 'use-debounce';
|
||||
|
||||
type WorkflowEditActionDeleteRecordProps = {
|
||||
action: WorkflowDeleteRecordAction;
|
||||
@ -68,14 +68,9 @@ export const WorkflowEditActionDeleteRecord = ({
|
||||
saveAction(newFormData);
|
||||
};
|
||||
|
||||
const selectedObjectMetadataItemNameSingular = formData.objectName;
|
||||
|
||||
const selectedObjectMetadataItem = activeObjectMetadataItems.find(
|
||||
(item) => item.nameSingular === selectedObjectMetadataItemNameSingular,
|
||||
);
|
||||
if (!isDefined(selectedObjectMetadataItem)) {
|
||||
throw new Error('Should have found the metadata item');
|
||||
}
|
||||
const objectNameSingular = activeObjectMetadataItems.find(
|
||||
(item) => item.nameSingular === formData.objectName,
|
||||
)?.nameSingular;
|
||||
|
||||
const saveAction = useDebouncedCallback(
|
||||
async (formData: DeleteRecordFormData) => {
|
||||
@ -156,17 +151,19 @@ export const WorkflowEditActionDeleteRecord = ({
|
||||
|
||||
<HorizontalSeparator noMargin />
|
||||
|
||||
<FormSingleRecordPicker
|
||||
label="Record"
|
||||
onChange={(objectRecordId) =>
|
||||
handleFieldChange('objectRecordId', objectRecordId)
|
||||
}
|
||||
objectNameSingular={formData.objectName}
|
||||
defaultValue={formData.objectRecordId}
|
||||
testId="workflow-edit-action-record-delete-object-record-id"
|
||||
disabled={isFormDisabled}
|
||||
VariablePicker={WorkflowVariablePicker}
|
||||
/>
|
||||
{isDefined(objectNameSingular) && (
|
||||
<FormSingleRecordPicker
|
||||
label="Record"
|
||||
onChange={(objectRecordId) =>
|
||||
handleFieldChange('objectRecordId', objectRecordId)
|
||||
}
|
||||
objectNameSingular={objectNameSingular}
|
||||
defaultValue={formData.objectRecordId}
|
||||
testId="workflow-edit-action-record-delete-object-record-id"
|
||||
disabled={isFormDisabled}
|
||||
VariablePicker={WorkflowVariablePicker}
|
||||
/>
|
||||
)}
|
||||
</WorkflowStepBody>
|
||||
</>
|
||||
);
|
||||
|
||||
@ -10,9 +10,9 @@ import { useActionHeaderTypeOrThrow } from '@/workflow/workflow-steps/workflow-a
|
||||
import { useActionIconColorOrThrow } from '@/workflow/workflow-steps/workflow-actions/hooks/useActionIconColorOrThrow';
|
||||
import { getActionIcon } from '@/workflow/workflow-steps/workflow-actions/utils/getActionIcon';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { useDebouncedCallback } from 'use-debounce';
|
||||
import { HorizontalSeparator, useIcons } from 'twenty-ui/display';
|
||||
import { SelectOption } from 'twenty-ui/input';
|
||||
import { useDebouncedCallback } from 'use-debounce';
|
||||
|
||||
type WorkflowEditActionFindRecordsProps = {
|
||||
action: WorkflowFindRecordsAction;
|
||||
@ -52,14 +52,10 @@ export const WorkflowEditActionFindRecords = ({
|
||||
});
|
||||
const isFormDisabled = actionOptions.readonly;
|
||||
|
||||
const selectedObjectMetadataItemNameSingular = formData.objectName;
|
||||
|
||||
const selectedObjectMetadataItem = activeObjectMetadataItems.find(
|
||||
(item) => item.nameSingular === selectedObjectMetadataItemNameSingular,
|
||||
);
|
||||
if (!isDefined(selectedObjectMetadataItem)) {
|
||||
throw new Error('Should have found the metadata item');
|
||||
}
|
||||
const selectedObjectMetadataItemNameSingular =
|
||||
activeObjectMetadataItems.find(
|
||||
(item) => item.nameSingular === formData.objectName,
|
||||
)?.nameSingular ?? '';
|
||||
|
||||
const saveAction = useDebouncedCallback(
|
||||
async (formData: FindRecordsFormData) => {
|
||||
@ -119,7 +115,7 @@ export const WorkflowEditActionFindRecords = ({
|
||||
label="Object"
|
||||
fullWidth
|
||||
disabled={isFormDisabled}
|
||||
value={formData.objectName}
|
||||
value={selectedObjectMetadataItemNameSingular}
|
||||
emptyOption={{ label: 'Select an option', value: '' }}
|
||||
options={availableMetadata}
|
||||
onChange={(objectName) => {
|
||||
|
||||
@ -14,11 +14,11 @@ import { useActionIconColorOrThrow } from '@/workflow/workflow-steps/workflow-ac
|
||||
import { getActionIcon } from '@/workflow/workflow-steps/workflow-actions/utils/getActionIcon';
|
||||
import { WorkflowVariablePicker } from '@/workflow/workflow-variables/components/WorkflowVariablePicker';
|
||||
import { isDefined } from 'twenty-shared/utils';
|
||||
import { HorizontalSeparator, useIcons } from 'twenty-ui/display';
|
||||
import { SelectOption } from 'twenty-ui/input';
|
||||
import { JsonValue } from 'type-fest';
|
||||
import { useDebouncedCallback } from 'use-debounce';
|
||||
import { FieldMetadataType } from '~/generated-metadata/graphql';
|
||||
import { HorizontalSeparator, useIcons } from 'twenty-ui/display';
|
||||
import { SelectOption } from 'twenty-ui/input';
|
||||
|
||||
type WorkflowEditActionUpdateRecordProps = {
|
||||
action: WorkflowUpdateRecordAction;
|
||||
@ -94,16 +94,13 @@ export const WorkflowEditActionUpdateRecord = ({
|
||||
saveAction(newFormData);
|
||||
};
|
||||
|
||||
const selectedObjectMetadataItemNameSingular = formData.objectName;
|
||||
|
||||
const selectedObjectMetadataItem = activeObjectMetadataItems.find(
|
||||
(item) => item.nameSingular === selectedObjectMetadataItemNameSingular,
|
||||
(item) => item.nameSingular === formData.objectName,
|
||||
);
|
||||
if (!isDefined(selectedObjectMetadataItem)) {
|
||||
throw new Error('Should have found the metadata item');
|
||||
}
|
||||
|
||||
const inlineFieldMetadataItems = selectedObjectMetadataItem.fields
|
||||
const objectNameSingular = selectedObjectMetadataItem?.nameSingular;
|
||||
|
||||
const inlineFieldMetadataItems = selectedObjectMetadataItem?.fields
|
||||
.filter(
|
||||
(fieldMetadataItem) =>
|
||||
!fieldMetadataItem.isSystem &&
|
||||
@ -114,15 +111,16 @@ export const WorkflowEditActionUpdateRecord = ({
|
||||
fieldMetadataItemA.name.localeCompare(fieldMetadataItemB.name),
|
||||
);
|
||||
|
||||
const inlineFieldDefinitions = inlineFieldMetadataItems.map(
|
||||
(fieldMetadataItem) =>
|
||||
formatFieldMetadataItemAsFieldDefinition({
|
||||
field: fieldMetadataItem,
|
||||
objectMetadataItem: selectedObjectMetadataItem,
|
||||
showLabel: true,
|
||||
labelWidth: 90,
|
||||
}),
|
||||
);
|
||||
const inlineFieldDefinitions = isDefined(selectedObjectMetadataItem)
|
||||
? inlineFieldMetadataItems?.map((fieldMetadataItem) =>
|
||||
formatFieldMetadataItemAsFieldDefinition({
|
||||
field: fieldMetadataItem,
|
||||
objectMetadataItem: selectedObjectMetadataItem,
|
||||
showLabel: true,
|
||||
labelWidth: 90,
|
||||
}),
|
||||
)
|
||||
: [];
|
||||
|
||||
const saveAction = useDebouncedCallback(
|
||||
async (formData: UpdateRecordFormData) => {
|
||||
@ -209,39 +207,43 @@ export const WorkflowEditActionUpdateRecord = ({
|
||||
|
||||
<HorizontalSeparator noMargin />
|
||||
|
||||
<FormSingleRecordPicker
|
||||
testId="workflow-edit-action-record-update-object-record-id"
|
||||
label="Record"
|
||||
onChange={(objectRecordId) =>
|
||||
handleFieldChange('objectRecordId', objectRecordId)
|
||||
}
|
||||
objectNameSingular={formData.objectName}
|
||||
defaultValue={formData.objectRecordId}
|
||||
disabled={isFormDisabled}
|
||||
VariablePicker={WorkflowVariablePicker}
|
||||
/>
|
||||
{isDefined(objectNameSingular) && (
|
||||
<FormSingleRecordPicker
|
||||
testId="workflow-edit-action-record-update-object-record-id"
|
||||
label="Record"
|
||||
onChange={(objectRecordId) =>
|
||||
handleFieldChange('objectRecordId', objectRecordId)
|
||||
}
|
||||
objectNameSingular={objectNameSingular}
|
||||
defaultValue={formData.objectRecordId}
|
||||
disabled={isFormDisabled}
|
||||
VariablePicker={WorkflowVariablePicker}
|
||||
/>
|
||||
)}
|
||||
|
||||
<FormMultiSelectFieldInput
|
||||
testId="workflow-edit-action-record-update-fields-to-update"
|
||||
label="Fields to update"
|
||||
defaultValue={formData.fieldsToUpdate}
|
||||
options={inlineFieldDefinitions.map((field) => ({
|
||||
label: field.label,
|
||||
value: field.metadata.fieldName,
|
||||
icon: getIcon(field.iconName),
|
||||
color: 'gray',
|
||||
}))}
|
||||
onChange={(fieldsToUpdate) =>
|
||||
handleFieldChange('fieldsToUpdate', fieldsToUpdate)
|
||||
}
|
||||
placeholder="Select fields to update"
|
||||
readonly={isFormDisabled}
|
||||
/>
|
||||
{isDefined(inlineFieldDefinitions) && (
|
||||
<FormMultiSelectFieldInput
|
||||
testId="workflow-edit-action-record-update-fields-to-update"
|
||||
label="Fields to update"
|
||||
defaultValue={formData.fieldsToUpdate}
|
||||
options={inlineFieldDefinitions.map((field) => ({
|
||||
label: field.label,
|
||||
value: field.metadata.fieldName,
|
||||
icon: getIcon(field.iconName),
|
||||
color: 'gray',
|
||||
}))}
|
||||
onChange={(fieldsToUpdate) =>
|
||||
handleFieldChange('fieldsToUpdate', fieldsToUpdate)
|
||||
}
|
||||
placeholder="Select fields to update"
|
||||
readonly={isFormDisabled}
|
||||
/>
|
||||
)}
|
||||
|
||||
<HorizontalSeparator noMargin />
|
||||
|
||||
{formData.fieldsToUpdate.map((fieldName) => {
|
||||
const fieldDefinition = inlineFieldDefinitions.find(
|
||||
const fieldDefinition = inlineFieldDefinitions?.find(
|
||||
(definition) => definition.metadata.fieldName === fieldName,
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user