feat: allow backend to rename field of custom object (#4097)
* feat: allow backend to rename field of custom object * feat: allow custom field label edition in Settings Closes #4080 * fix: avoid renaming standard fields --------- Co-authored-by: Thaïs Guigon <guigon.thais@gmail.com>
This commit is contained in:
@ -9,7 +9,6 @@ import { Section } from '@/ui/layout/section/components/Section';
|
|||||||
|
|
||||||
type SettingsObjectFieldFormSectionProps = {
|
type SettingsObjectFieldFormSectionProps = {
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
disableNameEdition?: boolean;
|
|
||||||
name?: string;
|
name?: string;
|
||||||
description?: string;
|
description?: string;
|
||||||
iconKey?: string;
|
iconKey?: string;
|
||||||
@ -31,7 +30,6 @@ const StyledInputsContainer = styled.div`
|
|||||||
|
|
||||||
export const SettingsObjectFieldFormSection = ({
|
export const SettingsObjectFieldFormSection = ({
|
||||||
disabled,
|
disabled,
|
||||||
disableNameEdition,
|
|
||||||
name = '',
|
name = '',
|
||||||
description = '',
|
description = '',
|
||||||
iconKey = 'IconUsers',
|
iconKey = 'IconUsers',
|
||||||
@ -57,7 +55,7 @@ export const SettingsObjectFieldFormSection = ({
|
|||||||
onChange?.({ label: value });
|
onChange?.({ label: value });
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
disabled={disabled || disableNameEdition}
|
disabled={disabled}
|
||||||
fullWidth
|
fullWidth
|
||||||
/>
|
/>
|
||||||
</StyledInputsContainer>
|
</StyledInputsContainer>
|
||||||
|
|||||||
@ -209,7 +209,6 @@ export const SettingsObjectFieldEdit = () => {
|
|||||||
</SettingsHeaderContainer>
|
</SettingsHeaderContainer>
|
||||||
<SettingsObjectFieldFormSection
|
<SettingsObjectFieldFormSection
|
||||||
disabled={!activeMetadataField.isCustom}
|
disabled={!activeMetadataField.isCustom}
|
||||||
disableNameEdition
|
|
||||||
name={formValues.label}
|
name={formValues.label}
|
||||||
description={formValues.description}
|
description={formValues.description}
|
||||||
iconKey={formValues.icon}
|
iconKey={formValues.icon}
|
||||||
|
|||||||
@ -228,9 +228,23 @@ export class FieldMetadataService extends TypeOrmQueryService<FieldMetadataEntit
|
|||||||
)
|
)
|
||||||
: fieldMetadataInput;
|
: fieldMetadataInput;
|
||||||
|
|
||||||
const updatedFieldMetadata = await super.updateOne(id, updatableFieldInput);
|
const updatedFieldMetadata = await super.updateOne(id, {
|
||||||
|
...updatableFieldInput,
|
||||||
|
// If the name is updated, the targetColumnMap should be updated as well
|
||||||
|
targetColumnMap: updatableFieldInput.name
|
||||||
|
? generateTargetColumnMap(
|
||||||
|
existingFieldMetadata.type,
|
||||||
|
existingFieldMetadata.isCustom,
|
||||||
|
updatableFieldInput.name,
|
||||||
|
)
|
||||||
|
: existingFieldMetadata.targetColumnMap,
|
||||||
|
});
|
||||||
|
|
||||||
if (updatableFieldInput.options || updatableFieldInput.defaultValue) {
|
if (
|
||||||
|
fieldMetadataInput.name ||
|
||||||
|
updatableFieldInput.options ||
|
||||||
|
updatableFieldInput.defaultValue
|
||||||
|
) {
|
||||||
await this.workspaceMigrationService.createCustomMigration(
|
await this.workspaceMigrationService.createCustomMigration(
|
||||||
generateMigrationName(`update-${updatedFieldMetadata.name}`),
|
generateMigrationName(`update-${updatedFieldMetadata.name}`),
|
||||||
existingFieldMetadata.workspaceId,
|
existingFieldMetadata.workspaceId,
|
||||||
|
|||||||
Reference in New Issue
Block a user