Fix support custom object renaming (#8089)
In this PR 1) (FE) fixing update of name not taken into account if toggle value is changed in the same transaction 2) (BE) moving same nameSingular and namePlural validation before effective update
This commit is contained in:
@ -102,6 +102,8 @@ const StyledLabel = styled.span`
|
||||
|
||||
const infoCircleElementId = 'info-circle-id';
|
||||
|
||||
export const IS_LABEL_SYNCED_WITH_NAME_LABEL = 'isLabelSyncedWithName';
|
||||
|
||||
export const SettingsDataModelObjectAboutForm = ({
|
||||
disabled,
|
||||
disableNameEdit,
|
||||
@ -115,7 +117,7 @@ export const SettingsDataModelObjectAboutForm = ({
|
||||
isAdvancedModeEnabled,
|
||||
);
|
||||
|
||||
const isLabelSyncedWithName = watch('isLabelSyncedWithName');
|
||||
const isLabelSyncedWithName = watch(IS_LABEL_SYNCED_WITH_NAME_LABEL);
|
||||
const labelSingular = watch('labelSingular');
|
||||
const labelPlural = watch('labelPlural');
|
||||
const apiNameTooltipText = isLabelSyncedWithName
|
||||
@ -318,7 +320,7 @@ export const SettingsDataModelObjectAboutForm = ({
|
||||
),
|
||||
)}
|
||||
<Controller
|
||||
name="isLabelSyncedWithName"
|
||||
name={IS_LABEL_SYNCED_WITH_NAME_LABEL}
|
||||
control={control}
|
||||
defaultValue={
|
||||
objectMetadataItem?.isLabelSyncedWithName ?? true
|
||||
|
||||
@ -16,6 +16,7 @@ import { RecordFieldValueSelectorContextProvider } from '@/object-record/record-
|
||||
import { SaveAndCancelButtons } from '@/settings/components/SaveAndCancelButtons/SaveAndCancelButtons';
|
||||
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
||||
import {
|
||||
IS_LABEL_SYNCED_WITH_NAME_LABEL,
|
||||
SettingsDataModelObjectAboutForm,
|
||||
settingsDataModelObjectAboutFormSchema,
|
||||
} from '@/settings/data-model/objects/forms/components/SettingsDataModelObjectAboutForm';
|
||||
@ -81,10 +82,16 @@ export const SettingsObjectEdit = () => {
|
||||
formValues: SettingsDataModelObjectEditFormValues,
|
||||
) => {
|
||||
let values = formValues;
|
||||
if (
|
||||
formValues.isLabelSyncedWithName === true ||
|
||||
activeObjectMetadataItem.isLabelSyncedWithName === true
|
||||
) {
|
||||
const dirtyFieldKeys = Object.keys(
|
||||
formConfig.formState.dirtyFields,
|
||||
) as (keyof SettingsDataModelObjectEditFormValues)[];
|
||||
const shouldComputeNamesFromLabels: boolean = dirtyFieldKeys.includes(
|
||||
IS_LABEL_SYNCED_WITH_NAME_LABEL,
|
||||
)
|
||||
? (formValues.isLabelSyncedWithName as boolean)
|
||||
: activeObjectMetadataItem.isLabelSyncedWithName;
|
||||
|
||||
if (shouldComputeNamesFromLabels) {
|
||||
values = {
|
||||
...values,
|
||||
...(values.labelSingular
|
||||
@ -104,10 +111,6 @@ export const SettingsObjectEdit = () => {
|
||||
};
|
||||
}
|
||||
|
||||
const dirtyFieldKeys = Object.keys(
|
||||
formConfig.formState.dirtyFields,
|
||||
) as (keyof SettingsDataModelObjectEditFormValues)[];
|
||||
|
||||
return settingsUpdateObjectInputSchema.parse(
|
||||
pick(values, [
|
||||
...dirtyFieldKeys,
|
||||
|
||||
Reference in New Issue
Block a user