@blaze-cms/plugin-data-ui 0.146.0-translations.8 → 0.147.0-rc-eagle.2
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/lib/components/EntityDataListing/EntityDataListing.js +21 -19
- package/lib/components/EntityDataListing/EntityDataListing.js.map +1 -1
- package/lib/components/EntityDataListing/index.js +2 -3
- package/lib/components/EntityDataListing/index.js.map +1 -1
- package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +18 -19
- package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js.map +1 -1
- package/lib/components/EntityManager/Entity/EntitiyNavLinks/index.js +2 -3
- package/lib/components/EntityManager/Entity/EntitiyNavLinks/index.js.map +1 -1
- package/lib/components/EntityManager/Entity/Entity.js +286 -458
- package/lib/components/EntityManager/Entity/Entity.js.map +1 -1
- package/lib/components/EntityManager/Entity/EntityHeader/EntityHeader.js +62 -66
- package/lib/components/EntityManager/Entity/EntityHeader/EntityHeader.js.map +1 -1
- package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js +32 -56
- package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js.map +1 -1
- package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/index.js +2 -3
- package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/index.js.map +1 -1
- package/lib/components/EntityManager/Entity/EntityHeader/index.js +2 -3
- package/lib/components/EntityManager/Entity/EntityHeader/index.js.map +1 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +20 -26
- package/lib/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js.map +1 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +20 -17
- package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +1 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +34 -32
- package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +1 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/index.js +95 -158
- package/lib/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +23 -30
- package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +1 -1
- package/lib/components/EntityManager/Entity/actions-handlers/create/index.js +2 -3
- package/lib/components/EntityManager/Entity/actions-handlers/create/index.js.map +1 -1
- package/lib/components/EntityManager/Entity/actions-handlers/create/submit.js +42 -56
- package/lib/components/EntityManager/Entity/actions-handlers/create/submit.js.map +1 -1
- package/lib/components/EntityManager/Entity/actions-handlers/delete/delete.js +29 -45
- package/lib/components/EntityManager/Entity/actions-handlers/delete/delete.js.map +1 -1
- package/lib/components/EntityManager/Entity/actions-handlers/delete/index.js +2 -3
- package/lib/components/EntityManager/Entity/actions-handlers/delete/index.js.map +1 -1
- package/lib/components/EntityManager/Entity/actions-handlers/index.js +7 -8
- package/lib/components/EntityManager/Entity/actions-handlers/index.js.map +1 -1
- package/lib/components/EntityManager/Entity/actions-handlers/shared/index.js +2 -3
- package/lib/components/EntityManager/Entity/actions-handlers/shared/index.js.map +1 -1
- package/lib/components/EntityManager/Entity/actions-handlers/shared/publish.js +36 -57
- package/lib/components/EntityManager/Entity/actions-handlers/shared/publish.js.map +1 -1
- package/lib/components/EntityManager/Entity/actions-handlers/update/index.js +2 -3
- package/lib/components/EntityManager/Entity/actions-handlers/update/index.js.map +1 -1
- package/lib/components/EntityManager/Entity/actions-handlers/update/submit.js +47 -66
- package/lib/components/EntityManager/Entity/actions-handlers/update/submit.js.map +1 -1
- package/lib/components/EntityManager/Entity/index.js +2 -3
- package/lib/components/EntityManager/Entity/index.js.map +1 -1
- package/lib/components/EntityManager/EntityManager.js +91 -166
- package/lib/components/EntityManager/EntityManager.js.map +1 -1
- package/lib/components/EntityManager/index.js +2 -3
- package/lib/components/EntityManager/index.js.map +1 -1
- package/lib/components/EntityManager/utils/RecordEditContext/index.js +3 -4
- package/lib/components/EntityManager/utils/RecordEditContext/index.js.map +1 -1
- package/lib/components/EntityManager/utils/data-mappers.js +34 -46
- package/lib/components/EntityManager/utils/data-mappers.js.map +1 -1
- package/lib/components/EntityManager/utils/entity.js +35 -80
- package/lib/components/EntityManager/utils/entity.js.map +1 -1
- package/lib/components/EntityManager/utils/entityAvailableActions.js +51 -110
- package/lib/components/EntityManager/utils/entityAvailableActions.js.map +1 -1
- package/lib/components/EntityManager/utils/is-form-empty.js +6 -10
- package/lib/components/EntityManager/utils/is-form-empty.js.map +1 -1
- package/lib/components/EntityManager/utils/query.js +17 -10
- package/lib/components/EntityManager/utils/query.js.map +1 -1
- package/lib/components/InfoBoxes/InfoBoxTooltip.js +19 -16
- package/lib/components/InfoBoxes/InfoBoxTooltip.js.map +1 -1
- package/lib/components/InfoBoxes/InfoBoxes.js +19 -19
- package/lib/components/InfoBoxes/InfoBoxes.js.map +1 -1
- package/lib/components/InfoBoxes/container/InfoBoxContainer.js +26 -38
- package/lib/components/InfoBoxes/container/InfoBoxContainer.js.map +1 -1
- package/lib/components/InfoBoxes/helpers/build-dynamic-query.js +21 -16
- package/lib/components/InfoBoxes/helpers/build-dynamic-query.js.map +1 -1
- package/lib/components/InfoBoxes/hooks/useData.js +33 -30
- package/lib/components/InfoBoxes/hooks/useData.js.map +1 -1
- package/lib/components/InfoBoxes/hooks/useInfoBox.js +10 -10
- package/lib/components/InfoBoxes/hooks/useInfoBox.js.map +1 -1
- package/lib/components/InfoBoxes/index.js +2 -3
- package/lib/components/InfoBoxes/index.js.map +1 -1
- package/lib/components/InfoBoxes/presentational/InfoBox.js +27 -34
- package/lib/components/InfoBoxes/presentational/InfoBox.js.map +1 -1
- package/lib/components/InfoBoxes/presentational/InfoBoxLabel.js +11 -12
- package/lib/components/InfoBoxes/presentational/InfoBoxLabel.js.map +1 -1
- package/lib/components/InfoBoxes/presentational/InfoBoxValue.js +12 -12
- package/lib/components/InfoBoxes/presentational/InfoBoxValue.js.map +1 -1
- package/lib/components/ListingTable/ListingTable.js +155 -296
- package/lib/components/ListingTable/ListingTable.js.map +1 -1
- package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js +53 -58
- package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
- package/lib/components/ListingTable/ListingTableContent/index.js +2 -3
- package/lib/components/ListingTable/ListingTableContent/index.js.map +1 -1
- package/lib/components/ListingTable/SearchFilter/SearchContainer.js +159 -257
- package/lib/components/ListingTable/SearchFilter/SearchContainer.js.map +1 -1
- package/lib/components/ListingTable/SearchFilter/SearchFilter.js +25 -36
- package/lib/components/ListingTable/SearchFilter/SearchFilter.js.map +1 -1
- package/lib/components/ListingTable/SearchFilter/helpers.js +46 -68
- package/lib/components/ListingTable/SearchFilter/helpers.js.map +1 -1
- package/lib/components/ListingTable/SearchFilter/querys.js +5 -5
- package/lib/components/ListingTable/SearchFilter/querys.js.map +1 -1
- package/lib/components/ListingTable/TableActions/TableActions.js +27 -31
- package/lib/components/ListingTable/TableActions/TableActions.js.map +1 -1
- package/lib/components/ListingTable/TableActions/index.js +2 -3
- package/lib/components/ListingTable/TableActions/index.js.map +1 -1
- package/lib/components/ListingTable/index.js +2 -3
- package/lib/components/ListingTable/index.js.map +1 -1
- package/lib/components/ListingTable/mappers/populate-rows.js +103 -122
- package/lib/components/ListingTable/mappers/populate-rows.js.map +1 -1
- package/lib/components/ListingTable/service/index.js +66 -83
- package/lib/components/ListingTable/service/index.js.map +1 -1
- package/lib/components/Tabs/index.js +26 -42
- package/lib/components/Tabs/index.js.map +1 -1
- package/lib/components/hooks/useCallbackDebounce.js +5 -9
- package/lib/components/hooks/useCallbackDebounce.js.map +1 -1
- package/lib/constants.js +30 -31
- package/lib/constants.js.map +1 -1
- package/lib/icons/ContentIcon.js +17 -20
- package/lib/icons/ContentIcon.js.map +1 -1
- package/lib/icons/SettingsIcon.js +12 -15
- package/lib/icons/SettingsIcon.js.map +1 -1
- package/lib/icons/TaxonomyIcon.js +15 -18
- package/lib/icons/TaxonomyIcon.js.map +1 -1
- package/lib/icons/UsersIcon.js +11 -14
- package/lib/icons/UsersIcon.js.map +1 -1
- package/lib/icons/index.js +8 -9
- package/lib/icons/index.js.map +1 -1
- package/lib/index.js +81 -121
- package/lib/index.js.map +1 -1
- package/lib/utils/add-content-menu-items.js +67 -93
- package/lib/utils/add-content-menu-items.js.map +1 -1
- package/lib/utils/build-create-entity-mutation.js +12 -9
- package/lib/utils/build-create-entity-mutation.js.map +1 -1
- package/lib/utils/build-delete-entity-mutation.js +11 -8
- package/lib/utils/build-delete-entity-mutation.js.map +1 -1
- package/lib/utils/build-listing-query.js +17 -14
- package/lib/utils/build-listing-query.js.map +1 -1
- package/lib/utils/build-update-data-query.js +15 -9
- package/lib/utils/build-update-data-query.js.map +1 -1
- package/lib/utils/build-update-publish-unpublish-mutation.js +15 -8
- package/lib/utils/build-update-publish-unpublish-mutation.js.map +1 -1
- package/lib/utils/get-default-query-params.js +7 -6
- package/lib/utils/get-default-query-params.js.map +1 -1
- package/lib/utils/hoc/withContext.js +4 -6
- package/lib/utils/hoc/withContext.js.map +1 -1
- package/lib/utils/hooks/useToggle.js +4 -12
- package/lib/utils/hooks/useToggle.js.map +1 -1
- package/lib/utils/index.js +2 -3
- package/lib/utils/index.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/Entity.js +15 -26
- package/lib-es/components/EntityManager/Entity/Entity.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/EntityHeader/EntityHeader.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js +6 -3
- package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/actions-handlers/create/submit.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/actions-handlers/shared/publish.js.map +1 -1
- package/lib-es/components/EntityManager/EntityManager.js.map +1 -1
- package/lib-es/components/EntityManager/utils/entity.js.map +1 -1
- package/lib-es/components/EntityManager/utils/query.js.map +1 -1
- package/lib-es/components/InfoBoxes/InfoBoxTooltip.js.map +1 -1
- package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js.map +1 -1
- package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js.map +1 -1
- package/lib-es/components/InfoBoxes/hooks/useData.js.map +1 -1
- package/lib-es/components/InfoBoxes/presentational/InfoBox.js.map +1 -1
- package/lib-es/components/InfoBoxes/presentational/InfoBoxLabel.js.map +1 -1
- package/lib-es/components/ListingTable/ListingTable.js +2 -2
- package/lib-es/components/ListingTable/ListingTable.js.map +1 -1
- package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js +20 -17
- package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
- package/lib-es/components/ListingTable/SearchFilter/SearchContainer.js.map +1 -1
- package/lib-es/components/ListingTable/SearchFilter/helpers.js.map +1 -1
- package/lib-es/components/ListingTable/SearchFilter/querys.js.map +1 -1
- package/lib-es/components/ListingTable/mappers/populate-rows.js.map +1 -1
- package/lib-es/components/ListingTable/service/index.js.map +1 -1
- package/lib-es/components/Tabs/index.js +6 -7
- package/lib-es/components/Tabs/index.js.map +1 -1
- package/lib-es/index.js +11 -3
- package/lib-es/index.js.map +1 -1
- package/lib-es/utils/add-content-menu-items.js.map +1 -1
- package/lib-es/utils/build-create-entity-mutation.js.map +1 -1
- package/lib-es/utils/build-delete-entity-mutation.js.map +1 -1
- package/lib-es/utils/build-listing-query.js.map +1 -1
- package/lib-es/utils/build-update-data-query.js.map +1 -1
- package/lib-es/utils/build-update-publish-unpublish-mutation.js.map +1 -1
- package/lib-es/utils/hoc/withContext.js +1 -1
- package/lib-es/utils/hoc/withContext.js.map +1 -1
- package/package.json +27 -22
- package/src/components/EntityManager/Entity/Entity.js +63 -81
- package/src/components/EntityManager/Entity/EntityHeader/EntityHeader.js +1 -2
- package/src/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +9 -7
- package/src/components/EntityManager/Entity/SideBarRelations/index.js +64 -59
- package/src/components/EntityManager/EntityManager.js +52 -45
- package/src/components/InfoBoxes/container/InfoBoxContainer.js +3 -6
- package/src/components/InfoBoxes/hooks/useData.js +6 -1
- package/src/components/ListingTable/ListingTable.js +13 -21
- package/src/components/ListingTable/ListingTableContent/ListingTableContent.js +38 -44
- package/src/components/ListingTable/SearchFilter/SearchContainer.js +105 -120
- package/src/components/ListingTable/service/index.js +2 -3
- package/src/components/Tabs/index.js +17 -21
- package/src/index.js +9 -7
- package/src/utils/hoc/withContext.js +5 -4
- package/CHANGELOG.md +0 -1947
- package/babel.config.js +0 -3
- package/jest.config.js +0 -5
|
@@ -19,56 +19,63 @@ const EntityManager = ({ match, history }) => {
|
|
|
19
19
|
|
|
20
20
|
const { action, entityIdentifier, id = null, onViewUrl } = match.params;
|
|
21
21
|
|
|
22
|
-
useEffect(
|
|
23
|
-
() => {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
addToast(PAGE_NOT_FOUND, {
|
|
34
|
-
appearance: ERROR,
|
|
35
|
-
autoDismiss: true
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
history.push(`/data-listing/${entityIdentifier}`);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
let localData = data;
|
|
42
|
-
|
|
43
|
-
if (isPageBuilderTemplateSet(data)) {
|
|
44
|
-
const pageBuilderComponents = await getPageBuilderComponents({
|
|
45
|
-
entitySchema,
|
|
46
|
-
client,
|
|
47
|
-
id
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
localData = {
|
|
51
|
-
...localData,
|
|
52
|
-
pageBuilder: pageBuilderComponents || localData.pageBuilder
|
|
53
|
-
};
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
setFormData({ values: localData });
|
|
57
|
-
setEntity(data);
|
|
58
|
-
setSchema(entitySchema);
|
|
59
|
-
setPreviousQuery(requestedQuery);
|
|
60
|
-
setShouldRefetch(false);
|
|
61
|
-
} catch (error) {
|
|
62
|
-
addToast(error.message, {
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
(async () => {
|
|
24
|
+
try {
|
|
25
|
+
const [entitySchema, data = {}, requestedQuery] = await entityAvailableActions[action]({
|
|
26
|
+
client,
|
|
27
|
+
identifier: entityIdentifier,
|
|
28
|
+
id
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
if (!data) {
|
|
32
|
+
addToast(PAGE_NOT_FOUND, {
|
|
63
33
|
appearance: ERROR,
|
|
64
34
|
autoDismiss: true
|
|
65
35
|
});
|
|
36
|
+
|
|
66
37
|
history.push(`/data-listing/${entityIdentifier}`);
|
|
67
38
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
39
|
+
|
|
40
|
+
let localData = data;
|
|
41
|
+
|
|
42
|
+
if (isPageBuilderTemplateSet(data)) {
|
|
43
|
+
const pageBuilderComponents = await getPageBuilderComponents({
|
|
44
|
+
entitySchema,
|
|
45
|
+
client,
|
|
46
|
+
id
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
localData = {
|
|
50
|
+
...localData,
|
|
51
|
+
pageBuilder: pageBuilderComponents || localData.pageBuilder
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
setFormData({ values: localData });
|
|
56
|
+
setEntity(data);
|
|
57
|
+
setSchema(entitySchema);
|
|
58
|
+
setPreviousQuery(requestedQuery);
|
|
59
|
+
setShouldRefetch(false);
|
|
60
|
+
} catch (error) {
|
|
61
|
+
addToast(error.message, {
|
|
62
|
+
appearance: ERROR,
|
|
63
|
+
autoDismiss: true
|
|
64
|
+
});
|
|
65
|
+
history.push(`/data-listing/${entityIdentifier}`);
|
|
66
|
+
}
|
|
67
|
+
})();
|
|
68
|
+
}, [
|
|
69
|
+
action,
|
|
70
|
+
addToast,
|
|
71
|
+
client,
|
|
72
|
+
entityIdentifier,
|
|
73
|
+
history,
|
|
74
|
+
history.push,
|
|
75
|
+
id,
|
|
76
|
+
schema,
|
|
77
|
+
shouldRefetch
|
|
78
|
+
]);
|
|
72
79
|
|
|
73
80
|
const updateFormData = (updatedFormData, shouldRefresh) => {
|
|
74
81
|
if (shouldRefresh) setShouldRefetch(true);
|
|
@@ -9,12 +9,9 @@ const InfoBoxContainer = ({ id, schema, infoBox }) => {
|
|
|
9
9
|
|
|
10
10
|
const { data, refetch } = useData({ id, schema, infoBox });
|
|
11
11
|
|
|
12
|
-
useEffect(
|
|
13
|
-
()
|
|
14
|
-
|
|
15
|
-
},
|
|
16
|
-
[externalUpdateTime, refetch]
|
|
17
|
-
);
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
refetch();
|
|
14
|
+
}, [externalUpdateTime, refetch]);
|
|
18
15
|
|
|
19
16
|
if (!data || !Object.keys(data) || Object.keys(data).length === 0) return null;
|
|
20
17
|
|
|
@@ -12,7 +12,12 @@ function useData({ id, schema, infoBox }) {
|
|
|
12
12
|
}
|
|
13
13
|
`;
|
|
14
14
|
|
|
15
|
-
const {
|
|
15
|
+
const {
|
|
16
|
+
data = {},
|
|
17
|
+
loading,
|
|
18
|
+
error,
|
|
19
|
+
refetch
|
|
20
|
+
} = useQuery(infoBoxQuery, {
|
|
16
21
|
variables: { id },
|
|
17
22
|
skip: !query
|
|
18
23
|
});
|
|
@@ -144,7 +144,6 @@ const ListingTable = ({ match, entitySchema, history }) => {
|
|
|
144
144
|
});
|
|
145
145
|
history.push('?page=1');
|
|
146
146
|
};
|
|
147
|
-
|
|
148
147
|
if (!tableData || !tableData.rows) return 'loading';
|
|
149
148
|
|
|
150
149
|
const {
|
|
@@ -160,27 +159,20 @@ const ListingTable = ({ match, entitySchema, history }) => {
|
|
|
160
159
|
|
|
161
160
|
return (
|
|
162
161
|
<div className="page">
|
|
163
|
-
{modalStatus &&
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
)}
|
|
162
|
+
{modalStatus && _deleteAction.active && (
|
|
163
|
+
<DeleteAction
|
|
164
|
+
data-testid="deleteEntity"
|
|
165
|
+
onClose={toggleModal}
|
|
166
|
+
deleteAction={deleteAction}
|
|
167
|
+
itemName={itemToDelete.name}
|
|
168
|
+
/>
|
|
169
|
+
)}
|
|
172
170
|
<PageHeader title={entitySchema.displayName} subtitle="">
|
|
173
|
-
{createAction.active &&
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
className="button button--small"
|
|
179
|
-
to={`${match.url}/create`}>
|
|
180
|
-
Add
|
|
181
|
-
</Link>
|
|
182
|
-
</Fragment>
|
|
183
|
-
)}
|
|
171
|
+
{createAction.active && !showAddButton && (
|
|
172
|
+
<Link data-testid="addEntity" className="button button--small" to={`${match.url}/create`}>
|
|
173
|
+
Add
|
|
174
|
+
</Link>
|
|
175
|
+
)}
|
|
184
176
|
</PageHeader>
|
|
185
177
|
{showAddButton ? (
|
|
186
178
|
<CardPrompt>
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import React, { useEffect, useRef } from 'react';
|
|
2
2
|
import Table from '@blaze-react/table';
|
|
3
3
|
import Pagination from '@blaze-react/pagination';
|
|
4
|
-
|
|
5
4
|
import PropTypes from 'prop-types';
|
|
6
5
|
import { withRouter } from 'react-router-dom';
|
|
7
6
|
|
|
@@ -18,53 +17,48 @@ const ListingTableContent = ({
|
|
|
18
17
|
const { isEnquiry } = tableData;
|
|
19
18
|
const className = `page__content${isEnquiry ? ' array-table' : ''}`;
|
|
20
19
|
|
|
21
|
-
useEffect(
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
// set table head to match body column widths to handle dynamic content
|
|
22
|
+
if (ref.current && displayTable) {
|
|
23
|
+
const tableHeadCells = ref.current.querySelectorAll('.table-head .table-cell');
|
|
24
|
+
const firstRowCells = ref.current.querySelectorAll(
|
|
25
|
+
'.table-body .table-row:first-child .table-cell'
|
|
26
|
+
);
|
|
29
27
|
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
firstRowCells.forEach((element, i) => {
|
|
29
|
+
const styles = window.getComputedStyle(element);
|
|
32
30
|
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
)
|
|
31
|
+
if (tableHeadCells[i]) {
|
|
32
|
+
tableHeadCells[i].style.flex = styles.flex;
|
|
33
|
+
tableHeadCells[i].style['justify-content'] = styles['justify-content'];
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}, [tableData, displayTable]);
|
|
38
|
+
|
|
39
|
+
if (displayTable) {
|
|
40
|
+
return (
|
|
41
|
+
<div ref={ref} className={className}>
|
|
42
|
+
<Table
|
|
43
|
+
onSort={onSort}
|
|
44
|
+
data={tableData}
|
|
45
|
+
onSelect={handleSelect}
|
|
46
|
+
data-testid="listing-table-content"
|
|
47
|
+
/>
|
|
48
|
+
<Pagination
|
|
49
|
+
visiblePages={10}
|
|
50
|
+
totalItems={totalItems}
|
|
51
|
+
currentPage={currentPage}
|
|
52
|
+
onPageChange={handleOnPageChange}
|
|
53
|
+
/>
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
42
57
|
|
|
43
58
|
return (
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
<div ref={ref} className={className}>
|
|
48
|
-
<Table
|
|
49
|
-
onSort={onSort}
|
|
50
|
-
data={tableData}
|
|
51
|
-
onSelect={handleSelect}
|
|
52
|
-
data-testid="listing-table-content"
|
|
53
|
-
/>
|
|
54
|
-
<Pagination
|
|
55
|
-
visiblePages={10}
|
|
56
|
-
totalItems={totalItems}
|
|
57
|
-
currentPage={currentPage}
|
|
58
|
-
onPageChange={handleOnPageChange}
|
|
59
|
-
/>
|
|
60
|
-
</div>
|
|
61
|
-
</>
|
|
62
|
-
) : (
|
|
63
|
-
<span className="table-no-results" data-testid="no-results">
|
|
64
|
-
No results
|
|
65
|
-
</span>
|
|
66
|
-
)}
|
|
67
|
-
</>
|
|
59
|
+
<span className="table-no-results" data-testid="no-results">
|
|
60
|
+
No results
|
|
61
|
+
</span>
|
|
68
62
|
);
|
|
69
63
|
};
|
|
70
64
|
|
|
@@ -23,20 +23,17 @@ const SearchContainer = ({
|
|
|
23
23
|
const displaySearchFilter = keywordFiltersToUse.length > 0;
|
|
24
24
|
const displaySelectFilters = selectFiltersToDisplay.length > 0;
|
|
25
25
|
|
|
26
|
-
const { keywordSearchProperties, keywordSearchLabels } = useMemo(
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
const properties = [];
|
|
26
|
+
const { keywordSearchProperties, keywordSearchLabels } = useMemo(() => {
|
|
27
|
+
const labels = [];
|
|
28
|
+
const properties = [];
|
|
30
29
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
30
|
+
keywordFiltersToUse.forEach(([property, { label }]) => {
|
|
31
|
+
if (label) labels.push(label);
|
|
32
|
+
properties.push(property);
|
|
33
|
+
});
|
|
35
34
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
[keywordFiltersToUse]
|
|
39
|
-
);
|
|
35
|
+
return { keywordSearchProperties: properties, keywordSearchLabels: labels };
|
|
36
|
+
}, [keywordFiltersToUse]);
|
|
40
37
|
|
|
41
38
|
const { gqlFields, rawQuery } = useMemo(
|
|
42
39
|
() => buildQueryFields(selectFiltersToDisplay, schema.id),
|
|
@@ -52,101 +49,93 @@ const SearchContainer = ({
|
|
|
52
49
|
fetchPolicy: 'cache-and-network'
|
|
53
50
|
});
|
|
54
51
|
|
|
55
|
-
const filterData = useMemo(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
return proccessedData;
|
|
66
|
-
},
|
|
67
|
-
[data]
|
|
68
|
-
);
|
|
52
|
+
const filterData = useMemo(() => {
|
|
53
|
+
const { searchResults: { rawResults: { aggregations = {} } = {} } = {} } = data || {};
|
|
54
|
+
const proccessedData = [];
|
|
55
|
+
Object.entries(aggregations).forEach(([key, { buckets }]) => {
|
|
56
|
+
proccessedData.push(
|
|
57
|
+
Array.isArray(buckets) ? [key, buckets.map(b => b.key).filter(Boolean)] : []
|
|
58
|
+
);
|
|
59
|
+
});
|
|
69
60
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
if (!selectionDetails.relation) {
|
|
90
|
-
return {
|
|
91
|
-
id: property,
|
|
92
|
-
label: selectionDetails.label,
|
|
93
|
-
options: ids.map(value => [value, value])
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
const query = getQuery('GET_ENTITY_SCHEMA');
|
|
97
|
-
const {
|
|
98
|
-
data: {
|
|
99
|
-
getEntitySchemas: [relationSchema]
|
|
100
|
-
}
|
|
101
|
-
} = await apolloClient.query({
|
|
102
|
-
query,
|
|
103
|
-
variables: { identifier: selectionDetails.relation.entityIdentifier }
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
const {
|
|
107
|
-
data: { result: selected = [] }
|
|
108
|
-
} = await apolloClient
|
|
109
|
-
.query({
|
|
110
|
-
query: getDynamicQuery('GET_ALL_ENTITIES')(relationSchema),
|
|
111
|
-
variables: {
|
|
112
|
-
where: {
|
|
113
|
-
id: {
|
|
114
|
-
_in: ids
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
sort: [{ property: 'name', direction: 'asc' }]
|
|
118
|
-
}
|
|
119
|
-
})
|
|
120
|
-
// eslint-disable-next-line no-console
|
|
121
|
-
.catch(e => console.error(e));
|
|
61
|
+
return proccessedData;
|
|
62
|
+
}, [data]);
|
|
63
|
+
|
|
64
|
+
useEffect(() => {
|
|
65
|
+
if (!filterData.length) {
|
|
66
|
+
setSelectOptions([]);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
(async () => {
|
|
71
|
+
const results = await Promise.all(
|
|
72
|
+
filterData.map(async ([property, ids]) => {
|
|
73
|
+
try {
|
|
74
|
+
if (!ids || !ids.length) return {};
|
|
75
|
+
|
|
76
|
+
const [, selectionDetails] =
|
|
77
|
+
selectFiltersToDisplay.find(([selectProperty]) => selectProperty === property) || [];
|
|
78
|
+
|
|
79
|
+
if (!selectionDetails) return null;
|
|
122
80
|
|
|
81
|
+
if (!selectionDetails.relation) {
|
|
123
82
|
return {
|
|
124
83
|
id: property,
|
|
125
84
|
label: selectionDetails.label,
|
|
126
|
-
options:
|
|
85
|
+
options: ids.map(value => [value, value])
|
|
127
86
|
};
|
|
128
|
-
} catch {
|
|
129
|
-
return null;
|
|
130
87
|
}
|
|
131
|
-
|
|
132
|
-
|
|
88
|
+
const query = getQuery('GET_ENTITY_SCHEMA');
|
|
89
|
+
const {
|
|
90
|
+
data: {
|
|
91
|
+
getEntitySchemas: [relationSchema]
|
|
92
|
+
}
|
|
93
|
+
} = await apolloClient.query({
|
|
94
|
+
query,
|
|
95
|
+
variables: { identifier: selectionDetails.relation.entityIdentifier }
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
const {
|
|
99
|
+
data: { result: selected = [] }
|
|
100
|
+
} = await apolloClient
|
|
101
|
+
.query({
|
|
102
|
+
query: getDynamicQuery('GET_ALL_ENTITIES')(relationSchema),
|
|
103
|
+
variables: {
|
|
104
|
+
where: {
|
|
105
|
+
id: {
|
|
106
|
+
_in: ids
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
sort: [{ property: 'name', direction: 'asc' }]
|
|
110
|
+
}
|
|
111
|
+
})
|
|
112
|
+
// eslint-disable-next-line no-console
|
|
113
|
+
.catch(e => console.error(e));
|
|
114
|
+
|
|
115
|
+
return {
|
|
116
|
+
id: property,
|
|
117
|
+
label: selectionDetails.label,
|
|
118
|
+
options: selected.map(item => [item.id, item.name])
|
|
119
|
+
};
|
|
120
|
+
} catch {
|
|
121
|
+
return null;
|
|
122
|
+
}
|
|
123
|
+
})
|
|
124
|
+
);
|
|
133
125
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
[apolloClient, filterData, schema, selectFiltersToDisplay]
|
|
138
|
-
);
|
|
126
|
+
setSelectOptions(results.filter(Boolean));
|
|
127
|
+
})();
|
|
128
|
+
}, [apolloClient, filterData, schema, selectFiltersToDisplay]);
|
|
139
129
|
|
|
140
130
|
const updateFilters = useCallback(
|
|
141
131
|
(term, filters) => updateListFilters(term, filters, setListFilters, keywordSearchProperties),
|
|
142
132
|
[setListFilters, keywordSearchProperties]
|
|
143
133
|
);
|
|
144
134
|
|
|
145
|
-
const handleSearch = useCallback(
|
|
146
|
-
searchTerm,
|
|
147
|
-
selectedFilters,
|
|
148
|
-
|
|
149
|
-
]);
|
|
135
|
+
const handleSearch = useCallback(
|
|
136
|
+
() => updateFilters(searchTerm, selectedFilters),
|
|
137
|
+
[searchTerm, selectedFilters, updateFilters]
|
|
138
|
+
);
|
|
150
139
|
const handleSearchChange = useCallback(e => setSearchTerm(e.target.value), []);
|
|
151
140
|
const handleEnterKey = useCallback(
|
|
152
141
|
e => {
|
|
@@ -154,19 +143,16 @@ const SearchContainer = ({
|
|
|
154
143
|
},
|
|
155
144
|
[handleSearch]
|
|
156
145
|
);
|
|
157
|
-
const handleReset = useCallback(
|
|
158
|
-
()
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
},
|
|
168
|
-
[selectedFilters, updateFilters]
|
|
169
|
-
);
|
|
146
|
+
const handleReset = useCallback(() => {
|
|
147
|
+
setSearchTerm('');
|
|
148
|
+
setSelectedFilters(
|
|
149
|
+
Object.keys(selectedFilters).reduce(
|
|
150
|
+
(acc, key) => ({ ...acc, [key]: DEFAULT_FILTER_OPTION_LABEL }),
|
|
151
|
+
{}
|
|
152
|
+
)
|
|
153
|
+
);
|
|
154
|
+
updateFilters('', {});
|
|
155
|
+
}, [selectedFilters, updateFilters]);
|
|
170
156
|
const handleSelect = useCallback(
|
|
171
157
|
(property, event) => {
|
|
172
158
|
const { value } = event;
|
|
@@ -200,20 +186,19 @@ const SearchContainer = ({
|
|
|
200
186
|
{displaySelectFilters &&
|
|
201
187
|
selectOptions.map(({ id, options, label }) => (
|
|
202
188
|
<>
|
|
203
|
-
{options &&
|
|
204
|
-
|
|
205
|
-
<
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
)}
|
|
189
|
+
{options && !!options.length && (
|
|
190
|
+
<div className="search-container__select-wrapper">
|
|
191
|
+
<Select
|
|
192
|
+
label={label}
|
|
193
|
+
id={id}
|
|
194
|
+
name={id}
|
|
195
|
+
onChange={event => handleSelect(id, event)}
|
|
196
|
+
options={options}
|
|
197
|
+
value={selectedFilters[id]}
|
|
198
|
+
defaultTextValue={DEFAULT_FILTER_OPTION_LABEL}
|
|
199
|
+
/>
|
|
200
|
+
</div>
|
|
201
|
+
)}
|
|
217
202
|
</>
|
|
218
203
|
))}
|
|
219
204
|
|
|
@@ -34,9 +34,8 @@ function buildVariables({ entitySchema, isSearchQuery, listFilters = [], queryPa
|
|
|
34
34
|
}
|
|
35
35
|
|
|
36
36
|
const fetchData = async ({ client, querySettings: { entitySchema, queryParams }, listFilters }) => {
|
|
37
|
-
const {
|
|
38
|
-
|
|
39
|
-
} = entitySchema;
|
|
37
|
+
const { displayProperties: { adminListings: { dataSource: { source, index } = {} } = {} } = {} } =
|
|
38
|
+
entitySchema;
|
|
40
39
|
|
|
41
40
|
const isSearchQuery = source === 'search';
|
|
42
41
|
const query = buildListingQuery(entitySchema, index, isSearchQuery);
|
|
@@ -1,11 +1,7 @@
|
|
|
1
1
|
import React, { useState } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import { Tab, TabItem } from '@blaze-react/tab';
|
|
4
|
-
import {
|
|
5
|
-
useReadFromCache,
|
|
6
|
-
GET_CURRENT_TAB_ID,
|
|
7
|
-
TabsContextProvider
|
|
8
|
-
} from '@blaze-cms/admin-ui-utils';
|
|
4
|
+
import { useTabsContext, TabsContextProvider } from '@blaze-cms/admin-ui-utils';
|
|
9
5
|
import {
|
|
10
6
|
PAGE_BUILDER_TAB,
|
|
11
7
|
PAGE_BUILDER_TAB_INDEX,
|
|
@@ -14,25 +10,25 @@ import {
|
|
|
14
10
|
} from '../../constants';
|
|
15
11
|
|
|
16
12
|
const Tabs = ({ children, onTabChange, enabled }) => {
|
|
17
|
-
const { currentTabId } =
|
|
13
|
+
const { currentTabId = EDITOR_VIEW_TAB_INDEX } = useTabsContext() || {};
|
|
18
14
|
const [activeAccordions, setActiveAccordions] = useState([]);
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
<>{children}</>
|
|
15
|
+
|
|
16
|
+
if (!enabled) return children;
|
|
17
|
+
|
|
18
|
+
return (
|
|
19
|
+
<TabsContextProvider value={{ currentTabId, activeAccordions, setActiveAccordions }}>
|
|
20
|
+
<Tab selected={currentTabId}>
|
|
21
|
+
<TabItem title={EDITOR_VIEW_TAB} action={() => onTabChange(EDITOR_VIEW_TAB_INDEX)}>
|
|
22
|
+
{children}
|
|
23
|
+
</TabItem>
|
|
24
|
+
<TabItem title={PAGE_BUILDER_TAB} action={() => onTabChange(PAGE_BUILDER_TAB_INDEX)}>
|
|
25
|
+
{children}
|
|
26
|
+
</TabItem>
|
|
27
|
+
</Tab>
|
|
28
|
+
</TabsContextProvider>
|
|
34
29
|
);
|
|
35
30
|
};
|
|
31
|
+
|
|
36
32
|
Tabs.propTypes = {
|
|
37
33
|
children: PropTypes.oneOfType([PropTypes.object, PropTypes.arrayOf(PropTypes.object)]).isRequired,
|
|
38
34
|
onTabChange: PropTypes.func.isRequired,
|
package/src/index.js
CHANGED
|
@@ -1,16 +1,18 @@
|
|
|
1
1
|
import { getFormBuilderLookup, formFieldTypes } from '@blaze-cms/react-form-builder';
|
|
2
|
-
import React from 'react';
|
|
3
2
|
import pkg from '../package.json';
|
|
4
3
|
import { DATA_LISTING_PREFIX, PLUGIN_NAME } from './constants';
|
|
5
4
|
import getAddContentMenuItems from './utils/add-content-menu-items';
|
|
6
5
|
import { UserIcon, TaxonomyIcon, ContentIcon, SettingsIcon } from './icons';
|
|
6
|
+
import EntityDataListing from './components/EntityDataListing';
|
|
7
|
+
import EntityManager from './components/EntityManager';
|
|
7
8
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
)
|
|
9
|
+
// todo: renable lazy loading after bundler optimisations, currently they are too slow in dev mode
|
|
10
|
+
// const EntityDataListing = React.lazy(
|
|
11
|
+
// () => import(/* webpackChunkName: 'EntityDataListing' */ './components/EntityDataListing')
|
|
12
|
+
// );
|
|
13
|
+
// const EntityManager = React.lazy(
|
|
14
|
+
// () => import(/* webpackChunkName: 'EntityManager' */ './components/EntityManager')
|
|
15
|
+
// );
|
|
14
16
|
|
|
15
17
|
export default async function load(app) {
|
|
16
18
|
app.events.once('admin:menu:config:load', getAddContentMenuItems(app));
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useMainContext, MainContext } from '@blaze-cms/admin-ui-utils';
|
|
3
3
|
|
|
4
|
-
export const withContext = Component =>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
4
|
+
export const withContext = Component =>
|
|
5
|
+
function (props) {
|
|
6
|
+
const contexts = useMainContext(MainContext);
|
|
7
|
+
return <Component {...props} {...contexts} />;
|
|
8
|
+
};
|