Closed Bonapara closed 1 month ago
Add API Name Field to Object Edit Page
/packages/twenty-front/src/pages/settings/data-model/SettingsObjectEdit.tsx
SettingsObjectEdit
component.import { TextField } from '@/ui/input/text-field/components/TextField';
const objectEditFormSchema = z
.object({
apiName: z.string().optional(),
})
.merge(settingsDataModelObjectAboutFormSchema)
.merge(settingsDataModelObjectIdentifiersFormSchema);
// Inside the SettingsObjectEdit component
<Section>
<H2Title title="API Name" description="Set a custom API name for this object." />
<TextField name="apiName" label="API Name" />
</Section>
Add API Name Field to Field Edit Page
/packages/twenty-front/src/pages/settings/data-model/SettingsObjectFieldEdit.tsx
SettingsObjectFieldEdit
component.import { TextField } from '@/ui/input/text-field/components/TextField';
const settingsFieldFormSchema = z
.object({
apiName: z.string().optional(),
})
.merge(existingSchema);
// Inside the SettingsObjectFieldEdit component
<Section>
<H2Title title="API Name" description="Set a custom API name for this field." />
<TextField name="apiName" label="API Name" />
</Section>
Update Form Submission Logic
handleSave
functions in both SettingsObjectEdit
and SettingsObjectFieldEdit
components to handle the new API Name field.const handleSave = async (formValues) => {
const { apiName, ...otherValues } = formValues;
// Include apiName in the update payload
await updateOneObjectMetadataItem({
idToUpdate: activeObjectMetadataItem.id,
updatePayload: { apiName, ...otherValues },
});
};
/packages/twenty-front/src/pages/settings/data-model/SettingsObjectFieldEdit.tsx /packages/twenty-front/src/pages/settings/data-model/SettingsObjectDetail.tsx /packages/twenty-front/src/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldStep1.tsx /packages/twenty-front/src/pages/settings/data-model/SettingsObjectNewField/SettingsObjectNewFieldStep2.tsx /packages/twenty-front/src/pages/settings/data-model/SettingsObjectEdit.tsx
@Bonapara Can I work?
Sure @Faisal-imtiyaz123, thanks for contributing!
@Bonapara Do I have to make this Text Field
Component.
We should use the standard text field component but add a yellow border and a wrench icon component. This component will either have an absolute or relative position. The border's height should always match the height of the element it's applied to, and the wrench should always be positioned on top.
See #6146 for the "position: relative" of the yellow border and Wrench component.
@Bonapara pardon me but there is no directorytext-input
under @ui/input. If i import the snippet import { TextField } from '@/ui/input/text-field/components/TextField';
it's not recognized. Sorry for asking a lot. I am new to the project.
Are you talking about this? https://storybook.twenty.com/?path=/story/ui-input-textinput--default
Got it ! Thanks
I'm not fully convinced by this feature, left a comment on the main thread here: https://github.com/twentyhq/twenty/issues/5491#issuecomment-2226833596
Hi @gitstart-twenty, since the sync API names setting will be on the API & Webhooks settings page in advanced mode, we won't need to make the Sync API names an advanced settings.
We can show it in blue as a result:
@gitstart-twenty @ijreilly @Bonapara I'm not a big fan of:
Could we instead keep this on the Object Edit / Field Edit page and keep it field or object level?
Merged this issue with other issue https://github.com/twentyhq/twenty/issues/5491
Desired Behavior
Introduce the following system:
1) An Advanced Settings option on the bottom of the API & Webhooks Settings page that allows to sync or unsync all labels and API names:
2) Behavior on an object detail page when this sync setting is activated:
Use a library like https://www.npmjs.com/package/pluralize to generate singular forms.
3) Behavior on an object detail page when this sync setting is deactivated:
4) Behavior on the Developer advanced Setting activation and deactivation:
5) Object creation
When creating a new object, even if the
Sync labels & API names
setting is deactivated, the API names should match the labels.