@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
package/server/bootstrap.ts
CHANGED
|
@@ -1,198 +1,198 @@
|
|
|
1
|
-
import { Common, Strapi } from '@strapi/strapi';
|
|
2
|
-
import { errors } from '@strapi/utils';
|
|
3
|
-
import { PAGE_TYPE_UID, PAGE_UID } from '../shared/utils/constants';
|
|
4
|
-
import permissions from './bootstrap/permissions';
|
|
5
|
-
import collectionTypeLifecycles from './bootstrap/collection-type-lifecycles';
|
|
6
|
-
|
|
7
|
-
export default async ({ strapi }: { strapi: Strapi }) => {
|
|
8
|
-
await permissions({ strapi });
|
|
9
|
-
await collectionTypeLifecycles({ strapi });
|
|
10
|
-
|
|
11
|
-
const updateCollectionTypeData = (data: any, collectionTypeId: number, uid: string) => {
|
|
12
|
-
data.collectionTypeData = {
|
|
13
|
-
id: collectionTypeId,
|
|
14
|
-
__type: uid,
|
|
15
|
-
__pivot: {
|
|
16
|
-
field: 'page'
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
return data;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
strapi.db?.lifecycles.subscribe({
|
|
24
|
-
// @ts-ignore
|
|
25
|
-
models: [PAGE_UID],
|
|
26
|
-
async beforeCreate(event) {
|
|
27
|
-
let { data } = event.params;
|
|
28
|
-
const collectionTypeId = data?.collectionTypeId;
|
|
29
|
-
const pageTypeId = data?.pageType.connect?.[0]?.id || data.initialPageType;
|
|
30
|
-
|
|
31
|
-
if (collectionTypeId && pageTypeId) {
|
|
32
|
-
const pageType: Record<string, any> | undefined | null = await strapi.entityService?.findOne(
|
|
33
|
-
PAGE_TYPE_UID,
|
|
34
|
-
pageTypeId
|
|
35
|
-
);
|
|
36
|
-
const collectionToConnect = await strapi.entityService?.findOne(pageType?.uid, collectionTypeId, {
|
|
37
|
-
populate: { page: true }
|
|
38
|
-
});
|
|
39
|
-
|
|
40
|
-
const page: Record<string, any>[] = collectionToConnect?.page as any;
|
|
41
|
-
|
|
42
|
-
if (page && page.length > 0) {
|
|
43
|
-
throw new errors.ValidationError('You can only link one CollectionType to one page');
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
data = updateCollectionTypeData(data, collectionTypeId, pageType?.uid);
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
async beforeUpdate(event) {
|
|
50
|
-
let { data, where } = event?.params;
|
|
51
|
-
|
|
52
|
-
const collectionTypeId = data?.collectionTypeId;
|
|
53
|
-
const pageTypeId = data?.pageType?.connect?.[0]?.id || data?.initialPageType;
|
|
54
|
-
const removedPageType = data?.pageType?.disconnect?.[0]?.id;
|
|
55
|
-
|
|
56
|
-
const originalEntity = await strapi.entityService?.findOne(
|
|
57
|
-
event.model.uid as Common.UID.CollectionType,
|
|
58
|
-
data.id || where.id,
|
|
59
|
-
{
|
|
60
|
-
populate: {
|
|
61
|
-
collectionTypeData: true
|
|
62
|
-
}
|
|
63
|
-
} as Record<string, any>
|
|
64
|
-
);
|
|
65
|
-
|
|
66
|
-
if (removedPageType || collectionTypeId === null) {
|
|
67
|
-
data.collectionTypeData = undefined;
|
|
68
|
-
|
|
69
|
-
if (originalEntity?.collectionTypeData?.[0]?.__type && originalEntity?.collectionTypeData?.[0]?.id) {
|
|
70
|
-
strapi.entityService?.update(
|
|
71
|
-
originalEntity.collectionTypeData[0].__type,
|
|
72
|
-
originalEntity.collectionTypeData[0].id,
|
|
73
|
-
{
|
|
74
|
-
data: {
|
|
75
|
-
id: originalEntity.collectionTypeData.id,
|
|
76
|
-
hasPage: false
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
);
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
if (collectionTypeId && pageTypeId && !removedPageType) {
|
|
84
|
-
const pageType: Record<string, any> | undefined | null = await strapi.entityService?.findOne(
|
|
85
|
-
PAGE_TYPE_UID,
|
|
86
|
-
pageTypeId
|
|
87
|
-
);
|
|
88
|
-
const collectionToConnect = await strapi.entityService?.findOne(pageType?.uid, collectionTypeId, {
|
|
89
|
-
populate: { page: true }
|
|
90
|
-
});
|
|
91
|
-
|
|
92
|
-
const page: Record<string, any>[] = collectionToConnect?.page as any;
|
|
93
|
-
|
|
94
|
-
if (page && page?.length > 0 && !page.some((p) => p.id === data.id)) {
|
|
95
|
-
throw new errors.ValidationError('You can only link one CollectionType to one page');
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
data = updateCollectionTypeData(data, collectionTypeId, pageType?.uid);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
// needs to check if the collectionTypeData is already connected to another page
|
|
102
|
-
// if so, remove the hasPage for filtering
|
|
103
|
-
if (
|
|
104
|
-
data.collectionTypeData &&
|
|
105
|
-
originalEntity?.collectionTypeData?.[0]?.__type &&
|
|
106
|
-
originalEntity?.collectionTypeData?.[0]?.id &&
|
|
107
|
-
Number(data.collectionTypeData.id) !== Number(originalEntity.collectionTypeData[0].id)
|
|
108
|
-
) {
|
|
109
|
-
await strapi.entityService?.update(
|
|
110
|
-
originalEntity.collectionTypeData[0].__type,
|
|
111
|
-
originalEntity.collectionTypeData[0].id,
|
|
112
|
-
{
|
|
113
|
-
data: {
|
|
114
|
-
id: originalEntity.collectionTypeData[0].id,
|
|
115
|
-
hasPage: false,
|
|
116
|
-
lifecycleState: {
|
|
117
|
-
exit: true
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
},
|
|
124
|
-
async afterUpdate(event) {
|
|
125
|
-
const data = event?.params?.data;
|
|
126
|
-
|
|
127
|
-
if (data.collectionTypeData?.__type && data.collectionTypeData.id) {
|
|
128
|
-
await strapi.entityService?.update(data.collectionTypeData.__type, data.collectionTypeData.id, {
|
|
129
|
-
data: {
|
|
130
|
-
id: data.collectionTypeData.id,
|
|
131
|
-
hasPage: true,
|
|
132
|
-
lifecycleState: {
|
|
133
|
-
exit: true
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
});
|
|
137
|
-
}
|
|
138
|
-
},
|
|
139
|
-
async afterCreate(event) {
|
|
140
|
-
const data = event?.params?.data;
|
|
141
|
-
if (data.collectionTypeData?.__type && data.collectionTypeData.id) {
|
|
142
|
-
await strapi.entityService?.update(data.collectionTypeData.__type, data.collectionTypeData.id, {
|
|
143
|
-
data: {
|
|
144
|
-
id: data.collectionTypeData.id,
|
|
145
|
-
hasPage: true,
|
|
146
|
-
lifecycleState: {
|
|
147
|
-
exit: true
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
},
|
|
153
|
-
async beforeDelete(event) {
|
|
154
|
-
const originalEntity = (await strapi.entityService?.findOne(PAGE_UID, event.params.where.id, {
|
|
155
|
-
populate: {
|
|
156
|
-
collectionTypeData: true
|
|
157
|
-
}
|
|
158
|
-
})) as Record<string, any> | undefined;
|
|
159
|
-
|
|
160
|
-
if (originalEntity?.collectionTypeData?.[0]?.__type && originalEntity?.collectionTypeData?.[0]?.id) {
|
|
161
|
-
await strapi.entityService?.update(
|
|
162
|
-
originalEntity.collectionTypeData[0].__type,
|
|
163
|
-
originalEntity.collectionTypeData[0].id,
|
|
164
|
-
{
|
|
165
|
-
data: {
|
|
166
|
-
id: originalEntity.collectionTypeData[0].id,
|
|
167
|
-
hasPage: false
|
|
168
|
-
}
|
|
169
|
-
}
|
|
170
|
-
);
|
|
171
|
-
}
|
|
172
|
-
},
|
|
173
|
-
async beforeDeleteMany(event) {
|
|
174
|
-
const pagesToDisconnect = event.params.where?.['$and']?.[0]?.id?.['$in'];
|
|
175
|
-
|
|
176
|
-
for (const pageId of pagesToDisconnect) {
|
|
177
|
-
const originalEntity = (await strapi.entityService?.findOne(PAGE_UID, pageId, {
|
|
178
|
-
populate: {
|
|
179
|
-
collectionTypeData: true
|
|
180
|
-
}
|
|
181
|
-
})) as Record<string, any> | undefined;
|
|
182
|
-
|
|
183
|
-
if (originalEntity?.collectionTypeData?.[0]?.__type && originalEntity?.collectionTypeData?.[0]?.id) {
|
|
184
|
-
await strapi.entityService?.update(
|
|
185
|
-
originalEntity.collectionTypeData[0].__type,
|
|
186
|
-
originalEntity.collectionTypeData[0].id,
|
|
187
|
-
{
|
|
188
|
-
data: {
|
|
189
|
-
id: originalEntity.collectionTypeData[0].id,
|
|
190
|
-
hasPage: false
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
}
|
|
197
|
-
});
|
|
198
|
-
};
|
|
1
|
+
import { Common, Strapi } from '@strapi/strapi';
|
|
2
|
+
import { errors } from '@strapi/utils';
|
|
3
|
+
import { PAGE_TYPE_UID, PAGE_UID } from '../shared/utils/constants';
|
|
4
|
+
import permissions from './bootstrap/permissions';
|
|
5
|
+
import collectionTypeLifecycles from './bootstrap/collection-type-lifecycles';
|
|
6
|
+
|
|
7
|
+
export default async ({ strapi }: { strapi: Strapi }) => {
|
|
8
|
+
await permissions({ strapi });
|
|
9
|
+
await collectionTypeLifecycles({ strapi });
|
|
10
|
+
|
|
11
|
+
const updateCollectionTypeData = (data: any, collectionTypeId: number, uid: string) => {
|
|
12
|
+
data.collectionTypeData = {
|
|
13
|
+
id: collectionTypeId,
|
|
14
|
+
__type: uid,
|
|
15
|
+
__pivot: {
|
|
16
|
+
field: 'page'
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return data;
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
strapi.db?.lifecycles.subscribe({
|
|
24
|
+
// @ts-ignore
|
|
25
|
+
models: [PAGE_UID],
|
|
26
|
+
async beforeCreate(event) {
|
|
27
|
+
let { data } = event.params;
|
|
28
|
+
const collectionTypeId = data?.collectionTypeId;
|
|
29
|
+
const pageTypeId = data?.pageType.connect?.[0]?.id || data.initialPageType;
|
|
30
|
+
|
|
31
|
+
if (collectionTypeId && pageTypeId) {
|
|
32
|
+
const pageType: Record<string, any> | undefined | null = await strapi.entityService?.findOne(
|
|
33
|
+
PAGE_TYPE_UID,
|
|
34
|
+
pageTypeId
|
|
35
|
+
);
|
|
36
|
+
const collectionToConnect = await strapi.entityService?.findOne(pageType?.uid, collectionTypeId, {
|
|
37
|
+
populate: { page: true }
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
const page: Record<string, any>[] = collectionToConnect?.page as any;
|
|
41
|
+
|
|
42
|
+
if (page && page.length > 0) {
|
|
43
|
+
throw new errors.ValidationError('You can only link one CollectionType to one page');
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
data = updateCollectionTypeData(data, collectionTypeId, pageType?.uid);
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
async beforeUpdate(event) {
|
|
50
|
+
let { data, where } = event?.params;
|
|
51
|
+
|
|
52
|
+
const collectionTypeId = data?.collectionTypeId;
|
|
53
|
+
const pageTypeId = data?.pageType?.connect?.[0]?.id || data?.initialPageType;
|
|
54
|
+
const removedPageType = data?.pageType?.disconnect?.[0]?.id;
|
|
55
|
+
|
|
56
|
+
const originalEntity = await strapi.entityService?.findOne(
|
|
57
|
+
event.model.uid as Common.UID.CollectionType,
|
|
58
|
+
data.id || where.id,
|
|
59
|
+
{
|
|
60
|
+
populate: {
|
|
61
|
+
collectionTypeData: true
|
|
62
|
+
}
|
|
63
|
+
} as Record<string, any>
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
if (removedPageType || collectionTypeId === null) {
|
|
67
|
+
data.collectionTypeData = undefined;
|
|
68
|
+
|
|
69
|
+
if (originalEntity?.collectionTypeData?.[0]?.__type && originalEntity?.collectionTypeData?.[0]?.id) {
|
|
70
|
+
strapi.entityService?.update(
|
|
71
|
+
originalEntity.collectionTypeData[0].__type,
|
|
72
|
+
originalEntity.collectionTypeData[0].id,
|
|
73
|
+
{
|
|
74
|
+
data: {
|
|
75
|
+
id: originalEntity.collectionTypeData.id,
|
|
76
|
+
hasPage: false
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
if (collectionTypeId && pageTypeId && !removedPageType) {
|
|
84
|
+
const pageType: Record<string, any> | undefined | null = await strapi.entityService?.findOne(
|
|
85
|
+
PAGE_TYPE_UID,
|
|
86
|
+
pageTypeId
|
|
87
|
+
);
|
|
88
|
+
const collectionToConnect = await strapi.entityService?.findOne(pageType?.uid, collectionTypeId, {
|
|
89
|
+
populate: { page: true }
|
|
90
|
+
});
|
|
91
|
+
|
|
92
|
+
const page: Record<string, any>[] = collectionToConnect?.page as any;
|
|
93
|
+
|
|
94
|
+
if (page && page?.length > 0 && !page.some((p) => p.id === data.id)) {
|
|
95
|
+
throw new errors.ValidationError('You can only link one CollectionType to one page');
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
data = updateCollectionTypeData(data, collectionTypeId, pageType?.uid);
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
// needs to check if the collectionTypeData is already connected to another page
|
|
102
|
+
// if so, remove the hasPage for filtering
|
|
103
|
+
if (
|
|
104
|
+
data.collectionTypeData &&
|
|
105
|
+
originalEntity?.collectionTypeData?.[0]?.__type &&
|
|
106
|
+
originalEntity?.collectionTypeData?.[0]?.id &&
|
|
107
|
+
Number(data.collectionTypeData.id) !== Number(originalEntity.collectionTypeData[0].id)
|
|
108
|
+
) {
|
|
109
|
+
await strapi.entityService?.update(
|
|
110
|
+
originalEntity.collectionTypeData[0].__type,
|
|
111
|
+
originalEntity.collectionTypeData[0].id,
|
|
112
|
+
{
|
|
113
|
+
data: {
|
|
114
|
+
id: originalEntity.collectionTypeData[0].id,
|
|
115
|
+
hasPage: false,
|
|
116
|
+
lifecycleState: {
|
|
117
|
+
exit: true
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
);
|
|
122
|
+
}
|
|
123
|
+
},
|
|
124
|
+
async afterUpdate(event) {
|
|
125
|
+
const data = event?.params?.data;
|
|
126
|
+
|
|
127
|
+
if (data.collectionTypeData?.__type && data.collectionTypeData.id) {
|
|
128
|
+
await strapi.entityService?.update(data.collectionTypeData.__type, data.collectionTypeData.id, {
|
|
129
|
+
data: {
|
|
130
|
+
id: data.collectionTypeData.id,
|
|
131
|
+
hasPage: true,
|
|
132
|
+
lifecycleState: {
|
|
133
|
+
exit: true
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
},
|
|
139
|
+
async afterCreate(event) {
|
|
140
|
+
const data = event?.params?.data;
|
|
141
|
+
if (data.collectionTypeData?.__type && data.collectionTypeData.id) {
|
|
142
|
+
await strapi.entityService?.update(data.collectionTypeData.__type, data.collectionTypeData.id, {
|
|
143
|
+
data: {
|
|
144
|
+
id: data.collectionTypeData.id,
|
|
145
|
+
hasPage: true,
|
|
146
|
+
lifecycleState: {
|
|
147
|
+
exit: true
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
},
|
|
153
|
+
async beforeDelete(event) {
|
|
154
|
+
const originalEntity = (await strapi.entityService?.findOne(PAGE_UID, event.params.where.id, {
|
|
155
|
+
populate: {
|
|
156
|
+
collectionTypeData: true
|
|
157
|
+
}
|
|
158
|
+
})) as Record<string, any> | undefined;
|
|
159
|
+
|
|
160
|
+
if (originalEntity?.collectionTypeData?.[0]?.__type && originalEntity?.collectionTypeData?.[0]?.id) {
|
|
161
|
+
await strapi.entityService?.update(
|
|
162
|
+
originalEntity.collectionTypeData[0].__type,
|
|
163
|
+
originalEntity.collectionTypeData[0].id,
|
|
164
|
+
{
|
|
165
|
+
data: {
|
|
166
|
+
id: originalEntity.collectionTypeData[0].id,
|
|
167
|
+
hasPage: false
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
);
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
async beforeDeleteMany(event) {
|
|
174
|
+
const pagesToDisconnect = event.params.where?.['$and']?.[0]?.id?.['$in'];
|
|
175
|
+
|
|
176
|
+
for (const pageId of pagesToDisconnect) {
|
|
177
|
+
const originalEntity = (await strapi.entityService?.findOne(PAGE_UID, pageId, {
|
|
178
|
+
populate: {
|
|
179
|
+
collectionTypeData: true
|
|
180
|
+
}
|
|
181
|
+
})) as Record<string, any> | undefined;
|
|
182
|
+
|
|
183
|
+
if (originalEntity?.collectionTypeData?.[0]?.__type && originalEntity?.collectionTypeData?.[0]?.id) {
|
|
184
|
+
await strapi.entityService?.update(
|
|
185
|
+
originalEntity.collectionTypeData[0].__type,
|
|
186
|
+
originalEntity.collectionTypeData[0].id,
|
|
187
|
+
{
|
|
188
|
+
data: {
|
|
189
|
+
id: originalEntity.collectionTypeData[0].id,
|
|
190
|
+
hasPage: false
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
});
|
|
198
|
+
};
|
package/server/config/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export default {
|
|
2
|
-
default: {},
|
|
3
|
-
validator() {}
|
|
4
|
-
};
|
|
1
|
+
export default {
|
|
2
|
+
default: {},
|
|
3
|
+
validator() {}
|
|
4
|
+
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export default {};
|
|
1
|
+
export default {};
|
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
import { Strapi } from '@strapi/strapi';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
async hasPageRelation(ctx: any) {
|
|
5
|
-
const uid = ctx.params?.uid;
|
|
6
|
-
|
|
7
|
-
return (strapi as Strapi).service('plugin::page-builder.collection-types').hasPageRelation(uid);
|
|
8
|
-
},
|
|
9
|
-
async getTranslationPageLinks(ctx: any): Promise<IGetTranslationPageLinks[] | undefined> {
|
|
10
|
-
const { uid, ids } = ctx.params || {};
|
|
11
|
-
const idsArr = (ids as string)
|
|
12
|
-
?.split(',')
|
|
13
|
-
.map(Number)
|
|
14
|
-
.filter((x) => !isNaN(x));
|
|
15
|
-
|
|
16
|
-
if (!uid || idsArr?.length === 0) {
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
return (strapi as Strapi).service('plugin::page-builder.collection-types').getTranslationPageLinks(uid, idsArr);
|
|
21
|
-
}
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export interface IGetTranslationPageLinks {
|
|
25
|
-
id: number;
|
|
26
|
-
locale: string;
|
|
27
|
-
}
|
|
1
|
+
import { Strapi } from '@strapi/strapi';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
async hasPageRelation(ctx: any) {
|
|
5
|
+
const uid = ctx.params?.uid;
|
|
6
|
+
|
|
7
|
+
return (strapi as Strapi).service('plugin::page-builder.collection-types').hasPageRelation(uid);
|
|
8
|
+
},
|
|
9
|
+
async getTranslationPageLinks(ctx: any): Promise<IGetTranslationPageLinks[] | undefined> {
|
|
10
|
+
const { uid, ids } = ctx.params || {};
|
|
11
|
+
const idsArr = (ids as string)
|
|
12
|
+
?.split(',')
|
|
13
|
+
.map(Number)
|
|
14
|
+
.filter((x) => !isNaN(x));
|
|
15
|
+
|
|
16
|
+
if (!uid || idsArr?.length === 0) {
|
|
17
|
+
return undefined;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return (strapi as Strapi).service('plugin::page-builder.collection-types').getTranslationPageLinks(uid, idsArr);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export interface IGetTranslationPageLinks {
|
|
25
|
+
id: number;
|
|
26
|
+
locale: string;
|
|
27
|
+
}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import page from './page';
|
|
2
|
-
import pageType from './page-type';
|
|
3
|
-
import collectionTypes from './collection-types';
|
|
4
|
-
import template from './template';
|
|
5
|
-
|
|
6
|
-
export default {
|
|
7
|
-
page,
|
|
8
|
-
'page-type': pageType,
|
|
9
|
-
'collection-types': collectionTypes,
|
|
10
|
-
template
|
|
11
|
-
};
|
|
1
|
+
import page from './page';
|
|
2
|
+
import pageType from './page-type';
|
|
3
|
+
import collectionTypes from './collection-types';
|
|
4
|
+
import template from './template';
|
|
5
|
+
|
|
6
|
+
export default {
|
|
7
|
+
page,
|
|
8
|
+
'page-type': pageType,
|
|
9
|
+
'collection-types': collectionTypes,
|
|
10
|
+
template
|
|
11
|
+
};
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Strapi } from '@strapi/strapi';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
async findOneByUid(ctx: any) {
|
|
5
|
-
const uid = ctx?.params?.uid;
|
|
6
|
-
|
|
7
|
-
if (!uid) {
|
|
8
|
-
return ctx.badRequest('uid is missing.');
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return await (strapi as Strapi).service('plugin::page-builder.page-type').findOneByUid(uid);
|
|
12
|
-
}
|
|
13
|
-
};
|
|
1
|
+
import { Strapi } from '@strapi/strapi';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
async findOneByUid(ctx: any) {
|
|
5
|
+
const uid = ctx?.params?.uid;
|
|
6
|
+
|
|
7
|
+
if (!uid) {
|
|
8
|
+
return ctx.badRequest('uid is missing.');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return await (strapi as Strapi).service('plugin::page-builder.page-type').findOneByUid(uid);
|
|
12
|
+
}
|
|
13
|
+
};
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { Strapi } from '@strapi/strapi';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
async getPage(ctx) {
|
|
5
|
-
const id = ctx.params?.id;
|
|
6
|
-
|
|
7
|
-
return (strapi as Strapi).service('plugin::page-builder.page')?.getPage(id);
|
|
8
|
-
}
|
|
9
|
-
};
|
|
1
|
+
import { Strapi } from '@strapi/strapi';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
async getPage(ctx) {
|
|
5
|
+
const id = ctx.params?.id;
|
|
6
|
+
|
|
7
|
+
return (strapi as Strapi).service('plugin::page-builder.page')?.getPage(id);
|
|
8
|
+
}
|
|
9
|
+
};
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import { Strapi } from '@strapi/strapi';
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
async findOneById(ctx: any) {
|
|
5
|
-
const id = ctx?.params?.id;
|
|
6
|
-
|
|
7
|
-
if (!id) {
|
|
8
|
-
return ctx.badRequest('id is missing.');
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
return await (strapi as Strapi).service('plugin::page-builder.template').findOne(id);
|
|
12
|
-
},
|
|
13
|
-
async findAll() {
|
|
14
|
-
return await (strapi as Strapi).service('plugin::page-builder.template').findAll();
|
|
15
|
-
}
|
|
16
|
-
};
|
|
1
|
+
import { Strapi } from '@strapi/strapi';
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
async findOneById(ctx: any) {
|
|
5
|
+
const id = ctx?.params?.id;
|
|
6
|
+
|
|
7
|
+
if (!id) {
|
|
8
|
+
return ctx.badRequest('id is missing.');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return await (strapi as Strapi).service('plugin::page-builder.template').findOne(id);
|
|
12
|
+
},
|
|
13
|
+
async findAll() {
|
|
14
|
+
return await (strapi as Strapi).service('plugin::page-builder.template').findAll();
|
|
15
|
+
}
|
|
16
|
+
};
|
package/server/destroy.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Strapi } from '@strapi/strapi';
|
|
2
|
-
|
|
3
|
-
export default ({ strapi }: { strapi: Strapi }) => {
|
|
4
|
-
// destroy phase
|
|
5
|
-
};
|
|
1
|
+
import { Strapi } from '@strapi/strapi';
|
|
2
|
+
|
|
3
|
+
export default ({ strapi }: { strapi: Strapi }) => {
|
|
4
|
+
// destroy phase
|
|
5
|
+
};
|
package/server/graphql/index.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import pageType from './page-type';
|
|
2
|
-
import pageBySlug from './page-by-slug';
|
|
3
|
-
import getPageInfoFromUID from './pages-by-uid';
|
|
4
|
-
|
|
5
|
-
export default {
|
|
6
|
-
getPageInfoFromUID,
|
|
7
|
-
pageType,
|
|
8
|
-
pageBySlug
|
|
9
|
-
};
|
|
1
|
+
import pageType from './page-type';
|
|
2
|
+
import pageBySlug from './page-by-slug';
|
|
3
|
+
import getPageInfoFromUID from './pages-by-uid';
|
|
4
|
+
|
|
5
|
+
export default {
|
|
6
|
+
getPageInfoFromUID,
|
|
7
|
+
pageType,
|
|
8
|
+
pageBySlug
|
|
9
|
+
};
|