@webbio/strapi-plugin-page-builder 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +98 -98
- package/admin/src/api/collection-type.ts +110 -110
- package/admin/src/api/has-page-relation.ts +34 -34
- package/admin/src/api/page-type.ts +31 -31
- package/admin/src/api/template.ts +27 -27
- package/admin/src/components/Combobox/index.tsx +77 -77
- package/admin/src/components/Combobox/react-select-custom-styles.tsx +120 -111
- package/admin/src/components/Combobox/styles.ts +22 -22
- package/admin/src/components/ConfirmModal/index.tsx +90 -90
- package/admin/src/components/EditView/CollectionTypeSearch/index.tsx +124 -124
- package/admin/src/components/EditView/CollectionTypeSettings/CreatePageButton/index.tsx +104 -101
- package/admin/src/components/EditView/CollectionTypeSettings/CreatePageButton/styles.ts +19 -19
- package/admin/src/components/EditView/CollectionTypeSettings/index.tsx +74 -74
- package/admin/src/components/EditView/Details/index.tsx +47 -47
- package/admin/src/components/EditView/Details/styles.ts +51 -51
- package/admin/src/components/EditView/PageSettings/index.tsx +104 -104
- package/admin/src/components/EditView/Template/TemplateConfirmModal/index.tsx +36 -36
- package/admin/src/components/EditView/Template/TemplateSelect/index.tsx +69 -69
- package/admin/src/components/EditView/Template/TemplateSelect/use-template-modules.ts +38 -38
- package/admin/src/components/EditView/index.tsx +29 -29
- package/admin/src/components/EditView/page-type-select.tsx +32 -32
- package/admin/src/components/EditView/wrapper.tsx +35 -35
- package/admin/src/components/Initializer/index.tsx +24 -24
- package/admin/src/components/PageTypeFilter/index.tsx +17 -17
- package/admin/src/components/PageTypeFilter/page-type-filter.tsx +130 -130
- package/admin/src/components/PluginIcon/index.tsx +12 -12
- package/admin/src/constants.ts +3 -3
- package/admin/src/index.tsx +59 -59
- package/admin/src/middlewares/index.tsx +37 -37
- package/admin/src/pluginId.ts +5 -5
- package/admin/src/translations/en.json +6 -6
- package/admin/src/translations/nl.json +6 -6
- package/admin/src/utils/getRequestUrl.ts +11 -11
- package/admin/src/utils/getTrad.ts +5 -5
- package/admin/src/utils/hooks/useDebounce.ts +17 -17
- package/admin/src/utils/hooks/useGetLocaleFromUrl.ts +9 -9
- package/admin/src/utils/hooks/usePrevious.ts +12 -12
- package/admin/src/utils/sanitizeModules.ts +43 -10
- package/custom.d.ts +5 -5
- package/dist/package.json +9 -9
- package/dist/server/graphql/page-by-slug.js +9 -9
- package/dist/server/graphql/pages-by-uid.js +14 -14
- package/dist/server/services/builder.js +7 -4
- package/dist/server/services/template.js +1 -2
- package/dist/server/utils/graphql.js +18 -18
- package/dist/server/utils/strapi.js +1 -4
- package/dist/tsconfig.server.tsbuildinfo +1 -1
- package/package.json +71 -71
- package/server/bootstrap/collection-type-lifecycles.ts +47 -47
- package/server/bootstrap/permissions.ts +42 -42
- package/server/bootstrap.ts +198 -198
- package/server/config/index.ts +4 -4
- package/server/content-types/index.ts +1 -1
- package/server/controllers/collection-types.ts +27 -27
- package/server/controllers/index.ts +11 -11
- package/server/controllers/page-type.ts +13 -13
- package/server/controllers/page.ts +9 -9
- package/server/controllers/template.ts +16 -16
- package/server/destroy.ts +5 -5
- package/server/graphql/index.ts +9 -9
- package/server/graphql/page-by-slug.ts +98 -98
- package/server/graphql/page-type.ts +67 -67
- package/server/graphql/pages-by-uid.ts +127 -127
- package/server/index.ts +23 -23
- package/server/middlewares/index.ts +1 -1
- package/server/policies/index.ts +1 -1
- package/server/register.ts +15 -15
- package/server/routes/index.ts +58 -58
- package/server/schema/page-end.json +91 -91
- package/server/schema/page-start.json +87 -87
- package/server/schema/page-type-end.json +43 -43
- package/server/schema/page-type-start.json +38 -38
- package/server/schema/template-start.json +35 -35
- package/server/services/builder.ts +137 -134
- package/server/services/collection-types.ts +88 -88
- package/server/services/index.ts +13 -13
- package/server/services/page-type.ts +26 -26
- package/server/services/page.ts +24 -24
- package/server/services/template.ts +13 -14
- package/server/utils/filter-underscore-arguments.ts +12 -12
- package/server/utils/graphql.ts +113 -113
- package/server/utils/paginationValidation.ts +39 -39
- package/server/utils/reload-strapi-on-load.ts +13 -13
- package/server/utils/strapi.ts +45 -49
- package/shared/utils/constants.ts +4 -4
- package/shared/utils/sleep.ts +1 -1
- package/strapi-admin.js +3 -3
- package/strapi-server.js +3 -3
- package/tsconfig.json +20 -20
- package/tsconfig.server.json +25 -25
- package/dist/server/controllers/platform.js +0 -20
- package/dist/server/schema/platform-start.json +0 -31
- package/dist/server/services/platform.js +0 -36
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
|
|
3
|
-
import { Flex } from '@strapi/design-system';
|
|
4
|
-
import { Link } from '@strapi/icons';
|
|
5
|
-
|
|
6
|
-
import { PageType } from '../../../api/page-type';
|
|
7
|
-
import { PAGE_TYPE_PAGE } from '../../../../../shared/utils/constants';
|
|
8
|
-
import S from './styles';
|
|
9
|
-
|
|
10
|
-
interface Props {
|
|
11
|
-
pageType?: PageType | null;
|
|
12
|
-
entityId?: number;
|
|
13
|
-
entityTitle?: string;
|
|
14
|
-
locale?: string;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
const Details = (props: Props) => {
|
|
18
|
-
const { entityTitle, pageType } = props;
|
|
19
|
-
|
|
20
|
-
const url = generateLink(props);
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<Flex gap={4} width="100%" direction="column">
|
|
24
|
-
<Flex direction="column" alignItems="start" width="100%" gap={1}>
|
|
25
|
-
<S.SubtleType variant="omega" fontWeight="bold" textColor="neutral800">
|
|
26
|
-
{pageType?.title || PAGE_TYPE_PAGE}
|
|
27
|
-
</S.SubtleType>
|
|
28
|
-
<S.EntityLinkWrapper variant="pi" textColor="neutral800">
|
|
29
|
-
<S.EntityLink title={entityTitle} to={url} variant="pi">
|
|
30
|
-
<Link />
|
|
31
|
-
{entityTitle}
|
|
32
|
-
</S.EntityLink>
|
|
33
|
-
</S.EntityLinkWrapper>
|
|
34
|
-
</Flex>
|
|
35
|
-
</Flex>
|
|
36
|
-
);
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
export { Details };
|
|
40
|
-
|
|
41
|
-
const generateLink = ({ locale, pageType, entityId }: Props) => {
|
|
42
|
-
if (!pageType?.uid || !entityId) {
|
|
43
|
-
return '';
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return `/content-manager/collectionType/${pageType.uid}/${entityId}?plugins[i18n][locale]=${locale}`;
|
|
47
|
-
};
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { Flex } from '@strapi/design-system';
|
|
4
|
+
import { Link } from '@strapi/icons';
|
|
5
|
+
|
|
6
|
+
import { PageType } from '../../../api/page-type';
|
|
7
|
+
import { PAGE_TYPE_PAGE } from '../../../../../shared/utils/constants';
|
|
8
|
+
import S from './styles';
|
|
9
|
+
|
|
10
|
+
interface Props {
|
|
11
|
+
pageType?: PageType | null;
|
|
12
|
+
entityId?: number;
|
|
13
|
+
entityTitle?: string;
|
|
14
|
+
locale?: string;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const Details = (props: Props) => {
|
|
18
|
+
const { entityTitle, pageType } = props;
|
|
19
|
+
|
|
20
|
+
const url = generateLink(props);
|
|
21
|
+
|
|
22
|
+
return (
|
|
23
|
+
<Flex gap={4} width="100%" direction="column">
|
|
24
|
+
<Flex direction="column" alignItems="start" width="100%" gap={1}>
|
|
25
|
+
<S.SubtleType variant="omega" fontWeight="bold" textColor="neutral800">
|
|
26
|
+
{pageType?.title || PAGE_TYPE_PAGE}
|
|
27
|
+
</S.SubtleType>
|
|
28
|
+
<S.EntityLinkWrapper variant="pi" textColor="neutral800">
|
|
29
|
+
<S.EntityLink title={entityTitle} to={url} variant="pi">
|
|
30
|
+
<Link />
|
|
31
|
+
{entityTitle}
|
|
32
|
+
</S.EntityLink>
|
|
33
|
+
</S.EntityLinkWrapper>
|
|
34
|
+
</Flex>
|
|
35
|
+
</Flex>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export { Details };
|
|
40
|
+
|
|
41
|
+
const generateLink = ({ locale, pageType, entityId }: Props) => {
|
|
42
|
+
if (!pageType?.uid || !entityId) {
|
|
43
|
+
return '';
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return `/content-manager/collectionType/${pageType.uid}/${entityId}?plugins[i18n][locale]=${locale}`;
|
|
47
|
+
};
|
|
@@ -1,51 +1,51 @@
|
|
|
1
|
-
import styled, { css } from 'styled-components';
|
|
2
|
-
|
|
3
|
-
import { Typography, Link, Button } from '@strapi/design-system';
|
|
4
|
-
|
|
5
|
-
const SubtleType = styled(Typography)`
|
|
6
|
-
${({ _theme }) => css`
|
|
7
|
-
text-transform: capitalize;
|
|
8
|
-
`}
|
|
9
|
-
`;
|
|
10
|
-
|
|
11
|
-
const EntityLinkWrapper = styled(Typography)`
|
|
12
|
-
${({ _theme }) => css`
|
|
13
|
-
display: flex;
|
|
14
|
-
`}
|
|
15
|
-
`;
|
|
16
|
-
|
|
17
|
-
const EntityLink = styled(Link)`
|
|
18
|
-
${({ _theme }) => css`
|
|
19
|
-
span {
|
|
20
|
-
line-height: 1.2;
|
|
21
|
-
font-size: inherit;
|
|
22
|
-
display: flex;
|
|
23
|
-
gap: 4px;
|
|
24
|
-
align-items: center;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
svg {
|
|
28
|
-
width: 0.7rem;
|
|
29
|
-
height: 0.7rem;
|
|
30
|
-
}
|
|
31
|
-
`}
|
|
32
|
-
`;
|
|
33
|
-
|
|
34
|
-
const EditLink = styled(Button)`
|
|
35
|
-
${({ _theme }) => css`
|
|
36
|
-
text-decoration: none;
|
|
37
|
-
|
|
38
|
-
svg {
|
|
39
|
-
flex-shrink: 0;
|
|
40
|
-
}
|
|
41
|
-
`}
|
|
42
|
-
`;
|
|
43
|
-
|
|
44
|
-
const DetailsStyles = {
|
|
45
|
-
SubtleType,
|
|
46
|
-
EntityLink,
|
|
47
|
-
EntityLinkWrapper,
|
|
48
|
-
EditLink
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
export default DetailsStyles;
|
|
1
|
+
import styled, { css } from 'styled-components';
|
|
2
|
+
|
|
3
|
+
import { Typography, Link, Button } from '@strapi/design-system';
|
|
4
|
+
|
|
5
|
+
const SubtleType = styled(Typography)`
|
|
6
|
+
${({ _theme }) => css`
|
|
7
|
+
text-transform: capitalize;
|
|
8
|
+
`}
|
|
9
|
+
`;
|
|
10
|
+
|
|
11
|
+
const EntityLinkWrapper = styled(Typography)`
|
|
12
|
+
${({ _theme }) => css`
|
|
13
|
+
display: flex;
|
|
14
|
+
`}
|
|
15
|
+
`;
|
|
16
|
+
|
|
17
|
+
const EntityLink = styled(Link)`
|
|
18
|
+
${({ _theme }) => css`
|
|
19
|
+
span {
|
|
20
|
+
line-height: 1.2;
|
|
21
|
+
font-size: inherit;
|
|
22
|
+
display: flex;
|
|
23
|
+
gap: 4px;
|
|
24
|
+
align-items: center;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
svg {
|
|
28
|
+
width: 0.7rem;
|
|
29
|
+
height: 0.7rem;
|
|
30
|
+
}
|
|
31
|
+
`}
|
|
32
|
+
`;
|
|
33
|
+
|
|
34
|
+
const EditLink = styled(Button)`
|
|
35
|
+
${({ _theme }) => css`
|
|
36
|
+
text-decoration: none;
|
|
37
|
+
|
|
38
|
+
svg {
|
|
39
|
+
flex-shrink: 0;
|
|
40
|
+
}
|
|
41
|
+
`}
|
|
42
|
+
`;
|
|
43
|
+
|
|
44
|
+
const DetailsStyles = {
|
|
45
|
+
SubtleType,
|
|
46
|
+
EntityLink,
|
|
47
|
+
EntityLinkWrapper,
|
|
48
|
+
EditLink
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export default DetailsStyles;
|
|
@@ -1,104 +1,104 @@
|
|
|
1
|
-
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
|
-
|
|
3
|
-
import { useCMEditViewDataManager } from '@strapi/helper-plugin';
|
|
4
|
-
import { Stack, Flex } from '@strapi/design-system';
|
|
5
|
-
import { Cog, Cross } from '@strapi/icons';
|
|
6
|
-
|
|
7
|
-
import { TemplateSelect } from '../Template/TemplateSelect';
|
|
8
|
-
import { PageTypeSelect } from '../page-type-select';
|
|
9
|
-
import { CollectionTypeSearch } from '../CollectionTypeSearch';
|
|
10
|
-
import { Wrapper } from '../wrapper';
|
|
11
|
-
import { PageType, useGetPageTypes } from '../../../api/page-type';
|
|
12
|
-
import { Details } from '../Details';
|
|
13
|
-
import S from '../Details/styles';
|
|
14
|
-
|
|
15
|
-
export const PageSettings = () => {
|
|
16
|
-
const { isCreatingEntry, initialData, onChange, modifiedData } = useCMEditViewDataManager();
|
|
17
|
-
const { data: pageTypes } = useGetPageTypes({});
|
|
18
|
-
const [selectedPageType, setSelectedPageType] = useState<PageType | undefined | null>(initialData?.initialPageType);
|
|
19
|
-
const [isEditting, setIsEditting] = useState(false);
|
|
20
|
-
const showEditFields = useMemo(
|
|
21
|
-
() => isCreatingEntry || !selectedPageType?.id || !initialData.collectionTypeTitle || isEditting,
|
|
22
|
-
[isCreatingEntry, isEditting, selectedPageType, initialData]
|
|
23
|
-
);
|
|
24
|
-
|
|
25
|
-
const setFormValue = (name: string, value?: string | Record<string, any>[]) => {
|
|
26
|
-
onChange({
|
|
27
|
-
target: {
|
|
28
|
-
name,
|
|
29
|
-
value
|
|
30
|
-
},
|
|
31
|
-
shouldSetInitialValue: true
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
|
|
35
|
-
useEffect(() => {
|
|
36
|
-
setSelectedPageType(initialData?.initialPageType);
|
|
37
|
-
|
|
38
|
-
setIsEditting(false);
|
|
39
|
-
}, [initialData]);
|
|
40
|
-
|
|
41
|
-
const cancelEdit = () => {
|
|
42
|
-
setIsEditting(false);
|
|
43
|
-
setSelectedPageType(initialData?.initialPageType || []);
|
|
44
|
-
setFormValue('pageType', initialData?.initialPageType || []);
|
|
45
|
-
setFormValue('collectionTypeTitle', initialData?.collectionTypeTitle);
|
|
46
|
-
setFormValue('collectionTypeId', initialData?.collectionTypeId);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
const removePageType = () => {
|
|
50
|
-
setSelectedPageType(undefined);
|
|
51
|
-
setFormValue('pageType', []);
|
|
52
|
-
setFormValue('collectionTypeTitle', undefined);
|
|
53
|
-
setFormValue('collectionTypeId', undefined);
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const handleSelectPageType = (pageTypeId: string) => {
|
|
57
|
-
const pageType = pageTypes?.find((pageType) => pageType.id === Number(pageTypeId));
|
|
58
|
-
|
|
59
|
-
if (pageType) {
|
|
60
|
-
setSelectedPageType(pageType);
|
|
61
|
-
const formPageType = {
|
|
62
|
-
...pageType,
|
|
63
|
-
mainField: pageType.uid,
|
|
64
|
-
label: pageType.uid,
|
|
65
|
-
value: pageType.id
|
|
66
|
-
};
|
|
67
|
-
setFormValue('pageType', [formPageType]);
|
|
68
|
-
} else {
|
|
69
|
-
removePageType();
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
return (
|
|
74
|
-
<Wrapper title="Gekoppelde type">
|
|
75
|
-
<Flex direction="column" gap={4} width="100%">
|
|
76
|
-
{showEditFields ? (
|
|
77
|
-
<Stack spacing={4} width="100%">
|
|
78
|
-
<PageTypeSelect pageTypes={pageTypes} selectedPageType={selectedPageType} onChange={handleSelectPageType} />
|
|
79
|
-
<TemplateSelect />
|
|
80
|
-
{selectedPageType?.uid && <CollectionTypeSearch uid={selectedPageType.uid} />}
|
|
81
|
-
</Stack>
|
|
82
|
-
) : (
|
|
83
|
-
<Details
|
|
84
|
-
locale={initialData?.locale}
|
|
85
|
-
pageType={selectedPageType}
|
|
86
|
-
entityId={modifiedData.collectionTypeId}
|
|
87
|
-
entityTitle={modifiedData.collectionTypeTitle}
|
|
88
|
-
/>
|
|
89
|
-
)}
|
|
90
|
-
{(!showEditFields || isEditting) && (
|
|
91
|
-
<S.EditLink
|
|
92
|
-
onClick={() => (isEditting ? cancelEdit() : setIsEditting(true))}
|
|
93
|
-
size="S"
|
|
94
|
-
variant={isEditting ? 'danger-light' : 'secondary'}
|
|
95
|
-
startIcon={isEditting ? <Cross /> : <Cog />}
|
|
96
|
-
width="100%"
|
|
97
|
-
>
|
|
98
|
-
{isEditting ? 'Annuleer bewerking' : 'Bewerk koppeling'}
|
|
99
|
-
</S.EditLink>
|
|
100
|
-
)}
|
|
101
|
-
</Flex>
|
|
102
|
-
</Wrapper>
|
|
103
|
-
);
|
|
104
|
-
};
|
|
1
|
+
import React, { useEffect, useMemo, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { useCMEditViewDataManager } from '@strapi/helper-plugin';
|
|
4
|
+
import { Stack, Flex } from '@strapi/design-system';
|
|
5
|
+
import { Cog, Cross } from '@strapi/icons';
|
|
6
|
+
|
|
7
|
+
import { TemplateSelect } from '../Template/TemplateSelect';
|
|
8
|
+
import { PageTypeSelect } from '../page-type-select';
|
|
9
|
+
import { CollectionTypeSearch } from '../CollectionTypeSearch';
|
|
10
|
+
import { Wrapper } from '../wrapper';
|
|
11
|
+
import { PageType, useGetPageTypes } from '../../../api/page-type';
|
|
12
|
+
import { Details } from '../Details';
|
|
13
|
+
import S from '../Details/styles';
|
|
14
|
+
|
|
15
|
+
export const PageSettings = () => {
|
|
16
|
+
const { isCreatingEntry, initialData, onChange, modifiedData } = useCMEditViewDataManager() as any;
|
|
17
|
+
const { data: pageTypes } = useGetPageTypes({});
|
|
18
|
+
const [selectedPageType, setSelectedPageType] = useState<PageType | undefined | null>(initialData?.initialPageType);
|
|
19
|
+
const [isEditting, setIsEditting] = useState(false);
|
|
20
|
+
const showEditFields = useMemo(
|
|
21
|
+
() => isCreatingEntry || !selectedPageType?.id || !initialData.collectionTypeTitle || isEditting,
|
|
22
|
+
[isCreatingEntry, isEditting, selectedPageType, initialData]
|
|
23
|
+
);
|
|
24
|
+
|
|
25
|
+
const setFormValue = (name: string, value?: string | Record<string, any>[]) => {
|
|
26
|
+
onChange({
|
|
27
|
+
target: {
|
|
28
|
+
name,
|
|
29
|
+
value
|
|
30
|
+
},
|
|
31
|
+
shouldSetInitialValue: true
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
setSelectedPageType(initialData?.initialPageType);
|
|
37
|
+
|
|
38
|
+
setIsEditting(false);
|
|
39
|
+
}, [initialData]);
|
|
40
|
+
|
|
41
|
+
const cancelEdit = () => {
|
|
42
|
+
setIsEditting(false);
|
|
43
|
+
setSelectedPageType(initialData?.initialPageType || []);
|
|
44
|
+
setFormValue('pageType', initialData?.initialPageType || []);
|
|
45
|
+
setFormValue('collectionTypeTitle', initialData?.collectionTypeTitle);
|
|
46
|
+
setFormValue('collectionTypeId', initialData?.collectionTypeId);
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
const removePageType = () => {
|
|
50
|
+
setSelectedPageType(undefined);
|
|
51
|
+
setFormValue('pageType', []);
|
|
52
|
+
setFormValue('collectionTypeTitle', undefined);
|
|
53
|
+
setFormValue('collectionTypeId', undefined);
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const handleSelectPageType = (pageTypeId: string) => {
|
|
57
|
+
const pageType = pageTypes?.find((pageType) => pageType.id === Number(pageTypeId));
|
|
58
|
+
|
|
59
|
+
if (pageType) {
|
|
60
|
+
setSelectedPageType(pageType);
|
|
61
|
+
const formPageType = {
|
|
62
|
+
...pageType,
|
|
63
|
+
mainField: pageType.uid,
|
|
64
|
+
label: pageType.uid,
|
|
65
|
+
value: pageType.id
|
|
66
|
+
};
|
|
67
|
+
setFormValue('pageType', [formPageType]);
|
|
68
|
+
} else {
|
|
69
|
+
removePageType();
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
return (
|
|
74
|
+
<Wrapper title="Gekoppelde type">
|
|
75
|
+
<Flex direction="column" gap={4} width="100%">
|
|
76
|
+
{showEditFields ? (
|
|
77
|
+
<Stack spacing={4} width="100%">
|
|
78
|
+
<PageTypeSelect pageTypes={pageTypes} selectedPageType={selectedPageType} onChange={handleSelectPageType} />
|
|
79
|
+
<TemplateSelect />
|
|
80
|
+
{selectedPageType?.uid && <CollectionTypeSearch uid={selectedPageType.uid} />}
|
|
81
|
+
</Stack>
|
|
82
|
+
) : (
|
|
83
|
+
<Details
|
|
84
|
+
locale={initialData?.locale}
|
|
85
|
+
pageType={selectedPageType}
|
|
86
|
+
entityId={modifiedData.collectionTypeId}
|
|
87
|
+
entityTitle={modifiedData.collectionTypeTitle}
|
|
88
|
+
/>
|
|
89
|
+
)}
|
|
90
|
+
{(!showEditFields || isEditting) && (
|
|
91
|
+
<S.EditLink
|
|
92
|
+
onClick={() => (isEditting ? cancelEdit() : setIsEditting(true))}
|
|
93
|
+
size="S"
|
|
94
|
+
variant={isEditting ? 'danger-light' : 'secondary'}
|
|
95
|
+
startIcon={isEditting ? <Cross /> : <Cog />}
|
|
96
|
+
width="100%"
|
|
97
|
+
>
|
|
98
|
+
{isEditting ? 'Annuleer bewerking' : 'Bewerk koppeling'}
|
|
99
|
+
</S.EditLink>
|
|
100
|
+
)}
|
|
101
|
+
</Flex>
|
|
102
|
+
</Wrapper>
|
|
103
|
+
);
|
|
104
|
+
};
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { useIntl } from 'react-intl';
|
|
3
|
-
|
|
4
|
-
import { Icon, Flex } from '@strapi/design-system';
|
|
5
|
-
import { Rotate } from '@strapi/icons';
|
|
6
|
-
|
|
7
|
-
import getTrad from '../../../../utils/getTrad';
|
|
8
|
-
import ConfirmModal, { IConfirmModalProps } from '../../../ConfirmModal';
|
|
9
|
-
|
|
10
|
-
interface ITemplateConfirmModalProps extends IConfirmModalProps {}
|
|
11
|
-
|
|
12
|
-
const TemplateConfirmModal = (props: ITemplateConfirmModalProps): JSX.Element => {
|
|
13
|
-
const { formatMessage } = useIntl();
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<ConfirmModal
|
|
17
|
-
{...props}
|
|
18
|
-
title={
|
|
19
|
-
<Flex gap={4}>
|
|
20
|
-
<Icon as={Rotate} color="neutral900" width={4} height={4} />
|
|
21
|
-
{formatMessage({
|
|
22
|
-
id: getTrad('template.confirmModal.title')
|
|
23
|
-
})}
|
|
24
|
-
</Flex>
|
|
25
|
-
}
|
|
26
|
-
body={formatMessage({
|
|
27
|
-
id: getTrad('template.confirmModal.body')
|
|
28
|
-
})}
|
|
29
|
-
submitText={formatMessage({
|
|
30
|
-
id: getTrad('template.confirmModal.buttons.submit')
|
|
31
|
-
})}
|
|
32
|
-
/>
|
|
33
|
-
);
|
|
34
|
-
};
|
|
35
|
-
|
|
36
|
-
export default TemplateConfirmModal;
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
|
|
4
|
+
import { Icon, Flex } from '@strapi/design-system';
|
|
5
|
+
import { Rotate } from '@strapi/icons';
|
|
6
|
+
|
|
7
|
+
import getTrad from '../../../../utils/getTrad';
|
|
8
|
+
import ConfirmModal, { IConfirmModalProps } from '../../../ConfirmModal';
|
|
9
|
+
|
|
10
|
+
interface ITemplateConfirmModalProps extends IConfirmModalProps {}
|
|
11
|
+
|
|
12
|
+
const TemplateConfirmModal = (props: ITemplateConfirmModalProps): JSX.Element => {
|
|
13
|
+
const { formatMessage } = useIntl();
|
|
14
|
+
|
|
15
|
+
return (
|
|
16
|
+
<ConfirmModal
|
|
17
|
+
{...props}
|
|
18
|
+
title={
|
|
19
|
+
<Flex gap={4}>
|
|
20
|
+
<Icon as={Rotate} color="neutral900" width={4} height={4} />
|
|
21
|
+
{formatMessage({
|
|
22
|
+
id: getTrad('template.confirmModal.title')
|
|
23
|
+
})}
|
|
24
|
+
</Flex>
|
|
25
|
+
}
|
|
26
|
+
body={formatMessage({
|
|
27
|
+
id: getTrad('template.confirmModal.body')
|
|
28
|
+
})}
|
|
29
|
+
submitText={formatMessage({
|
|
30
|
+
id: getTrad('template.confirmModal.buttons.submit')
|
|
31
|
+
})}
|
|
32
|
+
/>
|
|
33
|
+
);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default TemplateConfirmModal;
|
|
@@ -1,69 +1,69 @@
|
|
|
1
|
-
import React, { useEffect, useState } from 'react';
|
|
2
|
-
import { SingleSelect, SingleSelectOption } from '@strapi/design-system';
|
|
3
|
-
import { useCMEditViewDataManager } from '@strapi/helper-plugin';
|
|
4
|
-
import { Template } from '../../../../api/template';
|
|
5
|
-
import TemplateConfirmModal from '../TemplateConfirmModal';
|
|
6
|
-
import { useTemplateModules } from './use-template-modules';
|
|
7
|
-
|
|
8
|
-
interface Props {
|
|
9
|
-
disabled?: boolean;
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export const TemplateSelect = ({ disabled }: Props) => {
|
|
13
|
-
const { onChange, modifiedData } = useCMEditViewDataManager();
|
|
14
|
-
const [selectedTemplate, setSelectedTemplate] = useState<Template | null>(null);
|
|
15
|
-
const { templates, replaceContentTypeModules } = useTemplateModules(onChange);
|
|
16
|
-
const [templateIdToSelect, setTemplateIdToSelect] = useState<string | undefined>();
|
|
17
|
-
|
|
18
|
-
const handleSelectChange = (templateId?: string) => {
|
|
19
|
-
setTemplateIdToSelect(templateId);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const handleSelectTemplate = (templateId?: string) => {
|
|
23
|
-
const template = templates?.find((template) => template.id === Number(templateId));
|
|
24
|
-
template == null ? setSelectedTemplate(null) : setSelectedTemplate(template);
|
|
25
|
-
|
|
26
|
-
setTemplateIdToSelect(undefined);
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
const noModules = getHasModules(modifiedData?.modules);
|
|
31
|
-
|
|
32
|
-
const template = templates?.find((template) => template.id === Number(modifiedData?.pageType?.[0]?.templateId));
|
|
33
|
-
if (template && noModules) {
|
|
34
|
-
setSelectedTemplate(template);
|
|
35
|
-
}
|
|
36
|
-
}, [modifiedData?.pageType]);
|
|
37
|
-
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
if (selectedTemplate !== null) {
|
|
40
|
-
replaceContentTypeModules(selectedTemplate.id);
|
|
41
|
-
}
|
|
42
|
-
}, [selectedTemplate]);
|
|
43
|
-
|
|
44
|
-
return (
|
|
45
|
-
<>
|
|
46
|
-
<SingleSelect
|
|
47
|
-
label="Template"
|
|
48
|
-
placeholder="Choose a template"
|
|
49
|
-
value={selectedTemplate?.id || 0}
|
|
50
|
-
onChange={handleSelectChange}
|
|
51
|
-
disabled={disabled}
|
|
52
|
-
>
|
|
53
|
-
<SingleSelectOption value={0}>None</SingleSelectOption>
|
|
54
|
-
{templates?.map((template) => (
|
|
55
|
-
<SingleSelectOption key={template.id} value={template.id}>
|
|
56
|
-
{template.title}
|
|
57
|
-
</SingleSelectOption>
|
|
58
|
-
))}
|
|
59
|
-
</SingleSelect>
|
|
60
|
-
<TemplateConfirmModal
|
|
61
|
-
isOpen={Boolean(templateIdToSelect)}
|
|
62
|
-
onSubmit={() => handleSelectTemplate(templateIdToSelect)}
|
|
63
|
-
closeModal={() => setTemplateIdToSelect(undefined)}
|
|
64
|
-
/>
|
|
65
|
-
</>
|
|
66
|
-
);
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
const getHasModules = (modules: any[]): boolean => (modules?.length || 0) === 0;
|
|
1
|
+
import React, { useEffect, useState } from 'react';
|
|
2
|
+
import { SingleSelect, SingleSelectOption } from '@strapi/design-system';
|
|
3
|
+
import { useCMEditViewDataManager } from '@strapi/helper-plugin';
|
|
4
|
+
import { Template } from '../../../../api/template';
|
|
5
|
+
import TemplateConfirmModal from '../TemplateConfirmModal';
|
|
6
|
+
import { useTemplateModules } from './use-template-modules';
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
disabled?: boolean;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export const TemplateSelect = ({ disabled }: Props) => {
|
|
13
|
+
const { onChange, modifiedData } = useCMEditViewDataManager() as any;
|
|
14
|
+
const [selectedTemplate, setSelectedTemplate] = useState<Template | null>(null);
|
|
15
|
+
const { templates, replaceContentTypeModules } = useTemplateModules(onChange);
|
|
16
|
+
const [templateIdToSelect, setTemplateIdToSelect] = useState<string | undefined>();
|
|
17
|
+
|
|
18
|
+
const handleSelectChange = (templateId?: string) => {
|
|
19
|
+
setTemplateIdToSelect(templateId);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const handleSelectTemplate = (templateId?: string) => {
|
|
23
|
+
const template = templates?.find((template) => template.id === Number(templateId));
|
|
24
|
+
template == null ? setSelectedTemplate(null) : setSelectedTemplate(template);
|
|
25
|
+
|
|
26
|
+
setTemplateIdToSelect(undefined);
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
const noModules = getHasModules(modifiedData?.modules);
|
|
31
|
+
|
|
32
|
+
const template = templates?.find((template) => template.id === Number(modifiedData?.pageType?.[0]?.templateId));
|
|
33
|
+
if (template && noModules) {
|
|
34
|
+
setSelectedTemplate(template);
|
|
35
|
+
}
|
|
36
|
+
}, [modifiedData?.pageType]);
|
|
37
|
+
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
if (selectedTemplate !== null) {
|
|
40
|
+
replaceContentTypeModules(selectedTemplate.id);
|
|
41
|
+
}
|
|
42
|
+
}, [selectedTemplate]);
|
|
43
|
+
|
|
44
|
+
return (
|
|
45
|
+
<>
|
|
46
|
+
<SingleSelect
|
|
47
|
+
label="Template"
|
|
48
|
+
placeholder="Choose a template"
|
|
49
|
+
value={selectedTemplate?.id || 0}
|
|
50
|
+
onChange={handleSelectChange}
|
|
51
|
+
disabled={Boolean(disabled)}
|
|
52
|
+
>
|
|
53
|
+
<SingleSelectOption value={0}>None</SingleSelectOption>
|
|
54
|
+
{templates?.map((template) => (
|
|
55
|
+
<SingleSelectOption key={template.id} value={template.id}>
|
|
56
|
+
{template.title}
|
|
57
|
+
</SingleSelectOption>
|
|
58
|
+
))}
|
|
59
|
+
</SingleSelect>
|
|
60
|
+
<TemplateConfirmModal
|
|
61
|
+
isOpen={Boolean(templateIdToSelect)}
|
|
62
|
+
onSubmit={() => handleSelectTemplate(templateIdToSelect)}
|
|
63
|
+
closeModal={() => setTemplateIdToSelect(undefined)}
|
|
64
|
+
/>
|
|
65
|
+
</>
|
|
66
|
+
);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
const getHasModules = (modules: any[]): boolean => (modules?.length || 0) === 0;
|