@webbio/strapi-plugin-page-builder 0.3.7-platform → 0.3.8-legacy
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 +35 -11
- package/admin/src/api/collection-type.ts +1 -7
- package/admin/src/api/page-type.ts +4 -5
- package/admin/src/components/EditView/CollectionTypeSearch/index.tsx +12 -15
- package/admin/src/components/EditView/CollectionTypeSettings/CreatePageButton/index.tsx +28 -10
- package/admin/src/components/EditView/CollectionTypeSettings/index.tsx +35 -80
- package/admin/src/components/EditView/Details/index.tsx +2 -13
- package/admin/src/components/EditView/PageSettings/index.tsx +5 -61
- package/admin/src/components/EditView/index.tsx +2 -8
- package/admin/src/components/PageTypeFilter/index.tsx +17 -0
- package/admin/src/components/PageTypeFilter/page-type-filter.tsx +130 -0
- package/admin/src/index.tsx +2 -2
- package/admin/src/utils/sanitizeModules.ts +92 -9
- package/dist/package.json +12 -10
- package/dist/server/bootstrap/permissions.js +10 -68
- package/dist/server/bootstrap.js +25 -41
- package/dist/server/controllers/collection-types.js +0 -5
- package/dist/server/controllers/index.js +1 -3
- package/dist/server/graphql/index.js +2 -2
- package/dist/server/graphql/page-by-slug.js +50 -44
- package/dist/server/graphql/pages-by-uid.js +9 -11
- package/dist/server/register.js +2 -2
- package/dist/server/routes/index.js +0 -26
- package/dist/server/schema/page-end.json +0 -5
- package/dist/server/services/builder.js +5 -15
- package/dist/server/services/collection-types.js +0 -7
- package/dist/server/services/index.js +1 -3
- package/dist/server/services/template.js +1 -2
- package/dist/server/utils/strapi.js +1 -4
- package/dist/shared/utils/constants.js +1 -3
- package/dist/tsconfig.server.tsbuildinfo +1 -1
- package/package.json +12 -10
- package/server/bootstrap/collection-type-lifecycles.ts +1 -1
- package/server/bootstrap/permissions.ts +10 -75
- package/server/bootstrap.ts +25 -44
- package/server/controllers/collection-types.ts +0 -5
- package/server/controllers/index.ts +1 -3
- package/server/graphql/index.ts +2 -2
- package/server/graphql/page-by-slug.ts +113 -0
- package/server/graphql/pages-by-uid.ts +9 -11
- package/server/register.ts +2 -2
- package/server/routes/index.ts +0 -26
- package/server/schema/page-end.json +0 -5
- package/server/services/builder.ts +6 -18
- package/server/services/collection-types.ts +1 -8
- package/server/services/index.ts +1 -3
- package/server/services/template.ts +1 -2
- package/server/utils/strapi.ts +1 -5
- package/shared/utils/constants.ts +0 -2
- package/admin/src/api/has-platform-relation.ts +0 -37
- package/admin/src/api/platform-page-types.ts +0 -40
- package/admin/src/api/platform.ts +0 -34
- package/admin/src/components/EditView/Platform/platform-select.tsx +0 -31
- package/admin/src/components/PageFilters/PageTypeFilter/index.tsx +0 -39
- package/admin/src/components/PageFilters/PlatformFilter/index.tsx +0 -28
- package/admin/src/components/PageFilters/filters.tsx +0 -180
- package/admin/src/components/PageFilters/index.tsx +0 -30
- package/dist/server/controllers/platform.js +0 -20
- package/dist/server/graphql/page-by-path.js +0 -89
- package/dist/server/schema/platform-start.json +0 -31
- package/dist/server/services/platform.js +0 -36
- package/server/controllers/platform.ts +0 -21
- package/server/graphql/page-by-path.ts +0 -105
- package/server/schema/platform-start.json +0 -31
- package/server/services/platform.ts +0 -36
package/README.md
CHANGED
|
@@ -38,11 +38,6 @@ Voor elk collection type die een page type is, moet deze properties toegevoegd w
|
|
|
38
38
|
"morphBy": "collectionTypeData"
|
|
39
39
|
},
|
|
40
40
|
"hasPage": {
|
|
41
|
-
"pluginOptions": {
|
|
42
|
-
"i18n": {
|
|
43
|
-
"localized": true
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
41
|
"type": "boolean",
|
|
47
42
|
"default": false
|
|
48
43
|
}
|
|
@@ -50,6 +45,9 @@ Voor elk collection type die een page type is, moet deze properties toegevoegd w
|
|
|
50
45
|
|
|
51
46
|
Zodra dit goed is ingesteld, kan je via deze collectie types direct een pagina aanmaken.
|
|
52
47
|
|
|
48
|
+
> **Notitie:**
|
|
49
|
+
> `hasPage` wordt gebruikt om aan te tonen dan een collection type item een `published` pagina heeft.
|
|
50
|
+
|
|
53
51
|
## Page
|
|
54
52
|
|
|
55
53
|
Op een page kan je in de Edit View een page type selecteren. Op basis daarvan wordt er een template geselecteerd (indien gekozen in een page type) en kan je zoeken in verschillende entiteiten binnen die page type. Deze kan je koppelen aan een pagina.
|
|
@@ -65,19 +63,31 @@ Om wijzigignen aan te brengen in een platform, moeten deze in de schema aangepas
|
|
|
65
63
|
Voor elk collectiontype die je wil toevoegen aan het platform, moet deze relatie toegevoegd worden:
|
|
66
64
|
|
|
67
65
|
```
|
|
68
|
-
"
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
66
|
+
"collectiontype": {
|
|
67
|
+
"type": "relation",
|
|
68
|
+
"relation": "oneToMany",
|
|
69
|
+
"target": "UID van collection type",
|
|
70
|
+
"mappedBy": "platform"
|
|
71
|
+
}
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
bijvoorbeeld :
|
|
75
|
+
|
|
76
|
+
```
|
|
77
|
+
"faqs": {
|
|
78
|
+
"type": "relation",
|
|
79
|
+
"relation": "oneToMany",
|
|
80
|
+
"target": "api::faq.faq",
|
|
81
|
+
"mappedBy": "platform"
|
|
82
|
+
}
|
|
73
83
|
```
|
|
74
84
|
|
|
75
85
|
Een platform zit altijd aan een pagina gekoppeld. Deze moet handmatig in de pagina toegevoegd worden.
|
|
76
86
|
|
|
77
87
|
# Known bugs
|
|
78
88
|
|
|
89
|
+
- Bij het opslaan van een collectietype wil de gekoppelde pagina of type in het ui wel eens verdwijnen.
|
|
79
90
|
- Na het ontkoppelen en opslaan van een collectie item op een pagina, staat deze nog als "Geselecteerd" in de dropdown.
|
|
80
|
-
- 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.
|
|
81
91
|
|
|
82
92
|
# Improvements
|
|
83
93
|
|
|
@@ -89,3 +99,17 @@ Een platform zit altijd aan een pagina gekoppeld. Deze moet handmatig in de pagi
|
|
|
89
99
|
- Dit vorige punt geldt ook andersom, dus als je een entity koppelt vanuit een pagina. Als de titel en slug nog leeg zijn, vul die dan automatisch in.
|
|
90
100
|
- In het overzicht van een collectiontype moet duidelijk worden of en welke pagina er gekoppeld is. [https://share.getcloudapp.com/BluzGYEd](https://share.getcloudapp.com/BluzGYEd)
|
|
91
101
|
- Bij Page Types moet je handmatig de collectiontype uid invoeren. Dit zou idealiter een select zijn van alle mogelijke collecion type uids. Ook moet dit een mogelijkheid bieden voor geen uid.
|
|
102
|
+
|
|
103
|
+
# Lokaal met de plugin werken
|
|
104
|
+
|
|
105
|
+
- Git clone deze repo in dezelfde directory als je Strapi project
|
|
106
|
+
- En voeg onderstaande `resolve` property toe aan `plugins.js/ts`
|
|
107
|
+
|
|
108
|
+
```js
|
|
109
|
+
'page-builder': {
|
|
110
|
+
enabled: true,
|
|
111
|
+
resolve: '../strapi-plugin-page-builder/src/plugins/strapi-plugin-page-builder',
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
- Vergeet niet het `build-page-builder` script te draaien na een change.
|
|
115
|
+
- En herstart de dev-server van je Strapi project.
|
|
@@ -26,7 +26,6 @@ type SearchEntitiesQueryParams = {
|
|
|
26
26
|
searchQuery?: string;
|
|
27
27
|
currentCollectionTypeId?: number;
|
|
28
28
|
currentPageId?: number;
|
|
29
|
-
platformTitle?: string;
|
|
30
29
|
};
|
|
31
30
|
|
|
32
31
|
const QUERY_KEY = ['entities'];
|
|
@@ -38,8 +37,7 @@ export const getSearchEntities = async ({
|
|
|
38
37
|
locale,
|
|
39
38
|
searchQuery,
|
|
40
39
|
currentCollectionTypeId,
|
|
41
|
-
currentPageId
|
|
42
|
-
platformTitle
|
|
40
|
+
currentPageId
|
|
43
41
|
}: SearchEntitiesQueryParams): Promise<SearchResult> => {
|
|
44
42
|
try {
|
|
45
43
|
const { get } = fetchClient;
|
|
@@ -55,10 +53,6 @@ export const getSearchEntities = async ({
|
|
|
55
53
|
searchParams.append('_q', searchQuery);
|
|
56
54
|
}
|
|
57
55
|
|
|
58
|
-
if (platformTitle) {
|
|
59
|
-
searchParams.append('filters[$and][0][platform][title][$contains]', String(platformTitle));
|
|
60
|
-
}
|
|
61
|
-
|
|
62
56
|
const { data } = await get(`/content-manager/collection-types/${uid}?${searchParams.toString()}`);
|
|
63
57
|
|
|
64
58
|
const filteredResults = data.results.filter((p: Record<string, any>) => {
|
|
@@ -9,11 +9,11 @@ export type PageType = {
|
|
|
9
9
|
|
|
10
10
|
const QUERY_KEY = 'page-types';
|
|
11
11
|
|
|
12
|
-
const fetchPageTypes = async ({ fetchClient }:
|
|
12
|
+
const fetchPageTypes = async ({ fetchClient }: any): Promise<PageType[]> => {
|
|
13
13
|
const { get } = fetchClient;
|
|
14
|
-
const result = await get(`/content-manager/collection-types/api::page-type.page-type
|
|
14
|
+
const result = await get(`/content-manager/collection-types/api::page-type.page-type`);
|
|
15
15
|
|
|
16
|
-
return result?.data?.results?.map((entity:
|
|
16
|
+
return result?.data?.results?.map((entity: any) => ({
|
|
17
17
|
id: entity.id,
|
|
18
18
|
uid: entity.uid,
|
|
19
19
|
title: entity.title,
|
|
@@ -21,12 +21,11 @@ const fetchPageTypes = async ({ fetchClient }: Record<string, any>): Promise<Pag
|
|
|
21
21
|
}));
|
|
22
22
|
};
|
|
23
23
|
|
|
24
|
-
export const useGetPageTypes = (params:
|
|
24
|
+
export const useGetPageTypes = (params: any) => {
|
|
25
25
|
const fetchClient = useFetchClient();
|
|
26
26
|
params = {
|
|
27
27
|
...params,
|
|
28
28
|
fetchClient
|
|
29
29
|
};
|
|
30
|
-
|
|
31
30
|
return useQuery<PageType[], Error>(QUERY_KEY, () => fetchPageTypes(params));
|
|
32
31
|
};
|
|
@@ -14,10 +14,9 @@ const PAGE = 1;
|
|
|
14
14
|
|
|
15
15
|
interface Props {
|
|
16
16
|
uid: string;
|
|
17
|
-
platformTitle?: string;
|
|
18
17
|
}
|
|
19
18
|
|
|
20
|
-
export const CollectionTypeSearch = ({ uid
|
|
19
|
+
export const CollectionTypeSearch = ({ uid }: Props) => {
|
|
21
20
|
const fetchClient = useFetchClient();
|
|
22
21
|
const form = useCMEditViewDataManager() as any;
|
|
23
22
|
const { locales } = useSelector((state: any) => state.i18n_locales);
|
|
@@ -25,7 +24,6 @@ export const CollectionTypeSearch = ({ uid, platformTitle }: Props) => {
|
|
|
25
24
|
const defaultLocale = locales.find((locale: any) => locale.isDefault);
|
|
26
25
|
const selectedLocale = form.initialData?.locale ?? urlLocale ?? defaultLocale.code;
|
|
27
26
|
const prevUid = usePrevious(uid);
|
|
28
|
-
const prevPlatformTitle = usePrevious(platformTitle);
|
|
29
27
|
|
|
30
28
|
const [selected, setSelected] = useState<SingleValue<IReactSelectValue | null>>(
|
|
31
29
|
getInitialSelectItem(form.initialData?.collectionTypeId, form.initialData?.collectionTypeTitle)
|
|
@@ -40,7 +38,7 @@ export const CollectionTypeSearch = ({ uid, platformTitle }: Props) => {
|
|
|
40
38
|
}
|
|
41
39
|
}, []);
|
|
42
40
|
|
|
43
|
-
const getItems = async (inputValue?: string
|
|
41
|
+
const getItems = async (inputValue?: string): Promise<IReactSelectValue[]> => {
|
|
44
42
|
const searchEntities = await getSearchEntities({
|
|
45
43
|
fetchClient,
|
|
46
44
|
page: PAGE,
|
|
@@ -48,8 +46,7 @@ export const CollectionTypeSearch = ({ uid, platformTitle }: Props) => {
|
|
|
48
46
|
uid,
|
|
49
47
|
searchQuery: inputValue,
|
|
50
48
|
currentCollectionTypeId: form.initialData?.collectionTypeId,
|
|
51
|
-
currentPageId: form.initialData?.id
|
|
52
|
-
platformTitle
|
|
49
|
+
currentPageId: form.initialData?.id
|
|
53
50
|
});
|
|
54
51
|
|
|
55
52
|
return searchEntities.results.map((x) => ({
|
|
@@ -76,28 +73,28 @@ export const CollectionTypeSearch = ({ uid, platformTitle }: Props) => {
|
|
|
76
73
|
};
|
|
77
74
|
|
|
78
75
|
useEffect(() => {
|
|
79
|
-
if (
|
|
76
|
+
if (prevUid !== null && prevUid !== uid) {
|
|
80
77
|
setSelected(null);
|
|
81
78
|
}
|
|
82
|
-
}, [uid
|
|
79
|
+
}, [uid]);
|
|
83
80
|
|
|
84
|
-
const debouncedFetch = debounce((searchTerm, callback
|
|
85
|
-
promiseOptions(searchTerm
|
|
81
|
+
const debouncedFetch = debounce((searchTerm, callback) => {
|
|
82
|
+
promiseOptions(searchTerm).then((result) => {
|
|
86
83
|
return callback(result || []);
|
|
87
84
|
});
|
|
88
85
|
}, SEARCH_DEBOUNCE_MS);
|
|
89
86
|
|
|
90
|
-
const promiseOptions = (inputValue: string
|
|
87
|
+
const promiseOptions = (inputValue: string): Promise<IReactSelectValue[]> =>
|
|
91
88
|
new Promise<IReactSelectValue[]>((resolve) => {
|
|
92
|
-
resolve(getItems(inputValue
|
|
89
|
+
resolve(getItems(inputValue));
|
|
93
90
|
});
|
|
94
91
|
|
|
95
92
|
return (
|
|
96
93
|
<Combobox
|
|
97
|
-
key={`
|
|
94
|
+
key={`rerenderOnUidChange-${uid}`}
|
|
98
95
|
id="collectionTypeSearch"
|
|
99
|
-
label="
|
|
100
|
-
loadOptions={
|
|
96
|
+
label="Link"
|
|
97
|
+
loadOptions={debouncedFetch}
|
|
101
98
|
cacheOptions
|
|
102
99
|
onChange={handleChange}
|
|
103
100
|
customOption={CustomOption}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import React
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import slugify from 'slugify';
|
|
3
|
+
import { useSelector } from 'react-redux';
|
|
2
4
|
import { useHistory } from 'react-router-dom';
|
|
3
5
|
|
|
4
6
|
import { Plus } from '@strapi/icons';
|
|
@@ -14,9 +16,10 @@ import S from './styles';
|
|
|
14
16
|
export const CreatePageButton = () => {
|
|
15
17
|
const history = useHistory();
|
|
16
18
|
const { layout, initialData } = useCMEditViewDataManager() as any;
|
|
19
|
+
const { locales } = useSelector((state: any) => state.i18n_locales);
|
|
17
20
|
|
|
18
21
|
const { post, get, put } = useFetchClient();
|
|
19
|
-
const url = `/content-manager/
|
|
22
|
+
const url = `/content-manager/collection-types/${PAGE_UID}/create`;
|
|
20
23
|
|
|
21
24
|
const handleCreatePage = async (e: React.MouseEvent<HTMLAnchorElement>) => {
|
|
22
25
|
e.preventDefault();
|
|
@@ -28,8 +31,17 @@ export const CreatePageButton = () => {
|
|
|
28
31
|
getRequestUrl(`/collection-types-page-links/${layout.uid}/${mappedLocalizations}`)
|
|
29
32
|
);
|
|
30
33
|
const createLocalizedPage = !linkedPages?.data?.find((x) => x.locale === initialData?.locale);
|
|
31
|
-
const
|
|
32
|
-
const
|
|
34
|
+
const defaultLocale = locales.find((locale: any) => locale.isDefault);
|
|
35
|
+
const locale = initialData?.locale || defaultLocale?.code;
|
|
36
|
+
|
|
37
|
+
// Get data inside template
|
|
38
|
+
let templateData;
|
|
39
|
+
|
|
40
|
+
if (pageType?.template?.id) {
|
|
41
|
+
templateData = await get(getRequestUrl(`/template/${pageType.template.id}`));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const modules = sanitizeModules(templateData?.data?.modules || [], false);
|
|
33
45
|
|
|
34
46
|
const newPage = await createNewPage({
|
|
35
47
|
title: initialData?.title,
|
|
@@ -37,16 +49,15 @@ export const CreatePageButton = () => {
|
|
|
37
49
|
post,
|
|
38
50
|
locale,
|
|
39
51
|
pageTypeId: pageType.id,
|
|
40
|
-
platformId: initialData.platform[0]?.id,
|
|
41
52
|
collectionTypeId: initialData.id,
|
|
42
53
|
layoutUid: layout.uid,
|
|
43
54
|
relatedEntityId: createLocalizedPage ? linkedPages.data?.[0]?.id : undefined
|
|
44
55
|
});
|
|
45
56
|
if (newPage?.id) {
|
|
46
57
|
await put(`/content-manager/collection-types/${layout.uid}/${initialData.id}`, {
|
|
47
|
-
hasPage:
|
|
58
|
+
hasPage: false
|
|
48
59
|
});
|
|
49
|
-
history.push(`/content-manager/
|
|
60
|
+
history.push(`/content-manager/collection-types/${PAGE_UID}/${newPage.id}?plugins[i18n][locale]=${locale}`);
|
|
50
61
|
}
|
|
51
62
|
} catch (error) {
|
|
52
63
|
console.error(error);
|
|
@@ -68,7 +79,6 @@ interface ICreateNewPageProps {
|
|
|
68
79
|
modules?: Record<string, any>[];
|
|
69
80
|
post: any;
|
|
70
81
|
pageTypeId: number;
|
|
71
|
-
platformId: number;
|
|
72
82
|
relatedEntityId?: number;
|
|
73
83
|
}
|
|
74
84
|
|
|
@@ -80,17 +90,25 @@ const createNewPage = async ({
|
|
|
80
90
|
layoutUid,
|
|
81
91
|
modules,
|
|
82
92
|
pageTypeId,
|
|
83
|
-
platformId,
|
|
84
93
|
relatedEntityId
|
|
85
94
|
}: ICreateNewPageProps) => {
|
|
86
95
|
// Including locale in url is neccesary.
|
|
87
96
|
const relatedEntityIdQuery = relatedEntityId ? `&plugins[i18n][relatedEntityId]=${relatedEntityId}` : '';
|
|
88
97
|
const url = `/content-manager/collection-types/${PAGE_UID}?plugins[i18n][locale]=${locale}${relatedEntityIdQuery}`;
|
|
98
|
+
const slugData = title
|
|
99
|
+
? {
|
|
100
|
+
slug: slugify(title, {
|
|
101
|
+
lower: true,
|
|
102
|
+
trim: true
|
|
103
|
+
})
|
|
104
|
+
}
|
|
105
|
+
: {};
|
|
106
|
+
|
|
89
107
|
const { data: page } = await post(url, {
|
|
108
|
+
...slugData,
|
|
90
109
|
title,
|
|
91
110
|
locale,
|
|
92
111
|
pageType: { connect: [{ id: pageTypeId }] },
|
|
93
|
-
platform: { connect: [{ id: platformId }] },
|
|
94
112
|
collectionTypeData: {
|
|
95
113
|
id: collectionTypeId,
|
|
96
114
|
__type: layoutUid,
|
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
import React, { useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import { useCMEditViewDataManager } from '@strapi/helper-plugin';
|
|
4
|
-
import { Flex
|
|
4
|
+
import { Flex } from '@strapi/design-system';
|
|
5
5
|
import { Link } from '@strapi/icons';
|
|
6
6
|
|
|
7
7
|
import { Wrapper } from '../wrapper';
|
|
8
8
|
import { CreatePageButton } from './CreatePageButton';
|
|
9
9
|
import { PAGE_TYPE_PAGE, PAGE_UID } from '../../../../../shared/utils/constants';
|
|
10
10
|
import S from '../Details/styles';
|
|
11
|
-
import { PlatformSelect } from '../Platform/platform-select';
|
|
12
|
-
import { Platform, useGetPlatforms } from '../../../api/platform';
|
|
13
11
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
}
|
|
12
|
+
export const CollectionTypeSettings = () => {
|
|
13
|
+
const { layout, isCreatingEntry, initialData, modifiedData, onChange } = useCMEditViewDataManager() as any;
|
|
17
14
|
|
|
18
|
-
export const CollectionTypeSettings = ({ onlyPlatform }: CollectionTypeSettingsProps) => {
|
|
19
|
-
const { layout, isCreatingEntry, initialData, onChange } = useCMEditViewDataManager() as any;
|
|
20
|
-
const { data: platforms } = useGetPlatforms({});
|
|
21
|
-
const [selectedPlatform, setSelectedPlatform] = useState<Platform | undefined | null>(initialData?.platform?.[0]);
|
|
22
15
|
const isUserCreatedContentType = layout.uid.startsWith('api::');
|
|
23
|
-
const linkedPage = initialData.page?.[0];
|
|
16
|
+
const [linkedPage, setLinkedPage] = useState<Record<string, any> | undefined>(initialData.page?.[0]);
|
|
24
17
|
|
|
25
18
|
const showCreatePageButton = isUserCreatedContentType && !isCreatingEntry && !linkedPage;
|
|
26
19
|
const url = generateLink(linkedPage?.id, initialData?.locale);
|
|
27
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
|
+
|
|
28
31
|
useEffect(() => {
|
|
29
32
|
if (isCreatingEntry) {
|
|
30
33
|
onChange({
|
|
@@ -36,78 +39,30 @@ export const CollectionTypeSettings = ({ onlyPlatform }: CollectionTypeSettingsP
|
|
|
36
39
|
}
|
|
37
40
|
}, []);
|
|
38
41
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
const setFormValue = (name: string, value?: string | Record<string, any>[]) => {
|
|
44
|
-
onChange({
|
|
45
|
-
target: {
|
|
46
|
-
name,
|
|
47
|
-
value
|
|
48
|
-
},
|
|
49
|
-
shouldSetInitialValue: true
|
|
50
|
-
});
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
const handleSelectPlatform = async (platformId: string) => {
|
|
54
|
-
const platform = platforms?.find((platform) => platform.id === Number(platformId));
|
|
55
|
-
|
|
56
|
-
if (platform && platform.title) {
|
|
57
|
-
setSelectedPlatform(platform);
|
|
58
|
-
const formPlatform = {
|
|
59
|
-
...platform,
|
|
60
|
-
label: platform.title,
|
|
61
|
-
value: platform.id
|
|
62
|
-
};
|
|
63
|
-
setFormValue('platform', [formPlatform]);
|
|
64
|
-
} else {
|
|
65
|
-
setFormValue('platform', []);
|
|
66
|
-
setSelectedPlatform(null);
|
|
67
|
-
}
|
|
68
|
-
};
|
|
42
|
+
if (isCreatingEntry) {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
69
45
|
|
|
70
46
|
return (
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
<
|
|
74
|
-
<PlatformSelect
|
|
75
|
-
platforms={platforms}
|
|
76
|
-
selectedPlatform={selectedPlatform}
|
|
77
|
-
onChange={handleSelectPlatform}
|
|
78
|
-
noLabel
|
|
79
|
-
/>
|
|
80
|
-
</Wrapper>
|
|
81
|
-
)}
|
|
82
|
-
{!isCreatingEntry && !onlyPlatform && (
|
|
83
|
-
<Wrapper title="Gekoppelde pagina">
|
|
84
|
-
<Flex direction="column" gap={4} width="100%" alignItems="start">
|
|
85
|
-
<Box width="100%">
|
|
86
|
-
<PlatformSelect
|
|
87
|
-
platforms={platforms}
|
|
88
|
-
selectedPlatform={selectedPlatform}
|
|
89
|
-
onChange={handleSelectPlatform}
|
|
90
|
-
/>
|
|
91
|
-
</Box>
|
|
92
|
-
{showCreatePageButton && <CreatePageButton />}
|
|
47
|
+
<Wrapper title="Gekoppelde pagina">
|
|
48
|
+
<Flex direction="column" gap={4} width="100%" alignItems="start">
|
|
49
|
+
{showCreatePageButton && <CreatePageButton />}
|
|
93
50
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
</Flex>
|
|
106
|
-
)}
|
|
51
|
+
{url && (
|
|
52
|
+
<Flex direction="column" alignItems="start" width="100%" gap={1}>
|
|
53
|
+
<S.SubtleType variant="omega" fontWeight="bold" textColor="neutral800">
|
|
54
|
+
{PAGE_TYPE_PAGE}
|
|
55
|
+
</S.SubtleType>
|
|
56
|
+
<S.EntityLinkWrapper variant="pi" textColor="neutral800">
|
|
57
|
+
<S.EntityLink title={linkedPage?.title || '-'} to={url} variant="pi">
|
|
58
|
+
<Link />
|
|
59
|
+
{linkedPage?.title || '-'}
|
|
60
|
+
</S.EntityLink>
|
|
61
|
+
</S.EntityLinkWrapper>
|
|
107
62
|
</Flex>
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
63
|
+
)}
|
|
64
|
+
</Flex>
|
|
65
|
+
</Wrapper>
|
|
111
66
|
);
|
|
112
67
|
};
|
|
113
68
|
|
|
@@ -115,5 +70,5 @@ const generateLink = (entityId?: string, locale?: string) => {
|
|
|
115
70
|
if (!entityId) {
|
|
116
71
|
return '';
|
|
117
72
|
}
|
|
118
|
-
return `/content-manager/
|
|
73
|
+
return `/content-manager/collection-types/${PAGE_UID}/${entityId}?plugins[i18n][locale]=${locale}`;
|
|
119
74
|
};
|
|
@@ -12,26 +12,15 @@ interface Props {
|
|
|
12
12
|
entityId?: number;
|
|
13
13
|
entityTitle?: string;
|
|
14
14
|
locale?: string;
|
|
15
|
-
platformTitle?: string;
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
const Details = (props: Props) => {
|
|
19
|
-
const { entityTitle, pageType
|
|
18
|
+
const { entityTitle, pageType } = props;
|
|
20
19
|
|
|
21
20
|
const url = generateLink(props);
|
|
22
21
|
|
|
23
22
|
return (
|
|
24
23
|
<Flex gap={4} width="100%" direction="column">
|
|
25
|
-
{platformTitle && (
|
|
26
|
-
<Flex direction="column" alignItems="start" width="100%" gap={1}>
|
|
27
|
-
<S.SubtleType variant="omega" fontWeight="bold" textColor="neutral800">
|
|
28
|
-
Platform
|
|
29
|
-
</S.SubtleType>
|
|
30
|
-
<S.SubtleType variant="omega" fontWeight="bold" textColor="neutral800">
|
|
31
|
-
{platformTitle}
|
|
32
|
-
</S.SubtleType>
|
|
33
|
-
</Flex>
|
|
34
|
-
)}
|
|
35
24
|
<Flex direction="column" alignItems="start" width="100%" gap={1}>
|
|
36
25
|
<S.SubtleType variant="omega" fontWeight="bold" textColor="neutral800">
|
|
37
26
|
{pageType?.title || PAGE_TYPE_PAGE}
|
|
@@ -54,5 +43,5 @@ const generateLink = ({ locale, pageType, entityId }: Props) => {
|
|
|
54
43
|
return '';
|
|
55
44
|
}
|
|
56
45
|
|
|
57
|
-
return `/content-manager/
|
|
46
|
+
return `/content-manager/collection-types/${pageType.uid}/${entityId}?plugins[i18n][locale]=${locale}`;
|
|
58
47
|
};
|
|
@@ -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
|
+
|
|
7
7
|
import { TemplateSelect } from '../Template/TemplateSelect';
|
|
8
8
|
import { PageTypeSelect } from '../page-type-select';
|
|
9
9
|
import { CollectionTypeSearch } from '../CollectionTypeSearch';
|
|
@@ -11,18 +11,11 @@ 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';
|
|
17
14
|
|
|
18
15
|
export const PageSettings = () => {
|
|
19
16
|
const { isCreatingEntry, initialData, onChange, modifiedData } = useCMEditViewDataManager() as any;
|
|
20
|
-
const { data:
|
|
21
|
-
const { data: platforms } = useGetPlatforms({});
|
|
22
|
-
const [pageTypes, setPageTypes] = useState(allPageTypes);
|
|
17
|
+
const { data: pageTypes } = useGetPageTypes({});
|
|
23
18
|
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]);
|
|
26
19
|
const [isEditting, setIsEditting] = useState(false);
|
|
27
20
|
const showEditFields = useMemo(
|
|
28
21
|
() => isCreatingEntry || !selectedPageType?.id || !initialData.collectionTypeTitle || isEditting,
|
|
@@ -42,24 +35,15 @@ export const PageSettings = () => {
|
|
|
42
35
|
useEffect(() => {
|
|
43
36
|
setSelectedPageType(initialData?.initialPageType);
|
|
44
37
|
|
|
45
|
-
setSelectedPlatform(initialData?.platform?.[0]);
|
|
46
38
|
setIsEditting(false);
|
|
47
39
|
}, [initialData]);
|
|
48
40
|
|
|
49
|
-
useEffect(() => {
|
|
50
|
-
if (selectedPlatform?.title) {
|
|
51
|
-
setPageTypesByPlatform(selectedPlatform.title);
|
|
52
|
-
}
|
|
53
|
-
}, [selectedPlatform, allPageTypes]);
|
|
54
|
-
|
|
55
41
|
const cancelEdit = () => {
|
|
56
42
|
setIsEditting(false);
|
|
57
43
|
setSelectedPageType(initialData?.initialPageType || []);
|
|
58
|
-
setSelectedPlatform(initialData?.platform?.[0]);
|
|
59
44
|
setFormValue('pageType', initialData?.initialPageType || []);
|
|
60
45
|
setFormValue('collectionTypeTitle', initialData?.collectionTypeTitle);
|
|
61
46
|
setFormValue('collectionTypeId', initialData?.collectionTypeId);
|
|
62
|
-
setFormValue('platform', initialData?.platform);
|
|
63
47
|
};
|
|
64
48
|
|
|
65
49
|
const removePageType = () => {
|
|
@@ -86,53 +70,14 @@ export const PageSettings = () => {
|
|
|
86
70
|
}
|
|
87
71
|
};
|
|
88
72
|
|
|
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
|
-
const filterPageTypeByPlatform = platFormData[0].pageTypes.filter(
|
|
114
|
-
(data) => allPageTypes?.find((pageData) => pageData.uid === data.uid)
|
|
115
|
-
);
|
|
116
|
-
|
|
117
|
-
setPageTypes(filterPageTypeByPlatform);
|
|
118
|
-
};
|
|
119
|
-
|
|
120
73
|
return (
|
|
121
74
|
<Wrapper title="Gekoppelde type">
|
|
122
75
|
<Flex direction="column" gap={4} width="100%">
|
|
123
76
|
{showEditFields ? (
|
|
124
77
|
<Stack spacing={4} width="100%">
|
|
125
|
-
<
|
|
126
|
-
<
|
|
127
|
-
|
|
128
|
-
selectedPageType={selectedPageType}
|
|
129
|
-
onChange={handleSelectPageType}
|
|
130
|
-
disabled={noPlatformSelected}
|
|
131
|
-
/>
|
|
132
|
-
<TemplateSelect disabled={noPlatformSelected} />
|
|
133
|
-
{selectedPageType?.uid && (
|
|
134
|
-
<CollectionTypeSearch uid={selectedPageType.uid} platformTitle={selectedPlatform?.title} />
|
|
135
|
-
)}
|
|
78
|
+
<PageTypeSelect pageTypes={pageTypes} selectedPageType={selectedPageType} onChange={handleSelectPageType} />
|
|
79
|
+
<TemplateSelect />
|
|
80
|
+
{selectedPageType?.uid && <CollectionTypeSearch uid={selectedPageType.uid} />}
|
|
136
81
|
</Stack>
|
|
137
82
|
) : (
|
|
138
83
|
<Details
|
|
@@ -140,7 +85,6 @@ export const PageSettings = () => {
|
|
|
140
85
|
pageType={selectedPageType}
|
|
141
86
|
entityId={modifiedData.collectionTypeId}
|
|
142
87
|
entityTitle={modifiedData.collectionTypeTitle}
|
|
143
|
-
platformTitle={selectedPlatform?.title}
|
|
144
88
|
/>
|
|
145
89
|
)}
|
|
146
90
|
{(!showEditFields || isEditting) && (
|
|
@@ -6,7 +6,6 @@ import { PAGE_UID } from '../../../../shared/utils/constants';
|
|
|
6
6
|
import { PageSettings } from './PageSettings';
|
|
7
7
|
import { CollectionTypeSettings } from './CollectionTypeSettings';
|
|
8
8
|
import { useHasPageRelation } from '../../api/has-page-relation';
|
|
9
|
-
import { useHasPlatformRelation } from '../../api/has-platform-relation';
|
|
10
9
|
|
|
11
10
|
export const EditView = () => {
|
|
12
11
|
const { layout } = useCMEditViewDataManager() as any;
|
|
@@ -18,17 +17,12 @@ export const EditView = () => {
|
|
|
18
17
|
uid: layout.uid
|
|
19
18
|
});
|
|
20
19
|
|
|
21
|
-
const { data: hasPlatformRelation, isLoading: isLoadingPlatformRelation } = useHasPlatformRelation({
|
|
22
|
-
uid: layout.uid
|
|
23
|
-
});
|
|
24
|
-
|
|
25
20
|
if (isPageCollectionType) {
|
|
26
21
|
return <PageSettings />;
|
|
27
22
|
}
|
|
28
23
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return <CollectionTypeSettings onlyPlatform={!hasPageRelation && hasPlatformRelation} />;
|
|
24
|
+
if (isCollectionType && !isLoading && hasPageRelation) {
|
|
25
|
+
return <CollectionTypeSettings />;
|
|
32
26
|
}
|
|
33
27
|
|
|
34
28
|
return null;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useLocation } from 'react-router-dom';
|
|
3
|
+
|
|
4
|
+
import { PageTypeFilter } from './page-type-filter';
|
|
5
|
+
import { PAGE_UID } from '../../../../shared/utils/constants';
|
|
6
|
+
|
|
7
|
+
const PageTypeFilterContainer = () => {
|
|
8
|
+
const { pathname } = useLocation();
|
|
9
|
+
|
|
10
|
+
if (pathname === `/content-manager/collection-type/${PAGE_UID}`) {
|
|
11
|
+
return <PageTypeFilter />;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
return null;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default PageTypeFilterContainer;
|