@webbio/strapi-plugin-page-builder 0.2.1 → 0.3.0
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 +6 -18
- package/admin/src/api/collection-type.ts +7 -1
- package/admin/src/api/platform.ts +34 -0
- package/admin/src/components/Combobox/react-select-custom-styles.tsx +12 -3
- package/admin/src/components/EditView/CollectionTypeSearch/index.tsx +17 -14
- package/admin/src/components/EditView/CollectionTypeSettings/CreatePageButton/index.tsx +5 -1
- package/admin/src/components/EditView/CollectionTypeSettings/index.tsx +5 -15
- package/admin/src/components/EditView/PageSettings/index.tsx +57 -6
- package/admin/src/components/EditView/Platform/platform-select.tsx +30 -0
- package/admin/src/components/EditView/Template/TemplateSelect/index.tsx +2 -2
- package/admin/src/components/EditView/index.tsx +1 -1
- package/admin/src/components/EditView/page-type-select.tsx +1 -1
- package/admin/src/components/PageFilters/PageTypeFilter/index.tsx +39 -0
- package/admin/src/components/PageFilters/PlatformFilter/index.tsx +28 -0
- package/admin/src/components/PageFilters/filters.tsx +180 -0
- package/admin/src/components/PageFilters/index.tsx +30 -0
- package/admin/src/index.tsx +2 -2
- package/admin/src/utils/hooks/useGetLocaleFromUrl.ts +1 -1
- package/dist/package.json +5 -6
- package/dist/server/bootstrap.js +15 -5
- package/dist/server/controllers/index.js +3 -1
- package/dist/server/graphql/pages-by-uid.js +1 -2
- package/dist/server/routes/index.js +21 -0
- package/dist/server/schema/page-end.json +5 -0
- package/dist/server/services/builder.js +22 -7
- package/dist/server/services/index.js +3 -1
- package/dist/shared/utils/constants.js +3 -1
- package/dist/tsconfig.server.tsbuildinfo +1 -1
- package/package.json +5 -6
- package/server/bootstrap/collection-type-lifecycles.ts +1 -1
- package/server/bootstrap.ts +18 -3
- package/server/controllers/index.ts +3 -1
- package/server/controllers/platform.ts +21 -0
- package/server/graphql/pages-by-uid.ts +1 -2
- package/server/routes/index.ts +21 -0
- package/server/schema/page-end.json +5 -0
- package/server/schema/platform-start.json +31 -0
- package/server/services/builder.ts +24 -8
- package/server/services/index.ts +3 -1
- package/server/services/platform.ts +36 -0
- package/shared/utils/constants.ts +2 -0
- package/admin/src/components/PageTypeFilter/index.tsx +0 -17
- package/admin/src/components/PageTypeFilter/page-type-filter.tsx +0 -130
package/README.md
CHANGED
|
@@ -60,31 +60,19 @@ Om wijzigignen aan te brengen in een platform, moeten deze in de schema aangepas
|
|
|
60
60
|
Voor elk collectiontype die je wil toevoegen aan het platform, moet deze relatie toegevoegd worden:
|
|
61
61
|
|
|
62
62
|
```
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
}
|
|
69
|
-
```
|
|
70
|
-
|
|
71
|
-
bijvoorbeeld :
|
|
72
|
-
|
|
73
|
-
```
|
|
74
|
-
"faqs": {
|
|
75
|
-
"type": "relation",
|
|
76
|
-
"relation": "oneToMany",
|
|
77
|
-
"target": "api::faq.faq",
|
|
78
|
-
"mappedBy": "platform"
|
|
79
|
-
}
|
|
63
|
+
"platform": {
|
|
64
|
+
"type": "relation",
|
|
65
|
+
"relation": "oneToOne",
|
|
66
|
+
"target": "api::platform.platform"
|
|
67
|
+
}
|
|
80
68
|
```
|
|
81
69
|
|
|
82
70
|
Een platform zit altijd aan een pagina gekoppeld. Deze moet handmatig in de pagina toegevoegd worden.
|
|
83
71
|
|
|
84
72
|
# Known bugs
|
|
85
73
|
|
|
86
|
-
- Bij het opslaan van een collectietype wil de gekoppelde pagina of type in het ui wel eens verdwijnen.
|
|
87
74
|
- Na het ontkoppelen en opslaan van een collectie item op een pagina, staat deze nog als "Geselecteerd" in de dropdown.
|
|
75
|
+
- Sorteren op pages binnen een collectie type kan niet. Dus stel ik haal alle FAQ's op waarbij ik wil sorteren op een property op de page, kan dat niet.
|
|
88
76
|
|
|
89
77
|
# Improvements
|
|
90
78
|
|
|
@@ -26,6 +26,7 @@ type SearchEntitiesQueryParams = {
|
|
|
26
26
|
searchQuery?: string;
|
|
27
27
|
currentCollectionTypeId?: number;
|
|
28
28
|
currentPageId?: number;
|
|
29
|
+
platformTitle?: string;
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
const QUERY_KEY = ['entities'];
|
|
@@ -37,7 +38,8 @@ export const getSearchEntities = async ({
|
|
|
37
38
|
locale,
|
|
38
39
|
searchQuery,
|
|
39
40
|
currentCollectionTypeId,
|
|
40
|
-
currentPageId
|
|
41
|
+
currentPageId,
|
|
42
|
+
platformTitle
|
|
41
43
|
}: SearchEntitiesQueryParams): Promise<SearchResult> => {
|
|
42
44
|
try {
|
|
43
45
|
const { get } = fetchClient;
|
|
@@ -53,6 +55,10 @@ export const getSearchEntities = async ({
|
|
|
53
55
|
searchParams.append('_q', searchQuery);
|
|
54
56
|
}
|
|
55
57
|
|
|
58
|
+
if (platformTitle) {
|
|
59
|
+
searchParams.append('filters[$and][0][platform][title][$contains]', String(platformTitle));
|
|
60
|
+
}
|
|
61
|
+
|
|
56
62
|
const { data } = await get(`/content-manager/collection-types/${uid}?${searchParams.toString()}`);
|
|
57
63
|
|
|
58
64
|
const filteredResults = data.results.filter((p: Record<string, any>) => {
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useQuery } from 'react-query';
|
|
2
|
+
|
|
3
|
+
import { useFetchClient } from '@strapi/helper-plugin';
|
|
4
|
+
|
|
5
|
+
import getRequestUrl from '../utils/getRequestUrl';
|
|
6
|
+
import { PageType } from './page-type';
|
|
7
|
+
|
|
8
|
+
export type Platform = {
|
|
9
|
+
id: number;
|
|
10
|
+
title?: string;
|
|
11
|
+
pageTypes?: PageType[];
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
const QUERY_KEY = 'platforms';
|
|
15
|
+
|
|
16
|
+
const fetchPlatforms = async ({ fetchClient }: any): Promise<Platform[]> => {
|
|
17
|
+
const { get } = fetchClient;
|
|
18
|
+
const result = await get(getRequestUrl(`/platform`));
|
|
19
|
+
|
|
20
|
+
return result?.data?.map((entity: any) => ({
|
|
21
|
+
id: entity.id,
|
|
22
|
+
title: entity.title,
|
|
23
|
+
pageTypes: entity.pageTypes
|
|
24
|
+
}));
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const useGetPlatforms = (params: any) => {
|
|
28
|
+
const fetchClient = useFetchClient();
|
|
29
|
+
params = {
|
|
30
|
+
...params,
|
|
31
|
+
fetchClient
|
|
32
|
+
};
|
|
33
|
+
return useQuery<Platform[], Error>(QUERY_KEY, () => fetchPlatforms(params));
|
|
34
|
+
};
|
|
@@ -3,13 +3,13 @@ import { useTheme } from 'styled-components';
|
|
|
3
3
|
import { IReactSelectValue } from '.';
|
|
4
4
|
|
|
5
5
|
export const useReactSelectCustomStyles = (): StylesConfig<IReactSelectValue, false> => {
|
|
6
|
-
const theme = useTheme() as any
|
|
6
|
+
const theme = useTheme() as Record<string, any>;
|
|
7
7
|
|
|
8
8
|
return {
|
|
9
9
|
control: (provided, { isFocused, isDisabled }) => ({
|
|
10
10
|
...provided,
|
|
11
11
|
color: theme.colors.neutral800,
|
|
12
|
-
backgroundColor:
|
|
12
|
+
backgroundColor: theme.colors.neutral0,
|
|
13
13
|
minHeight: '40px',
|
|
14
14
|
lineHeight: 1.4,
|
|
15
15
|
borderRadius: theme.borderRadius,
|
|
@@ -21,6 +21,15 @@ export const useReactSelectCustomStyles = (): StylesConfig<IReactSelectValue, fa
|
|
|
21
21
|
borderColor: isFocused ? theme.colors.buttonPrimary600 : theme.colors.neutral200
|
|
22
22
|
}
|
|
23
23
|
}),
|
|
24
|
+
|
|
25
|
+
input: (provided, {}) => ({
|
|
26
|
+
...provided,
|
|
27
|
+
color: theme.colors.neutral800
|
|
28
|
+
}),
|
|
29
|
+
singleValue: (provided, {}) => ({
|
|
30
|
+
...provided,
|
|
31
|
+
color: theme.colors.neutral800
|
|
32
|
+
}),
|
|
24
33
|
placeholder: (provided) => ({
|
|
25
34
|
...provided,
|
|
26
35
|
color: theme.colors.neutral500
|
|
@@ -30,7 +39,7 @@ export const useReactSelectCustomStyles = (): StylesConfig<IReactSelectValue, fa
|
|
|
30
39
|
border: `1px solid ${theme.colors.neutral150}`,
|
|
31
40
|
boxShadow: '0px 1px 4px rgba(33, 33, 52, 0.1)',
|
|
32
41
|
borderRadius: theme.borderRadius,
|
|
33
|
-
|
|
42
|
+
backgroundColor: theme.colors.neutral0
|
|
34
43
|
}),
|
|
35
44
|
menuList: (provided) => ({
|
|
36
45
|
...provided,
|
|
@@ -14,16 +14,18 @@ const PAGE = 1;
|
|
|
14
14
|
|
|
15
15
|
interface Props {
|
|
16
16
|
uid: string;
|
|
17
|
+
platformTitle?: string;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
export const CollectionTypeSearch = ({ uid }: Props) => {
|
|
20
|
+
export const CollectionTypeSearch = ({ uid, platformTitle }: Props) => {
|
|
20
21
|
const fetchClient = useFetchClient();
|
|
21
|
-
const form = useCMEditViewDataManager();
|
|
22
|
+
const form = useCMEditViewDataManager() as any;
|
|
22
23
|
const { locales } = useSelector((state: any) => state.i18n_locales);
|
|
23
24
|
const urlLocale = useGetLocaleFromUrl();
|
|
24
25
|
const defaultLocale = locales.find((locale: any) => locale.isDefault);
|
|
25
26
|
const selectedLocale = form.initialData?.locale ?? urlLocale ?? defaultLocale.code;
|
|
26
27
|
const prevUid = usePrevious(uid);
|
|
28
|
+
const prevPlatformTitle = usePrevious(platformTitle);
|
|
27
29
|
|
|
28
30
|
const [selected, setSelected] = useState<SingleValue<IReactSelectValue | null>>(
|
|
29
31
|
getInitialSelectItem(form.initialData?.collectionTypeId, form.initialData?.collectionTypeTitle)
|
|
@@ -38,7 +40,7 @@ export const CollectionTypeSearch = ({ uid }: Props) => {
|
|
|
38
40
|
}
|
|
39
41
|
}, []);
|
|
40
42
|
|
|
41
|
-
const getItems = async (inputValue?: string): Promise<IReactSelectValue[]> => {
|
|
43
|
+
const getItems = async (inputValue?: string, platformTitle?: string): Promise<IReactSelectValue[]> => {
|
|
42
44
|
const searchEntities = await getSearchEntities({
|
|
43
45
|
fetchClient,
|
|
44
46
|
page: PAGE,
|
|
@@ -46,7 +48,8 @@ export const CollectionTypeSearch = ({ uid }: Props) => {
|
|
|
46
48
|
uid,
|
|
47
49
|
searchQuery: inputValue,
|
|
48
50
|
currentCollectionTypeId: form.initialData?.collectionTypeId,
|
|
49
|
-
currentPageId: form.initialData?.id
|
|
51
|
+
currentPageId: form.initialData?.id,
|
|
52
|
+
platformTitle
|
|
50
53
|
});
|
|
51
54
|
|
|
52
55
|
return searchEntities.results.map((x) => ({
|
|
@@ -73,28 +76,28 @@ export const CollectionTypeSearch = ({ uid }: Props) => {
|
|
|
73
76
|
};
|
|
74
77
|
|
|
75
78
|
useEffect(() => {
|
|
76
|
-
if (prevUid !== null && prevUid !== uid) {
|
|
79
|
+
if ((prevUid !== null && prevUid !== uid) || (prevPlatformTitle !== null && prevPlatformTitle !== platformTitle)) {
|
|
77
80
|
setSelected(null);
|
|
78
81
|
}
|
|
79
|
-
}, [uid]);
|
|
82
|
+
}, [uid, platformTitle]);
|
|
80
83
|
|
|
81
|
-
const debouncedFetch = debounce((searchTerm, callback) => {
|
|
82
|
-
promiseOptions(searchTerm).then((result) => {
|
|
84
|
+
const debouncedFetch = debounce((searchTerm, callback, selectedPlatformTitle?: string) => {
|
|
85
|
+
promiseOptions(searchTerm, selectedPlatformTitle).then((result) => {
|
|
83
86
|
return callback(result || []);
|
|
84
87
|
});
|
|
85
88
|
}, SEARCH_DEBOUNCE_MS);
|
|
86
89
|
|
|
87
|
-
const promiseOptions = (inputValue: string): Promise<IReactSelectValue[]> =>
|
|
90
|
+
const promiseOptions = (inputValue: string, selectedPlatformTitle?: string): Promise<IReactSelectValue[]> =>
|
|
88
91
|
new Promise<IReactSelectValue[]>((resolve) => {
|
|
89
|
-
resolve(getItems(inputValue));
|
|
92
|
+
resolve(getItems(inputValue, selectedPlatformTitle));
|
|
90
93
|
});
|
|
91
94
|
|
|
92
95
|
return (
|
|
93
96
|
<Combobox
|
|
94
|
-
key={`
|
|
97
|
+
key={`rerenderOnUidOrPlatformChange-${uid}-${platformTitle}`}
|
|
95
98
|
id="collectionTypeSearch"
|
|
96
99
|
label="Entity"
|
|
97
|
-
loadOptions={debouncedFetch}
|
|
100
|
+
loadOptions={(i, c) => debouncedFetch(i, c, platformTitle)}
|
|
98
101
|
cacheOptions
|
|
99
102
|
onChange={handleChange}
|
|
100
103
|
customOption={CustomOption}
|
|
@@ -108,8 +111,8 @@ const CustomOption = (props: OptionProps<IReactSelectValue, false>) => {
|
|
|
108
111
|
return (
|
|
109
112
|
<components.Option {...props}>
|
|
110
113
|
<span>{props.children}</span>
|
|
111
|
-
{props.isDisabled && <span>
|
|
112
|
-
{props.data.initialSelected && <span>
|
|
114
|
+
{props.isDisabled && <span>Entiteit heeft al een pagina</span>}
|
|
115
|
+
{props.data.initialSelected && <span>Oorspronkelijk gekoppeld</span>}
|
|
113
116
|
</components.Option>
|
|
114
117
|
);
|
|
115
118
|
};
|
|
@@ -13,7 +13,7 @@ import S from './styles';
|
|
|
13
13
|
|
|
14
14
|
export const CreatePageButton = () => {
|
|
15
15
|
const history = useHistory();
|
|
16
|
-
const { layout, initialData } = useCMEditViewDataManager();
|
|
16
|
+
const { layout, initialData } = useCMEditViewDataManager() as any;
|
|
17
17
|
|
|
18
18
|
const { post, get, put } = useFetchClient();
|
|
19
19
|
const url = `/content-manager/collectionType/${PAGE_UID}/create`;
|
|
@@ -37,6 +37,7 @@ export const CreatePageButton = () => {
|
|
|
37
37
|
post,
|
|
38
38
|
locale,
|
|
39
39
|
pageTypeId: pageType.id,
|
|
40
|
+
platformId: initialData.platform[0]?.id,
|
|
40
41
|
collectionTypeId: initialData.id,
|
|
41
42
|
layoutUid: layout.uid,
|
|
42
43
|
relatedEntityId: createLocalizedPage ? linkedPages.data?.[0]?.id : undefined
|
|
@@ -67,6 +68,7 @@ interface ICreateNewPageProps {
|
|
|
67
68
|
modules?: Record<string, any>[];
|
|
68
69
|
post: any;
|
|
69
70
|
pageTypeId: number;
|
|
71
|
+
platformId: number;
|
|
70
72
|
relatedEntityId?: number;
|
|
71
73
|
}
|
|
72
74
|
|
|
@@ -78,6 +80,7 @@ const createNewPage = async ({
|
|
|
78
80
|
layoutUid,
|
|
79
81
|
modules,
|
|
80
82
|
pageTypeId,
|
|
83
|
+
platformId,
|
|
81
84
|
relatedEntityId
|
|
82
85
|
}: ICreateNewPageProps) => {
|
|
83
86
|
// Including locale in url is neccesary.
|
|
@@ -87,6 +90,7 @@ const createNewPage = async ({
|
|
|
87
90
|
title,
|
|
88
91
|
locale,
|
|
89
92
|
pageType: { connect: [{ id: pageTypeId }] },
|
|
93
|
+
platform: { connect: [{ id: platformId }] },
|
|
90
94
|
collectionTypeData: {
|
|
91
95
|
id: collectionTypeId,
|
|
92
96
|
__type: layoutUid,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { useEffect
|
|
1
|
+
import React, { useEffect } from 'react';
|
|
2
2
|
|
|
3
3
|
import { useCMEditViewDataManager } from '@strapi/helper-plugin';
|
|
4
4
|
import { Flex } from '@strapi/design-system';
|
|
@@ -10,24 +10,14 @@ import { PAGE_TYPE_PAGE, PAGE_UID } from '../../../../../shared/utils/constants'
|
|
|
10
10
|
import S from '../Details/styles';
|
|
11
11
|
|
|
12
12
|
export const CollectionTypeSettings = () => {
|
|
13
|
-
const { layout, isCreatingEntry, initialData,
|
|
13
|
+
const { layout, isCreatingEntry, initialData, onChange } = useCMEditViewDataManager() as any;
|
|
14
14
|
|
|
15
15
|
const isUserCreatedContentType = layout.uid.startsWith('api::');
|
|
16
|
-
const
|
|
16
|
+
const linkedPage = initialData.page?.[0];
|
|
17
17
|
|
|
18
18
|
const showCreatePageButton = isUserCreatedContentType && !isCreatingEntry && !linkedPage;
|
|
19
19
|
const url = generateLink(linkedPage?.id, initialData?.locale);
|
|
20
20
|
|
|
21
|
-
useEffect(() => {
|
|
22
|
-
if (modifiedData.page?.[0]) {
|
|
23
|
-
setLinkedPage(modifiedData.page?.[0]);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
if (modifiedData.page === null) {
|
|
27
|
-
setLinkedPage(undefined);
|
|
28
|
-
}
|
|
29
|
-
}, [modifiedData.page?.[0]]);
|
|
30
|
-
|
|
31
21
|
useEffect(() => {
|
|
32
22
|
if (isCreatingEntry) {
|
|
33
23
|
onChange({
|
|
@@ -54,9 +44,9 @@ export const CollectionTypeSettings = () => {
|
|
|
54
44
|
{PAGE_TYPE_PAGE}
|
|
55
45
|
</S.SubtleType>
|
|
56
46
|
<S.EntityLinkWrapper variant="pi" textColor="neutral800">
|
|
57
|
-
<S.EntityLink title={linkedPage
|
|
47
|
+
<S.EntityLink title={linkedPage.title || '-'} to={url} variant="pi">
|
|
58
48
|
<Link />
|
|
59
|
-
{linkedPage
|
|
49
|
+
{linkedPage.title || '-'}
|
|
60
50
|
</S.EntityLink>
|
|
61
51
|
</S.EntityLinkWrapper>
|
|
62
52
|
</Flex>
|
|
@@ -3,7 +3,7 @@ import React, { useEffect, useMemo, useState } from 'react';
|
|
|
3
3
|
import { useCMEditViewDataManager } from '@strapi/helper-plugin';
|
|
4
4
|
import { Stack, Flex } from '@strapi/design-system';
|
|
5
5
|
import { Cog, Cross } from '@strapi/icons';
|
|
6
|
-
|
|
6
|
+
import { getFetchClient } from '@strapi/helper-plugin';
|
|
7
7
|
import { TemplateSelect } from '../Template/TemplateSelect';
|
|
8
8
|
import { PageTypeSelect } from '../page-type-select';
|
|
9
9
|
import { CollectionTypeSearch } from '../CollectionTypeSearch';
|
|
@@ -11,11 +11,18 @@ import { Wrapper } from '../wrapper';
|
|
|
11
11
|
import { PageType, useGetPageTypes } from '../../../api/page-type';
|
|
12
12
|
import { Details } from '../Details';
|
|
13
13
|
import S from '../Details/styles';
|
|
14
|
+
import { Platform, useGetPlatforms } from '../../../api/platform';
|
|
15
|
+
import { PlatformSelect } from '../Platform/platform-select';
|
|
16
|
+
import getRequestUrl from '../../../utils/getRequestUrl';
|
|
14
17
|
|
|
15
18
|
export const PageSettings = () => {
|
|
16
|
-
const { isCreatingEntry, initialData, onChange, modifiedData } = useCMEditViewDataManager();
|
|
17
|
-
const { data:
|
|
19
|
+
const { isCreatingEntry, initialData, onChange, modifiedData, ...rest } = useCMEditViewDataManager() as any;
|
|
20
|
+
const { data: allPageTypes } = useGetPageTypes({});
|
|
21
|
+
const { data: platforms } = useGetPlatforms({});
|
|
22
|
+
const [pageTypes, setPageTypes] = useState(allPageTypes);
|
|
18
23
|
const [selectedPageType, setSelectedPageType] = useState<PageType | undefined | null>(initialData?.initialPageType);
|
|
24
|
+
const [selectedPlatform, setSelectedPlatform] = useState<Platform | undefined | null>(initialData?.platform?.[0]);
|
|
25
|
+
const noPlatformSelected = useMemo(() => !Boolean(selectedPlatform), [selectedPlatform]);
|
|
19
26
|
const [isEditting, setIsEditting] = useState(false);
|
|
20
27
|
const showEditFields = useMemo(
|
|
21
28
|
() => isCreatingEntry || !selectedPageType?.id || !initialData.collectionTypeTitle || isEditting,
|
|
@@ -35,15 +42,24 @@ export const PageSettings = () => {
|
|
|
35
42
|
useEffect(() => {
|
|
36
43
|
setSelectedPageType(initialData?.initialPageType);
|
|
37
44
|
|
|
45
|
+
setSelectedPlatform(initialData?.platform?.[0]);
|
|
38
46
|
setIsEditting(false);
|
|
39
47
|
}, [initialData]);
|
|
40
48
|
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (selectedPlatform?.title) {
|
|
51
|
+
setPageTypesByPlatform(selectedPlatform.title);
|
|
52
|
+
}
|
|
53
|
+
}, [selectedPlatform, allPageTypes]);
|
|
54
|
+
|
|
41
55
|
const cancelEdit = () => {
|
|
42
56
|
setIsEditting(false);
|
|
43
57
|
setSelectedPageType(initialData?.initialPageType || []);
|
|
58
|
+
setSelectedPlatform(initialData?.platform?.[0]);
|
|
44
59
|
setFormValue('pageType', initialData?.initialPageType || []);
|
|
45
60
|
setFormValue('collectionTypeTitle', initialData?.collectionTypeTitle);
|
|
46
61
|
setFormValue('collectionTypeId', initialData?.collectionTypeId);
|
|
62
|
+
setFormValue('platform', initialData?.platform);
|
|
47
63
|
};
|
|
48
64
|
|
|
49
65
|
const removePageType = () => {
|
|
@@ -70,14 +86,49 @@ export const PageSettings = () => {
|
|
|
70
86
|
}
|
|
71
87
|
};
|
|
72
88
|
|
|
89
|
+
const handleSelectPlatform = async (platformId: string) => {
|
|
90
|
+
const platform = platforms?.find((platform) => platform.id === Number(platformId));
|
|
91
|
+
|
|
92
|
+
if (platform && platform.title) {
|
|
93
|
+
setSelectedPlatform(platform);
|
|
94
|
+
const formPlatform = {
|
|
95
|
+
...platform,
|
|
96
|
+
label: platform.title,
|
|
97
|
+
value: platform.id
|
|
98
|
+
};
|
|
99
|
+
setFormValue('platform', [formPlatform]);
|
|
100
|
+
setPageTypesByPlatform(platform.title);
|
|
101
|
+
} else {
|
|
102
|
+
setFormValue('platform', []);
|
|
103
|
+
setSelectedPlatform(null);
|
|
104
|
+
removePageType();
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const setPageTypesByPlatform = async (platform: string) => {
|
|
109
|
+
const pageTypeUrl = getRequestUrl(`/platform/${platform}`);
|
|
110
|
+
const { get } = getFetchClient();
|
|
111
|
+
const { data: platFormData } = await get(pageTypeUrl);
|
|
112
|
+
|
|
113
|
+
setPageTypes(platFormData[0].pageTypes);
|
|
114
|
+
};
|
|
115
|
+
|
|
73
116
|
return (
|
|
74
117
|
<Wrapper title="Gekoppelde type">
|
|
75
118
|
<Flex direction="column" gap={4} width="100%">
|
|
76
119
|
{showEditFields ? (
|
|
77
120
|
<Stack spacing={4} width="100%">
|
|
78
|
-
<
|
|
79
|
-
<
|
|
80
|
-
|
|
121
|
+
<PlatformSelect platforms={platforms} selectedPlatform={selectedPlatform} onChange={handleSelectPlatform} />
|
|
122
|
+
<PageTypeSelect
|
|
123
|
+
pageTypes={pageTypes}
|
|
124
|
+
selectedPageType={selectedPageType}
|
|
125
|
+
onChange={handleSelectPageType}
|
|
126
|
+
disabled={noPlatformSelected}
|
|
127
|
+
/>
|
|
128
|
+
<TemplateSelect disabled={noPlatformSelected} />
|
|
129
|
+
{selectedPageType?.uid && (
|
|
130
|
+
<CollectionTypeSearch uid={selectedPageType.uid} platformTitle={selectedPlatform?.title} />
|
|
131
|
+
)}
|
|
81
132
|
</Stack>
|
|
82
133
|
) : (
|
|
83
134
|
<Details
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { SingleSelect, SingleSelectOption } from '@strapi/design-system';
|
|
4
|
+
|
|
5
|
+
import { Platform } from '../../../api/platform';
|
|
6
|
+
import { PLATFORM } from '../../../../../shared/utils/constants';
|
|
7
|
+
|
|
8
|
+
interface Props {
|
|
9
|
+
onChange: (platformId: string) => void;
|
|
10
|
+
selectedPlatform?: Platform | null;
|
|
11
|
+
platforms?: Platform[];
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export const PlatformSelect = ({ onChange, platforms, selectedPlatform }: Props) => {
|
|
15
|
+
return (
|
|
16
|
+
<SingleSelect
|
|
17
|
+
label="Platform"
|
|
18
|
+
placeholder="Choose a platform"
|
|
19
|
+
value={selectedPlatform?.id || PLATFORM}
|
|
20
|
+
onChange={onChange}
|
|
21
|
+
>
|
|
22
|
+
<SingleSelectOption value={PLATFORM}>Platform</SingleSelectOption>
|
|
23
|
+
{platforms?.map((pageType: Platform) => (
|
|
24
|
+
<SingleSelectOption key={pageType?.id} value={pageType?.id}>
|
|
25
|
+
{pageType?.title}
|
|
26
|
+
</SingleSelectOption>
|
|
27
|
+
))}
|
|
28
|
+
</SingleSelect>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
@@ -10,7 +10,7 @@ interface Props {
|
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
export const TemplateSelect = ({ disabled }: Props) => {
|
|
13
|
-
const { onChange, modifiedData } = useCMEditViewDataManager();
|
|
13
|
+
const { onChange, modifiedData } = useCMEditViewDataManager() as any;
|
|
14
14
|
const [selectedTemplate, setSelectedTemplate] = useState<Template | null>(null);
|
|
15
15
|
const { templates, replaceContentTypeModules } = useTemplateModules(onChange);
|
|
16
16
|
const [templateIdToSelect, setTemplateIdToSelect] = useState<string | undefined>();
|
|
@@ -48,7 +48,7 @@ export const TemplateSelect = ({ disabled }: Props) => {
|
|
|
48
48
|
placeholder="Choose a template"
|
|
49
49
|
value={selectedTemplate?.id || 0}
|
|
50
50
|
onChange={handleSelectChange}
|
|
51
|
-
disabled={disabled}
|
|
51
|
+
disabled={Boolean(disabled)}
|
|
52
52
|
>
|
|
53
53
|
<SingleSelectOption value={0}>None</SingleSelectOption>
|
|
54
54
|
{templates?.map((template) => (
|
|
@@ -8,7 +8,7 @@ import { CollectionTypeSettings } from './CollectionTypeSettings';
|
|
|
8
8
|
import { useHasPageRelation } from '../../api/has-page-relation';
|
|
9
9
|
|
|
10
10
|
export const EditView = () => {
|
|
11
|
-
const { layout } = useCMEditViewDataManager();
|
|
11
|
+
const { layout } = useCMEditViewDataManager() as any;
|
|
12
12
|
|
|
13
13
|
const isPageCollectionType = layout.uid === PAGE_UID;
|
|
14
14
|
const isCollectionType = layout.kind === 'collectionType';
|
|
@@ -19,7 +19,7 @@ export const PageTypeSelect = ({ onChange, pageTypes, selectedPageType, disabled
|
|
|
19
19
|
placeholder="Choose a page type"
|
|
20
20
|
value={selectedPageType?.id || PAGE_TYPE_PAGE}
|
|
21
21
|
onChange={onChange}
|
|
22
|
-
disabled={disabled}
|
|
22
|
+
disabled={Boolean(disabled)}
|
|
23
23
|
>
|
|
24
24
|
<SingleSelectOption value={PAGE_TYPE_PAGE}>Page</SingleSelectOption>
|
|
25
25
|
{pageTypes?.map((pageType: PageType) => (
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { SingleSelectOption, SingleSelect } from '@strapi/design-system';
|
|
4
|
+
|
|
5
|
+
import { PageType } from '../../../api/page-type';
|
|
6
|
+
import { PAGE_TYPE_NO_FILTER } from '../../../constants';
|
|
7
|
+
import { PAGE_TYPE_PAGE } from '../../../../../shared/utils/constants';
|
|
8
|
+
|
|
9
|
+
interface Props {
|
|
10
|
+
onChange: (pageTypeUId: string) => void;
|
|
11
|
+
selectedPageTypeUid?: string;
|
|
12
|
+
pageTypes?: PageType[];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const PageTypeFilter = ({ onChange, pageTypes, selectedPageTypeUid }: Props) => {
|
|
16
|
+
return (
|
|
17
|
+
<SingleSelect
|
|
18
|
+
placeholder="Select page type"
|
|
19
|
+
onChange={onChange}
|
|
20
|
+
size="S"
|
|
21
|
+
value={selectedPageTypeUid}
|
|
22
|
+
disabled={(pageTypes?.length || 0) === 0}
|
|
23
|
+
>
|
|
24
|
+
<SingleSelectOption key={PAGE_TYPE_NO_FILTER} value={PAGE_TYPE_NO_FILTER}>
|
|
25
|
+
All Pagetypes
|
|
26
|
+
</SingleSelectOption>
|
|
27
|
+
<SingleSelectOption key={PAGE_TYPE_PAGE} value={PAGE_TYPE_PAGE}>
|
|
28
|
+
Page
|
|
29
|
+
</SingleSelectOption>
|
|
30
|
+
{pageTypes?.map((pageType) => (
|
|
31
|
+
<SingleSelectOption key={pageType.uid} value={pageType.uid}>
|
|
32
|
+
{pageType.title || pageType.uid}
|
|
33
|
+
</SingleSelectOption>
|
|
34
|
+
))}
|
|
35
|
+
</SingleSelect>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
export default PageTypeFilter;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
import { SingleSelectOption, SingleSelect } from '@strapi/design-system';
|
|
4
|
+
import { Platform } from '../../../api/platform';
|
|
5
|
+
import { PLATFORM_NO_FILTER } from '../../../constants';
|
|
6
|
+
|
|
7
|
+
interface Props {
|
|
8
|
+
onChange?: (platformId: string) => void;
|
|
9
|
+
selectedPlatform?: string;
|
|
10
|
+
platforms?: Platform[];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const PlatformFilter = ({ onChange, platforms, selectedPlatform }: Props) => {
|
|
14
|
+
return (
|
|
15
|
+
<SingleSelect placeholder="Select platform" onChange={onChange} size="S" value={selectedPlatform}>
|
|
16
|
+
<SingleSelectOption key={PLATFORM_NO_FILTER} value={PLATFORM_NO_FILTER}>
|
|
17
|
+
All Platforms
|
|
18
|
+
</SingleSelectOption>
|
|
19
|
+
{platforms?.map((platform: Platform) => (
|
|
20
|
+
<SingleSelectOption key={platform?.id} value={platform?.title}>
|
|
21
|
+
{platform?.title}
|
|
22
|
+
</SingleSelectOption>
|
|
23
|
+
))}
|
|
24
|
+
</SingleSelect>
|
|
25
|
+
);
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default PlatformFilter;
|