Fix update field default value (#11386)
Fixes https://github.com/twentyhq/twenty/issues/11379
This commit is contained in:
@ -80,6 +80,7 @@ export class BeforeUpdateOneField<T extends UpdateFieldInput>
|
||||
'isLabelSyncedWithName',
|
||||
'options',
|
||||
'settings',
|
||||
'defaultValue',
|
||||
];
|
||||
const overridableFields = ['label', 'icon', 'description'];
|
||||
|
||||
@ -102,7 +103,7 @@ export class BeforeUpdateOneField<T extends UpdateFieldInput>
|
||||
|
||||
if (nonUpdatableFields.length > 0) {
|
||||
throw new BadRequestException(
|
||||
`Only isActive, isLabelSyncedWithName, label, icon and description fields can be updated for standard fields. Invalid fields: ${nonUpdatableFields.join(', ')}`,
|
||||
`Only isActive, isLabelSyncedWithName, label, icon, description and defaultValue fields can be updated for standard fields. Invalid fields: ${nonUpdatableFields.join(', ')}`,
|
||||
);
|
||||
}
|
||||
|
||||
@ -116,6 +117,7 @@ export class BeforeUpdateOneField<T extends UpdateFieldInput>
|
||||
this.handleStandardOverrides(instance, fieldMetadata, update, locale);
|
||||
this.handleOptionsField(instance, update);
|
||||
this.handleSettingsField(instance, update);
|
||||
this.handleDefaultValueField(instance, update);
|
||||
|
||||
return {
|
||||
id: instance.id,
|
||||
@ -123,6 +125,17 @@ export class BeforeUpdateOneField<T extends UpdateFieldInput>
|
||||
};
|
||||
}
|
||||
|
||||
private handleDefaultValueField(
|
||||
instance: UpdateOneInputType<T>,
|
||||
update: StandardFieldUpdate,
|
||||
): void {
|
||||
if (!isDefined(instance.update.defaultValue)) {
|
||||
return;
|
||||
}
|
||||
|
||||
update.defaultValue = instance.update.defaultValue;
|
||||
}
|
||||
|
||||
private handleOptionsField(
|
||||
instance: UpdateOneInputType<T>,
|
||||
update: StandardFieldUpdate,
|
||||
|
||||
Reference in New Issue
Block a user