feat: create custom object and update edited object names (#2220)
Closes #2155, Closes #2153
This commit is contained in:
@ -37,7 +37,10 @@
|
|||||||
"js-levenshtein": "^1.1.6",
|
"js-levenshtein": "^1.1.6",
|
||||||
"jwt-decode": "^3.1.2",
|
"jwt-decode": "^3.1.2",
|
||||||
"libphonenumber-js": "^1.10.26",
|
"libphonenumber-js": "^1.10.26",
|
||||||
|
"lodash.camelcase": "^4.3.0",
|
||||||
"lodash.debounce": "^4.0.8",
|
"lodash.debounce": "^4.0.8",
|
||||||
|
"lodash.kebabcase": "^4.1.1",
|
||||||
|
"lodash.upperfirst": "^4.3.1",
|
||||||
"luxon": "^3.3.0",
|
"luxon": "^3.3.0",
|
||||||
"react": "^18.2.0",
|
"react": "^18.2.0",
|
||||||
"react-data-grid": "7.0.0-beta.13",
|
"react-data-grid": "7.0.0-beta.13",
|
||||||
@ -140,7 +143,10 @@
|
|||||||
"@types/intl-tel-input": "^18.1.1",
|
"@types/intl-tel-input": "^18.1.1",
|
||||||
"@types/jest": "^27.5.2",
|
"@types/jest": "^27.5.2",
|
||||||
"@types/js-cookie": "^3.0.3",
|
"@types/js-cookie": "^3.0.3",
|
||||||
|
"@types/lodash.camelcase": "^4.3.7",
|
||||||
"@types/lodash.debounce": "^4.0.7",
|
"@types/lodash.debounce": "^4.0.7",
|
||||||
|
"@types/lodash.kebabcase": "^4.1.7",
|
||||||
|
"@types/lodash.upperfirst": "^4.3.7",
|
||||||
"@types/luxon": "^3.3.0",
|
"@types/luxon": "^3.3.0",
|
||||||
"@types/react-datepicker": "^4.11.2",
|
"@types/react-datepicker": "^4.11.2",
|
||||||
"@types/scroll-into-view": "^1.16.0",
|
"@types/scroll-into-view": "^1.16.0",
|
||||||
|
|||||||
@ -644,6 +644,8 @@ export type UpdateObjectInput = {
|
|||||||
isActive?: InputMaybe<Scalars['Boolean']['input']>;
|
isActive?: InputMaybe<Scalars['Boolean']['input']>;
|
||||||
labelPlural?: InputMaybe<Scalars['String']['input']>;
|
labelPlural?: InputMaybe<Scalars['String']['input']>;
|
||||||
labelSingular?: InputMaybe<Scalars['String']['input']>;
|
labelSingular?: InputMaybe<Scalars['String']['input']>;
|
||||||
|
namePlural?: InputMaybe<Scalars['String']['input']>;
|
||||||
|
nameSingular?: InputMaybe<Scalars['String']['input']>;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type UpdateOneFieldInput = {
|
export type UpdateOneFieldInput = {
|
||||||
|
|||||||
@ -1,5 +1,8 @@
|
|||||||
import { MetadataObject } from '../types/MetadataObject';
|
import { MetadataObject } from '../types/MetadataObject';
|
||||||
|
import { formatMetadataObjectInput } from '../utils/formatMetadataObjectInput';
|
||||||
|
import { getObjectSlug } from '../utils/getObjectSlug';
|
||||||
|
|
||||||
|
import { useCreateOneMetadataObject } from './useCreateOneMetadataObject';
|
||||||
import { useFindManyMetadataObjects } from './useFindManyMetadataObjects';
|
import { useFindManyMetadataObjects } from './useFindManyMetadataObjects';
|
||||||
import { useUpdateOneMetadataObject } from './useUpdateOneMetadataObject';
|
import { useUpdateOneMetadataObject } from './useUpdateOneMetadataObject';
|
||||||
|
|
||||||
@ -13,17 +16,30 @@ export const useObjectMetadata = () => {
|
|||||||
({ isActive }) => !isActive,
|
({ isActive }) => !isActive,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
const findActiveObjectBySlug = (slug: string) =>
|
||||||
|
activeMetadataObjects.find(
|
||||||
|
(activeObject) => getObjectSlug(activeObject) === slug,
|
||||||
|
);
|
||||||
|
|
||||||
|
const { createOneMetadataObject } = useCreateOneMetadataObject();
|
||||||
const { updateOneMetadataObject } = useUpdateOneMetadataObject();
|
const { updateOneMetadataObject } = useUpdateOneMetadataObject();
|
||||||
|
|
||||||
const editObject = (metadataObject: MetadataObject) =>
|
const createObject = (
|
||||||
|
input: Pick<
|
||||||
|
MetadataObject,
|
||||||
|
'labelPlural' | 'labelSingular' | 'icon' | 'description'
|
||||||
|
>,
|
||||||
|
) => createOneMetadataObject(formatMetadataObjectInput(input));
|
||||||
|
|
||||||
|
const editObject = (
|
||||||
|
input: Pick<
|
||||||
|
MetadataObject,
|
||||||
|
'id' | 'labelPlural' | 'labelSingular' | 'icon' | 'description'
|
||||||
|
>,
|
||||||
|
) =>
|
||||||
updateOneMetadataObject({
|
updateOneMetadataObject({
|
||||||
idToUpdate: metadataObject.id,
|
idToUpdate: input.id,
|
||||||
updatePayload: {
|
updatePayload: formatMetadataObjectInput(input),
|
||||||
description: metadataObject.description ?? null,
|
|
||||||
icon: metadataObject.icon,
|
|
||||||
labelPlural: metadataObject.labelPlural,
|
|
||||||
labelSingular: metadataObject.labelSingular,
|
|
||||||
},
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const activateObject = (metadataObject: MetadataObject) =>
|
const activateObject = (metadataObject: MetadataObject) =>
|
||||||
@ -40,9 +56,11 @@ export const useObjectMetadata = () => {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
activateObject,
|
activateObject,
|
||||||
disableObject,
|
|
||||||
activeObjects: activeMetadataObjects,
|
activeObjects: activeMetadataObjects,
|
||||||
|
createObject,
|
||||||
disabledObjects: disabledMetadataObjects,
|
disabledObjects: disabledMetadataObjects,
|
||||||
|
disableObject,
|
||||||
editObject,
|
editObject,
|
||||||
|
findActiveObjectBySlug,
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@ -29,7 +29,13 @@ export const useUpdateOneMetadataObject = () => {
|
|||||||
idToUpdate: UpdateOneMetadataObjectMutationVariables['idToUpdate'];
|
idToUpdate: UpdateOneMetadataObjectMutationVariables['idToUpdate'];
|
||||||
updatePayload: Pick<
|
updatePayload: Pick<
|
||||||
UpdateOneMetadataObjectMutationVariables['updatePayload'],
|
UpdateOneMetadataObjectMutationVariables['updatePayload'],
|
||||||
'description' | 'icon' | 'isActive' | 'labelPlural' | 'labelSingular'
|
| 'description'
|
||||||
|
| 'icon'
|
||||||
|
| 'isActive'
|
||||||
|
| 'labelPlural'
|
||||||
|
| 'labelSingular'
|
||||||
|
| 'namePlural'
|
||||||
|
| 'nameSingular'
|
||||||
>;
|
>;
|
||||||
}) => {
|
}) => {
|
||||||
return await mutate({
|
return await mutate({
|
||||||
|
|||||||
@ -0,0 +1,18 @@
|
|||||||
|
import toCamelCase from 'lodash.camelcase';
|
||||||
|
import upperFirst from 'lodash.upperfirst';
|
||||||
|
|
||||||
|
import { MetadataObject } from '../types/MetadataObject';
|
||||||
|
|
||||||
|
export const formatMetadataObjectInput = (
|
||||||
|
input: Pick<
|
||||||
|
MetadataObject,
|
||||||
|
'labelPlural' | 'labelSingular' | 'icon' | 'description'
|
||||||
|
>,
|
||||||
|
) => ({
|
||||||
|
description: input.description?.trim() ?? null,
|
||||||
|
icon: input.icon,
|
||||||
|
labelPlural: input.labelPlural.trim(),
|
||||||
|
labelSingular: input.labelSingular.trim(),
|
||||||
|
namePlural: upperFirst(toCamelCase(input.labelPlural.trim())),
|
||||||
|
nameSingular: upperFirst(toCamelCase(input.labelSingular.trim())),
|
||||||
|
});
|
||||||
7
front/src/modules/metadata/utils/getObjectSlug.ts
Normal file
7
front/src/modules/metadata/utils/getObjectSlug.ts
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
import toKebabCase from 'lodash.kebabcase';
|
||||||
|
|
||||||
|
import { MetadataObject } from '../types/MetadataObject';
|
||||||
|
|
||||||
|
export const getObjectSlug = (
|
||||||
|
metadataObject: Pick<MetadataObject, 'labelPlural'>,
|
||||||
|
) => toKebabCase(metadataObject.labelPlural);
|
||||||
@ -0,0 +1,4 @@
|
|||||||
|
const metadataObjectLabelValidationPattern = /^[a-zA-Z][a-zA-Z0-9 ]*$/;
|
||||||
|
|
||||||
|
export const validateMetadataObjectLabel = (value: string) =>
|
||||||
|
!!value.match(metadataObjectLabelValidationPattern);
|
||||||
@ -1,5 +1,6 @@
|
|||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
|
|
||||||
|
import { validateMetadataObjectLabel } from '@/metadata/utils/validateMetadataObjectLabel';
|
||||||
import { H2Title } from '@/ui/display/typography/components/H2Title';
|
import { H2Title } from '@/ui/display/typography/components/H2Title';
|
||||||
import { TextArea } from '@/ui/input/components/TextArea';
|
import { TextArea } from '@/ui/input/components/TextArea';
|
||||||
import { TextInput } from '@/ui/input/components/TextInput';
|
import { TextInput } from '@/ui/input/components/TextInput';
|
||||||
@ -43,7 +44,11 @@ export const SettingsObjectFormSection = ({
|
|||||||
label="Singular"
|
label="Singular"
|
||||||
placeholder="Investor"
|
placeholder="Investor"
|
||||||
value={singularName}
|
value={singularName}
|
||||||
onChange={(value) => onChange?.({ labelSingular: value })}
|
onChange={(value) => {
|
||||||
|
if (!value || validateMetadataObjectLabel(value)) {
|
||||||
|
onChange?.({ labelSingular: value });
|
||||||
|
}
|
||||||
|
}}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
fullWidth
|
fullWidth
|
||||||
/>
|
/>
|
||||||
@ -51,7 +56,11 @@ export const SettingsObjectFormSection = ({
|
|||||||
label="Plural"
|
label="Plural"
|
||||||
placeholder="Investors"
|
placeholder="Investors"
|
||||||
value={pluralName}
|
value={pluralName}
|
||||||
onChange={(value) => onChange?.({ labelPlural: value })}
|
onChange={(value) => {
|
||||||
|
if (!value || validateMetadataObjectLabel(value)) {
|
||||||
|
onChange?.({ labelPlural: value });
|
||||||
|
}
|
||||||
|
}}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
fullWidth
|
fullWidth
|
||||||
/>
|
/>
|
||||||
|
|||||||
@ -2,11 +2,11 @@ export enum SettingsPath {
|
|||||||
ProfilePage = 'profile',
|
ProfilePage = 'profile',
|
||||||
Experience = 'profile/experience',
|
Experience = 'profile/experience',
|
||||||
Objects = 'objects',
|
Objects = 'objects',
|
||||||
ObjectDetail = 'objects/:pluralObjectName',
|
ObjectDetail = 'objects/:objectSlug',
|
||||||
ObjectEdit = 'objects/:pluralObjectName/edit',
|
ObjectEdit = 'objects/:objectSlug/edit',
|
||||||
ObjectNewFieldStep1 = 'objects/:pluralObjectName/new-field/step-1',
|
ObjectNewFieldStep1 = 'objects/:objectSlug/new-field/step-1',
|
||||||
ObjectNewFieldStep2 = 'objects/:pluralObjectName/new-field/step-2',
|
ObjectNewFieldStep2 = 'objects/:objectSlug/new-field/step-2',
|
||||||
ObjectFieldEdit = 'objects/:pluralObjectName/:fieldName',
|
ObjectFieldEdit = 'objects/:objectSlug/:fieldName',
|
||||||
NewObject = 'objects/new',
|
NewObject = 'objects/new',
|
||||||
WorkspaceMembersPage = 'workspace-members',
|
WorkspaceMembersPage = 'workspace-members',
|
||||||
Workspace = 'workspace',
|
Workspace = 'workspace',
|
||||||
|
|||||||
@ -1,6 +1,7 @@
|
|||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
import { useNavigate } from 'react-router-dom';
|
import { useNavigate } from 'react-router-dom';
|
||||||
|
|
||||||
|
import { useObjectMetadata } from '@/metadata/hooks/useObjectMetadata';
|
||||||
import { SaveAndCancelButtons } from '@/settings/components/SaveAndCancelButtons/SaveAndCancelButtons';
|
import { SaveAndCancelButtons } from '@/settings/components/SaveAndCancelButtons/SaveAndCancelButtons';
|
||||||
import { SettingsHeaderContainer } from '@/settings/components/SettingsHeaderContainer';
|
import { SettingsHeaderContainer } from '@/settings/components/SettingsHeaderContainer';
|
||||||
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
||||||
@ -21,19 +22,33 @@ export const SettingsNewObject = () => {
|
|||||||
const [selectedObjectType, setSelectedObjectType] =
|
const [selectedObjectType, setSelectedObjectType] =
|
||||||
useState<NewObjectType>('Standard');
|
useState<NewObjectType>('Standard');
|
||||||
|
|
||||||
const [customFormValues, setCustomFormValues] = useState<
|
const { createObject } = useObjectMetadata();
|
||||||
Partial<{
|
|
||||||
labelPlural: string;
|
const [customFormValues, setCustomFormValues] = useState<{
|
||||||
labelSingular: string;
|
description?: string;
|
||||||
description: string;
|
icon?: string;
|
||||||
}>
|
labelPlural: string;
|
||||||
>({});
|
labelSingular: string;
|
||||||
|
}>({ labelPlural: '', labelSingular: '' });
|
||||||
|
|
||||||
const canSave =
|
const canSave =
|
||||||
selectedObjectType === 'Custom' &&
|
selectedObjectType === 'Custom' &&
|
||||||
!!customFormValues.labelPlural &&
|
!!customFormValues.labelPlural &&
|
||||||
!!customFormValues.labelSingular;
|
!!customFormValues.labelSingular;
|
||||||
|
|
||||||
|
const handleSave = async () => {
|
||||||
|
if (selectedObjectType === 'Custom') {
|
||||||
|
await createObject({
|
||||||
|
labelPlural: customFormValues.labelPlural,
|
||||||
|
labelSingular: customFormValues.labelSingular,
|
||||||
|
description: customFormValues.description,
|
||||||
|
icon: customFormValues.icon,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
navigate('/settings/objects');
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SubMenuTopBarContainer Icon={IconSettings} title="Settings">
|
<SubMenuTopBarContainer Icon={IconSettings} title="Settings">
|
||||||
<SettingsPageContainer>
|
<SettingsPageContainer>
|
||||||
@ -49,7 +64,7 @@ export const SettingsNewObject = () => {
|
|||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
navigate('/settings/objects');
|
navigate('/settings/objects');
|
||||||
}}
|
}}
|
||||||
onSave={() => undefined}
|
onSave={handleSave}
|
||||||
/>
|
/>
|
||||||
</SettingsHeaderContainer>
|
</SettingsHeaderContainer>
|
||||||
<Section>
|
<Section>
|
||||||
@ -64,7 +79,16 @@ export const SettingsNewObject = () => {
|
|||||||
</Section>
|
</Section>
|
||||||
{selectedObjectType === 'Custom' && (
|
{selectedObjectType === 'Custom' && (
|
||||||
<>
|
<>
|
||||||
<SettingsObjectIconSection label={customFormValues.labelPlural} />
|
<SettingsObjectIconSection
|
||||||
|
label={customFormValues.labelPlural}
|
||||||
|
iconKey={customFormValues.icon}
|
||||||
|
onChange={({ iconKey }) => {
|
||||||
|
setCustomFormValues((previousValues) => ({
|
||||||
|
...previousValues,
|
||||||
|
icon: iconKey,
|
||||||
|
}));
|
||||||
|
}}
|
||||||
|
/>
|
||||||
<SettingsObjectFormSection
|
<SettingsObjectFormSection
|
||||||
singularName={customFormValues.labelSingular}
|
singularName={customFormValues.labelSingular}
|
||||||
pluralName={customFormValues.labelPlural}
|
pluralName={customFormValues.labelPlural}
|
||||||
|
|||||||
@ -32,11 +32,10 @@ const StyledDiv = styled.div`
|
|||||||
export const SettingsObjectDetail = () => {
|
export const SettingsObjectDetail = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const { pluralObjectName = '' } = useParams();
|
const { objectSlug = '' } = useParams();
|
||||||
const { activeObjects, disableObject } = useObjectMetadata();
|
const { activeObjects, disableObject, findActiveObjectBySlug } =
|
||||||
const activeObject = activeObjects.find(
|
useObjectMetadata();
|
||||||
(activeObject) => activeObject.namePlural === pluralObjectName,
|
const activeObject = findActiveObjectBySlug(objectSlug);
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (activeObjects.length && !activeObject) {
|
if (activeObjects.length && !activeObject) {
|
||||||
@ -70,9 +69,7 @@ export const SettingsObjectDetail = () => {
|
|||||||
disableObject(activeObject);
|
disableObject(activeObject);
|
||||||
navigate('/settings/objects');
|
navigate('/settings/objects');
|
||||||
}}
|
}}
|
||||||
onEdit={() =>
|
onEdit={() => navigate('./edit')}
|
||||||
navigate(`/settings/objects/${pluralObjectName}/edit`)
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<Section>
|
<Section>
|
||||||
@ -97,11 +94,7 @@ export const SettingsObjectDetail = () => {
|
|||||||
<SettingsObjectFieldActiveActionDropdown
|
<SettingsObjectFieldActiveActionDropdown
|
||||||
isCustomField={fieldItem.isCustom}
|
isCustomField={fieldItem.isCustom}
|
||||||
scopeKey={fieldItem.id}
|
scopeKey={fieldItem.id}
|
||||||
onEdit={() =>
|
onEdit={() => navigate(`./${fieldItem.name}`)}
|
||||||
navigate(
|
|
||||||
`/settings/objects/${pluralObjectName}/${fieldItem.name}`,
|
|
||||||
)
|
|
||||||
}
|
|
||||||
onDisable={() => disableField(fieldItem)}
|
onDisable={() => disableField(fieldItem)}
|
||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
|
|||||||
@ -2,6 +2,7 @@ import { useEffect, useState } from 'react';
|
|||||||
import { useNavigate, useParams } from 'react-router-dom';
|
import { useNavigate, useParams } from 'react-router-dom';
|
||||||
|
|
||||||
import { useObjectMetadata } from '@/metadata/hooks/useObjectMetadata';
|
import { useObjectMetadata } from '@/metadata/hooks/useObjectMetadata';
|
||||||
|
import { getObjectSlug } from '@/metadata/utils/getObjectSlug';
|
||||||
import { SaveAndCancelButtons } from '@/settings/components/SaveAndCancelButtons/SaveAndCancelButtons';
|
import { SaveAndCancelButtons } from '@/settings/components/SaveAndCancelButtons/SaveAndCancelButtons';
|
||||||
import { SettingsHeaderContainer } from '@/settings/components/SettingsHeaderContainer';
|
import { SettingsHeaderContainer } from '@/settings/components/SettingsHeaderContainer';
|
||||||
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
||||||
@ -18,11 +19,10 @@ import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
|
|||||||
export const SettingsObjectEdit = () => {
|
export const SettingsObjectEdit = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const { pluralObjectName = '' } = useParams();
|
const { objectSlug = '' } = useParams();
|
||||||
const { activeObjects, disableObject, editObject } = useObjectMetadata();
|
const { activeObjects, disableObject, editObject, findActiveObjectBySlug } =
|
||||||
const activeObject = activeObjects.find(
|
useObjectMetadata();
|
||||||
(activeObject) => activeObject.namePlural === pluralObjectName,
|
const activeObject = findActiveObjectBySlug(objectSlug);
|
||||||
);
|
|
||||||
|
|
||||||
const [formValues, setFormValues] = useState<
|
const [formValues, setFormValues] = useState<
|
||||||
Partial<{
|
Partial<{
|
||||||
@ -62,6 +62,16 @@ export const SettingsObjectEdit = () => {
|
|||||||
|
|
||||||
const canSave = areRequiredFieldsFilled && hasChanges;
|
const canSave = areRequiredFieldsFilled && hasChanges;
|
||||||
|
|
||||||
|
const handleSave = async () => {
|
||||||
|
if (!activeObject) return;
|
||||||
|
|
||||||
|
const editedObject = { ...activeObject, ...formValues };
|
||||||
|
|
||||||
|
await editObject(editedObject);
|
||||||
|
|
||||||
|
navigate(`/settings/objects/${getObjectSlug(editedObject)}`);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<SubMenuTopBarContainer Icon={IconSettings} title="Settings">
|
<SubMenuTopBarContainer Icon={IconSettings} title="Settings">
|
||||||
<SettingsPageContainer>
|
<SettingsPageContainer>
|
||||||
@ -71,7 +81,7 @@ export const SettingsObjectEdit = () => {
|
|||||||
{ children: 'Objects', href: '/settings/objects' },
|
{ children: 'Objects', href: '/settings/objects' },
|
||||||
{
|
{
|
||||||
children: activeObject?.labelPlural ?? '',
|
children: activeObject?.labelPlural ?? '',
|
||||||
href: `/settings/objects/${pluralObjectName}`,
|
href: `/settings/objects/${objectSlug}`,
|
||||||
},
|
},
|
||||||
{ children: 'Edit' },
|
{ children: 'Edit' },
|
||||||
]}
|
]}
|
||||||
@ -80,12 +90,9 @@ export const SettingsObjectEdit = () => {
|
|||||||
<SaveAndCancelButtons
|
<SaveAndCancelButtons
|
||||||
isSaveDisabled={!canSave}
|
isSaveDisabled={!canSave}
|
||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
navigate(`/settings/objects/${pluralObjectName}`);
|
navigate(`/settings/objects/${objectSlug}`);
|
||||||
}}
|
|
||||||
onSave={() => {
|
|
||||||
editObject({ ...activeObject, ...formValues });
|
|
||||||
navigate(`/settings/objects/${pluralObjectName}`);
|
|
||||||
}}
|
}}
|
||||||
|
onSave={handleSave}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
</SettingsHeaderContainer>
|
</SettingsHeaderContainer>
|
||||||
|
|||||||
@ -7,7 +7,7 @@ import { SubMenuTopBarContainer } from '@/ui/layout/page/SubMenuTopBarContainer'
|
|||||||
import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
|
import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
|
||||||
|
|
||||||
export const SettingsObjectFieldEdit = () => {
|
export const SettingsObjectFieldEdit = () => {
|
||||||
const { pluralObjectName = '', fieldName = '' } = useParams();
|
const { objectSlug = '', fieldName = '' } = useParams();
|
||||||
return (
|
return (
|
||||||
<SubMenuTopBarContainer Icon={IconSettings} title="Settings">
|
<SubMenuTopBarContainer Icon={IconSettings} title="Settings">
|
||||||
<SettingsPageContainer>
|
<SettingsPageContainer>
|
||||||
@ -16,8 +16,8 @@ export const SettingsObjectFieldEdit = () => {
|
|||||||
links={[
|
links={[
|
||||||
{ children: 'Objects', href: '/settings/objects' },
|
{ children: 'Objects', href: '/settings/objects' },
|
||||||
{
|
{
|
||||||
children: `${pluralObjectName}`,
|
children: `${objectSlug}`,
|
||||||
href: `/settings/objects/${pluralObjectName}`,
|
href: `/settings/objects/${objectSlug}`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
children: `${fieldName}`,
|
children: `${fieldName}`,
|
||||||
|
|||||||
@ -35,11 +35,9 @@ const StyledAddCustomFieldButton = styled(Button)`
|
|||||||
export const SettingsObjectNewFieldStep1 = () => {
|
export const SettingsObjectNewFieldStep1 = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
|
|
||||||
const { pluralObjectName = '' } = useParams();
|
const { objectSlug = '' } = useParams();
|
||||||
const { activeObjects } = useObjectMetadata();
|
const { activeObjects, findActiveObjectBySlug } = useObjectMetadata();
|
||||||
const activeObject = activeObjects.find(
|
const activeObject = findActiveObjectBySlug(objectSlug);
|
||||||
(activeObject) => activeObject.namePlural === pluralObjectName,
|
|
||||||
);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (activeObjects.length && !activeObject) {
|
if (activeObjects.length && !activeObject) {
|
||||||
@ -63,7 +61,7 @@ export const SettingsObjectNewFieldStep1 = () => {
|
|||||||
{ children: 'Objects', href: '/settings/objects' },
|
{ children: 'Objects', href: '/settings/objects' },
|
||||||
{
|
{
|
||||||
children: activeObject?.labelPlural ?? '',
|
children: activeObject?.labelPlural ?? '',
|
||||||
href: `/settings/objects/${pluralObjectName}`,
|
href: `/settings/objects/${objectSlug}`,
|
||||||
},
|
},
|
||||||
{ children: 'New Field' },
|
{ children: 'New Field' },
|
||||||
]}
|
]}
|
||||||
@ -71,7 +69,7 @@ export const SettingsObjectNewFieldStep1 = () => {
|
|||||||
<SaveAndCancelButtons
|
<SaveAndCancelButtons
|
||||||
isSaveDisabled
|
isSaveDisabled
|
||||||
onCancel={() => {
|
onCancel={() => {
|
||||||
navigate(`/settings/objects/${pluralObjectName}`);
|
navigate(`/settings/objects/${objectSlug}`);
|
||||||
}}
|
}}
|
||||||
onSave={() => undefined}
|
onSave={() => undefined}
|
||||||
/>
|
/>
|
||||||
@ -121,7 +119,7 @@ export const SettingsObjectNewFieldStep1 = () => {
|
|||||||
size="small"
|
size="small"
|
||||||
variant="secondary"
|
variant="secondary"
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
navigate(`/settings/objects/${pluralObjectName}/new-field/step-2`)
|
navigate(`/settings/objects/${objectSlug}/new-field/step-2`)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
</StyledSection>
|
</StyledSection>
|
||||||
|
|||||||
@ -15,9 +15,9 @@ import { Breadcrumb } from '@/ui/navigation/bread-crumb/components/Breadcrumb';
|
|||||||
|
|
||||||
export const SettingsObjectNewFieldStep2 = () => {
|
export const SettingsObjectNewFieldStep2 = () => {
|
||||||
const navigate = useNavigate();
|
const navigate = useNavigate();
|
||||||
const { pluralObjectName = '' } = useParams();
|
const { objectSlug = '' } = useParams();
|
||||||
const activeObject = activeObjectItems.find(
|
const activeObject = activeObjectItems.find(
|
||||||
(activeObject) => activeObject.name.toLowerCase() === pluralObjectName,
|
(activeObject) => activeObject.name.toLowerCase() === objectSlug,
|
||||||
);
|
);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
@ -43,7 +43,7 @@ export const SettingsObjectNewFieldStep2 = () => {
|
|||||||
{ children: 'Objects', href: '/settings/objects' },
|
{ children: 'Objects', href: '/settings/objects' },
|
||||||
{
|
{
|
||||||
children: activeObject?.name ?? '',
|
children: activeObject?.name ?? '',
|
||||||
href: `/settings/objects/${pluralObjectName}`,
|
href: `/settings/objects/${objectSlug}`,
|
||||||
},
|
},
|
||||||
{ children: 'New Field' },
|
{ children: 'New Field' },
|
||||||
]}
|
]}
|
||||||
|
|||||||
@ -3,6 +3,7 @@ import { useTheme } from '@emotion/react';
|
|||||||
import styled from '@emotion/styled';
|
import styled from '@emotion/styled';
|
||||||
|
|
||||||
import { useObjectMetadata } from '@/metadata/hooks/useObjectMetadata';
|
import { useObjectMetadata } from '@/metadata/hooks/useObjectMetadata';
|
||||||
|
import { getObjectSlug } from '@/metadata/utils/getObjectSlug';
|
||||||
import { SettingsHeaderContainer } from '@/settings/components/SettingsHeaderContainer';
|
import { SettingsHeaderContainer } from '@/settings/components/SettingsHeaderContainer';
|
||||||
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
import { SettingsPageContainer } from '@/settings/components/SettingsPageContainer';
|
||||||
import {
|
import {
|
||||||
@ -76,7 +77,9 @@ export const SettingsObjects = () => {
|
|||||||
/>
|
/>
|
||||||
}
|
}
|
||||||
onClick={() =>
|
onClick={() =>
|
||||||
navigate(`/settings/objects/${objectItem.namePlural}`)
|
navigate(
|
||||||
|
`/settings/objects/${getObjectSlug(objectItem)}`,
|
||||||
|
)
|
||||||
}
|
}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
|
|||||||
@ -14,8 +14,8 @@ const meta: Meta<PageDecoratorArgs> = {
|
|||||||
component: SettingsObjectDetail,
|
component: SettingsObjectDetail,
|
||||||
decorators: [PageDecorator],
|
decorators: [PageDecorator],
|
||||||
args: {
|
args: {
|
||||||
routePath: '/settings/objects/:pluralObjectName',
|
routePath: '/settings/objects/:objectSlug',
|
||||||
routeParams: { ':pluralObjectName': 'companies' },
|
routeParams: { ':objectSlug': 'companies' },
|
||||||
},
|
},
|
||||||
parameters: {
|
parameters: {
|
||||||
msw: graphqlMocks,
|
msw: graphqlMocks,
|
||||||
|
|||||||
@ -14,8 +14,8 @@ const meta: Meta<PageDecoratorArgs> = {
|
|||||||
component: SettingsObjectEdit,
|
component: SettingsObjectEdit,
|
||||||
decorators: [PageDecorator],
|
decorators: [PageDecorator],
|
||||||
args: {
|
args: {
|
||||||
routePath: '/settings/objects/:pluralObjectName/edit',
|
routePath: '/settings/objects/:objectSlug/edit',
|
||||||
routeParams: { ':pluralObjectName': 'companies' },
|
routeParams: { ':objectSlug': 'companies' },
|
||||||
},
|
},
|
||||||
parameters: {
|
parameters: {
|
||||||
msw: graphqlMocks,
|
msw: graphqlMocks,
|
||||||
|
|||||||
@ -15,8 +15,8 @@ const meta: Meta<PageDecoratorArgs> = {
|
|||||||
component: SettingsObjectNewFieldStep1,
|
component: SettingsObjectNewFieldStep1,
|
||||||
decorators: [PageDecorator],
|
decorators: [PageDecorator],
|
||||||
args: {
|
args: {
|
||||||
routePath: '/settings/objects/:pluralObjectName/new-field/step-1',
|
routePath: '/settings/objects/:objectSlug/new-field/step-1',
|
||||||
routeParams: { ':pluralObjectName': 'companies' },
|
routeParams: { ':objectSlug': 'companies' },
|
||||||
},
|
},
|
||||||
parameters: {
|
parameters: {
|
||||||
msw: graphqlMocks,
|
msw: graphqlMocks,
|
||||||
|
|||||||
@ -15,8 +15,8 @@ const meta: Meta<PageDecoratorArgs> = {
|
|||||||
component: SettingsObjectNewFieldStep2,
|
component: SettingsObjectNewFieldStep2,
|
||||||
decorators: [PageDecorator],
|
decorators: [PageDecorator],
|
||||||
args: {
|
args: {
|
||||||
routePath: '/settings/objects/:pluralObjectName/new-field/step-2',
|
routePath: '/settings/objects/:objectSlug/new-field/step-2',
|
||||||
routeParams: { ':pluralObjectName': 'companies' },
|
routeParams: { ':objectSlug': 'companies' },
|
||||||
},
|
},
|
||||||
parameters: {
|
parameters: {
|
||||||
msw: graphqlMocks,
|
msw: graphqlMocks,
|
||||||
|
|||||||
@ -5628,6 +5628,13 @@
|
|||||||
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
|
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
|
||||||
integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==
|
integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==
|
||||||
|
|
||||||
|
"@types/lodash.camelcase@^4.3.7":
|
||||||
|
version "4.3.8"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/lodash.camelcase/-/lodash.camelcase-4.3.8.tgz#0cbf6b4d13ed2ba94310d114c7bec2d171fe4f44"
|
||||||
|
integrity sha512-jwsvMuU3ntB7w3a4L/oLW24qpBE9fobU5O/uCYWQctlvEOoWkXEgw/fkpY+onmT37IOQMVcVW9UiJ33CZE70ug==
|
||||||
|
dependencies:
|
||||||
|
"@types/lodash" "*"
|
||||||
|
|
||||||
"@types/lodash.debounce@^4.0.7":
|
"@types/lodash.debounce@^4.0.7":
|
||||||
version "4.0.7"
|
version "4.0.7"
|
||||||
resolved "https://registry.yarnpkg.com/@types/lodash.debounce/-/lodash.debounce-4.0.7.tgz#0285879defb7cdb156ae633cecd62d5680eded9f"
|
resolved "https://registry.yarnpkg.com/@types/lodash.debounce/-/lodash.debounce-4.0.7.tgz#0285879defb7cdb156ae633cecd62d5680eded9f"
|
||||||
@ -5635,6 +5642,13 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@types/lodash" "*"
|
"@types/lodash" "*"
|
||||||
|
|
||||||
|
"@types/lodash.kebabcase@^4.1.7":
|
||||||
|
version "4.1.8"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/lodash.kebabcase/-/lodash.kebabcase-4.1.8.tgz#81cf2a1f81f3ea640a3538da43ec54e13b57dfcc"
|
||||||
|
integrity sha512-ZwdT+S6Ejbl2KEw/nunwO63hMzABqzVdWonRMEuhKs0GfwqffaQ3tSJo+/wmDCCaGUHIiObsBFY59GUYjYMk5A==
|
||||||
|
dependencies:
|
||||||
|
"@types/lodash" "*"
|
||||||
|
|
||||||
"@types/lodash.mergewith@4.6.7":
|
"@types/lodash.mergewith@4.6.7":
|
||||||
version "4.6.7"
|
version "4.6.7"
|
||||||
resolved "https://registry.yarnpkg.com/@types/lodash.mergewith/-/lodash.mergewith-4.6.7.tgz#eaa65aa5872abdd282f271eae447b115b2757212"
|
resolved "https://registry.yarnpkg.com/@types/lodash.mergewith/-/lodash.mergewith-4.6.7.tgz#eaa65aa5872abdd282f271eae447b115b2757212"
|
||||||
@ -5642,6 +5656,13 @@
|
|||||||
dependencies:
|
dependencies:
|
||||||
"@types/lodash" "*"
|
"@types/lodash" "*"
|
||||||
|
|
||||||
|
"@types/lodash.upperfirst@^4.3.7":
|
||||||
|
version "4.3.8"
|
||||||
|
resolved "https://registry.yarnpkg.com/@types/lodash.upperfirst/-/lodash.upperfirst-4.3.8.tgz#b488f406f2325f4271c6904f7f9fb560ad6be813"
|
||||||
|
integrity sha512-/R/drl34clakjVOVSgUryl7R18RgAuUWYXKuc3S7Aozw2DW+iqE6hvZJugMtdfzML0fGXs+UCDjafCkctlgIug==
|
||||||
|
dependencies:
|
||||||
|
"@types/lodash" "*"
|
||||||
|
|
||||||
"@types/lodash@*", "@types/lodash@^4.14.167":
|
"@types/lodash@*", "@types/lodash@^4.14.167":
|
||||||
version "4.14.197"
|
version "4.14.197"
|
||||||
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.197.tgz#e95c5ddcc814ec3e84c891910a01e0c8a378c54b"
|
resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.197.tgz#e95c5ddcc814ec3e84c891910a01e0c8a378c54b"
|
||||||
@ -13625,6 +13646,11 @@ locate-path@^7.1.0:
|
|||||||
dependencies:
|
dependencies:
|
||||||
p-locate "^6.0.0"
|
p-locate "^6.0.0"
|
||||||
|
|
||||||
|
lodash.camelcase@^4.3.0:
|
||||||
|
version "4.3.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/lodash.camelcase/-/lodash.camelcase-4.3.0.tgz#b28aa6288a2b9fc651035c7711f65ab6190331a6"
|
||||||
|
integrity sha512-TwuEnCnxbc3rAvhf/LbG7tJUDzhqXyFnv3dtzLOPgCG/hODL7WFnsbwktkD7yUV0RrreP/l1PALq/YSg6VvjlA==
|
||||||
|
|
||||||
lodash.debounce@^4.0.8:
|
lodash.debounce@^4.0.8:
|
||||||
version "4.0.8"
|
version "4.0.8"
|
||||||
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
|
resolved "https://registry.yarnpkg.com/lodash.debounce/-/lodash.debounce-4.0.8.tgz#82d79bff30a67c4005ffd5e2515300ad9ca4d7af"
|
||||||
@ -13635,6 +13661,11 @@ lodash.flattendeep@^4.4.0:
|
|||||||
resolved "https://registry.yarnpkg.com/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz#fb030917f86a3134e5bc9bec0d69e0013ddfedb2"
|
resolved "https://registry.yarnpkg.com/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz#fb030917f86a3134e5bc9bec0d69e0013ddfedb2"
|
||||||
integrity sha512-uHaJFihxmJcEX3kT4I23ABqKKalJ/zDrDg0lsFtc1h+3uw49SIJ5beyhx5ExVRti3AvKoOJngIj7xz3oylPdWQ==
|
integrity sha512-uHaJFihxmJcEX3kT4I23ABqKKalJ/zDrDg0lsFtc1h+3uw49SIJ5beyhx5ExVRti3AvKoOJngIj7xz3oylPdWQ==
|
||||||
|
|
||||||
|
lodash.kebabcase@^4.1.1:
|
||||||
|
version "4.1.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/lodash.kebabcase/-/lodash.kebabcase-4.1.1.tgz#8489b1cb0d29ff88195cceca448ff6d6cc295c36"
|
||||||
|
integrity sha512-N8XRTIMMqqDgSy4VLKPnJ/+hpGZN+PHQiJnSenYqPaVV/NCqEogTnAdZLQiGKhxX+JCs8waWq2t1XHWKOmlY8g==
|
||||||
|
|
||||||
lodash.memoize@4.x, lodash.memoize@^4.1.2:
|
lodash.memoize@4.x, lodash.memoize@^4.1.2:
|
||||||
version "4.1.2"
|
version "4.1.2"
|
||||||
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
|
resolved "https://registry.yarnpkg.com/lodash.memoize/-/lodash.memoize-4.1.2.tgz#bcc6c49a42a2840ed997f323eada5ecd182e0bfe"
|
||||||
@ -13660,6 +13691,11 @@ lodash.uniq@^4.5.0:
|
|||||||
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
|
resolved "https://registry.yarnpkg.com/lodash.uniq/-/lodash.uniq-4.5.0.tgz#d0225373aeb652adc1bc82e4945339a842754773"
|
||||||
integrity sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==
|
integrity sha512-xfBaXQd9ryd9dlSDvnvI0lvxfLJlYAZzXomUYzLKtUeOQvOP5piqAWuGtrhWeqaXK9hhoM/iyJc5AV+XfsX3HQ==
|
||||||
|
|
||||||
|
lodash.upperfirst@^4.3.1:
|
||||||
|
version "4.3.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/lodash.upperfirst/-/lodash.upperfirst-4.3.1.tgz#1365edf431480481ef0d1c68957a5ed99d49f7ce"
|
||||||
|
integrity sha512-sReKOYJIJf74dhJONhU4e0/shzi1trVbSWDOhKYE5XV2O+H7Sb2Dihwuc7xWxVl+DgFPyTqIN3zMfT9cq5iWDg==
|
||||||
|
|
||||||
lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.20, lodash@^4.17.21, lodash@^4.17.4, lodash@^4.7.0, lodash@~4.17.0:
|
lodash@^4.17.14, lodash@^4.17.15, lodash@^4.17.20, lodash@^4.17.21, lodash@^4.17.4, lodash@^4.7.0, lodash@~4.17.0:
|
||||||
version "4.17.21"
|
version "4.17.21"
|
||||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
|
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
|
||||||
|
|||||||
@ -14,6 +14,16 @@ export class UpdateObjectInput {
|
|||||||
@Field({ nullable: true })
|
@Field({ nullable: true })
|
||||||
labelPlural?: string;
|
labelPlural?: string;
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
@IsOptional()
|
||||||
|
@Field({ nullable: true })
|
||||||
|
nameSingular?: string;
|
||||||
|
|
||||||
|
@IsString()
|
||||||
|
@IsOptional()
|
||||||
|
@Field({ nullable: true })
|
||||||
|
namePlural?: string;
|
||||||
|
|
||||||
@IsString()
|
@IsString()
|
||||||
@IsOptional()
|
@IsOptional()
|
||||||
@Field({ nullable: true })
|
@Field({ nullable: true })
|
||||||
|
|||||||
Reference in New Issue
Block a user