@blaze-cms/plugin-data-ui 0.146.0-translations.6 → 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/README.md +57 -0
- 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 +289 -452
- 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 +34 -50
- 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 +104 -150
- package/lib/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +24 -24
- 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 -73
- 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 +43 -0
- package/lib/components/InfoBoxes/InfoBoxTooltip.js.map +1 -0
- 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 +28 -32
- 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 +163 -303
- package/lib/components/ListingTable/ListingTable.js.map +1 -1
- package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js +61 -40
- 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 +215 -0
- package/lib/components/ListingTable/SearchFilter/SearchContainer.js.map +1 -0
- package/lib/components/ListingTable/SearchFilter/SearchFilter.js +48 -0
- package/lib/components/ListingTable/SearchFilter/SearchFilter.js.map +1 -0
- package/lib/components/ListingTable/SearchFilter/helpers.js +105 -0
- package/lib/components/ListingTable/SearchFilter/helpers.js.map +1 -0
- package/lib/components/ListingTable/SearchFilter/querys.js +13 -0
- package/lib/components/ListingTable/SearchFilter/querys.js.map +1 -0
- 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 +104 -120
- 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 +31 -29
- 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 +20 -17
- 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/EntityDataListing/EntityDataListing.js.map +1 -1
- package/lib-es/components/EntityDataListing/index.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/index.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/Entity.js +21 -28
- 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 +6 -1
- package/lib-es/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/index.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/EntityHeader/index.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +2 -0
- 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 +26 -7
- package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +8 -2
- package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/actions-handlers/create/index.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/delete/delete.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/actions-handlers/delete/index.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/actions-handlers/index.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/actions-handlers/shared/index.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/actions-handlers/shared/publish.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/actions-handlers/update/index.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/actions-handlers/update/submit.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/index.js.map +1 -1
- package/lib-es/components/EntityManager/EntityManager.js.map +1 -1
- package/lib-es/components/EntityManager/index.js.map +1 -1
- package/lib-es/components/EntityManager/utils/RecordEditContext/index.js.map +1 -1
- package/lib-es/components/EntityManager/utils/data-mappers.js.map +1 -1
- package/lib-es/components/EntityManager/utils/entity.js +6 -2
- package/lib-es/components/EntityManager/utils/entity.js.map +1 -1
- package/lib-es/components/EntityManager/utils/entityAvailableActions.js.map +1 -1
- package/lib-es/components/EntityManager/utils/is-form-empty.js.map +1 -1
- package/lib-es/components/EntityManager/utils/query.js.map +1 -1
- package/lib-es/components/InfoBoxes/InfoBoxTooltip.js +36 -0
- package/lib-es/components/InfoBoxes/InfoBoxTooltip.js.map +1 -0
- package/lib-es/components/InfoBoxes/InfoBoxes.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 +2 -0
- 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/hooks/useInfoBox.js.map +1 -1
- package/lib-es/components/InfoBoxes/index.js.map +1 -1
- package/lib-es/components/InfoBoxes/presentational/InfoBox.js +4 -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/InfoBoxes/presentational/InfoBoxValue.js.map +1 -1
- package/lib-es/components/ListingTable/ListingTable.js +12 -11
- package/lib-es/components/ListingTable/ListingTable.js.map +1 -1
- package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js +34 -16
- package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
- package/lib-es/components/ListingTable/ListingTableContent/index.js.map +1 -1
- package/lib-es/components/ListingTable/SearchFilter/SearchContainer.js +207 -0
- package/lib-es/components/ListingTable/SearchFilter/SearchContainer.js.map +1 -0
- package/lib-es/components/ListingTable/SearchFilter/SearchFilter.js +40 -0
- package/lib-es/components/ListingTable/SearchFilter/SearchFilter.js.map +1 -0
- package/lib-es/components/ListingTable/SearchFilter/helpers.js +96 -0
- package/lib-es/components/ListingTable/SearchFilter/helpers.js.map +1 -0
- package/lib-es/components/ListingTable/SearchFilter/querys.js +8 -0
- package/lib-es/components/ListingTable/SearchFilter/querys.js.map +1 -0
- package/lib-es/components/ListingTable/TableActions/TableActions.js.map +1 -1
- package/lib-es/components/ListingTable/TableActions/index.js.map +1 -1
- package/lib-es/components/ListingTable/index.js.map +1 -1
- package/lib-es/components/ListingTable/mappers/populate-rows.js +3 -0
- package/lib-es/components/ListingTable/mappers/populate-rows.js.map +1 -1
- package/lib-es/components/ListingTable/service/index.js +3 -2
- 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/components/hooks/useCallbackDebounce.js.map +1 -1
- package/lib-es/constants.js +4 -1
- package/lib-es/constants.js.map +1 -1
- package/lib-es/icons/ContentIcon.js.map +1 -1
- package/lib-es/icons/SettingsIcon.js.map +1 -1
- package/lib-es/icons/TaxonomyIcon.js.map +1 -1
- package/lib-es/icons/UsersIcon.js.map +1 -1
- package/lib-es/icons/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 +4 -4
- 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/get-default-query-params.js.map +1 -1
- package/lib-es/utils/hoc/withContext.js +1 -1
- package/lib-es/utils/hoc/withContext.js.map +1 -1
- package/lib-es/utils/hooks/useToggle.js.map +1 -1
- package/lib-es/utils/index.js.map +1 -1
- package/package.json +28 -22
- package/src/components/EntityManager/Entity/Entity.js +72 -80
- package/src/components/EntityManager/Entity/EntityHeader/EntityHeader.js +1 -2
- package/src/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js +8 -1
- package/src/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +2 -0
- package/src/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +9 -7
- package/src/components/EntityManager/Entity/SideBarRelations/index.js +82 -59
- package/src/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +5 -3
- package/src/components/EntityManager/EntityManager.js +52 -45
- package/src/components/EntityManager/utils/entity.js +13 -2
- package/src/components/InfoBoxes/InfoBoxTooltip.js +32 -0
- package/src/components/InfoBoxes/container/InfoBoxContainer.js +3 -6
- package/src/components/InfoBoxes/helpers/build-dynamic-query.js +2 -0
- package/src/components/InfoBoxes/hooks/useData.js +6 -1
- package/src/components/InfoBoxes/presentational/InfoBox.js +4 -2
- package/src/components/ListingTable/ListingTable.js +23 -31
- package/src/components/ListingTable/ListingTableContent/ListingTableContent.js +43 -27
- package/src/components/ListingTable/SearchFilter/SearchContainer.js +228 -0
- package/src/components/ListingTable/SearchFilter/SearchFilter.js +38 -0
- package/src/components/ListingTable/SearchFilter/helpers.js +99 -0
- package/src/components/ListingTable/SearchFilter/querys.js +9 -0
- package/src/components/ListingTable/mappers/populate-rows.js +3 -0
- package/src/components/ListingTable/service/index.js +3 -4
- package/src/components/Tabs/index.js +17 -21
- package/src/constants.js +9 -1
- package/src/index.js +9 -7
- package/src/utils/build-listing-query.js +4 -4
- package/src/utils/hoc/withContext.js +5 -4
- package/CHANGELOG.md +0 -1939
- package/babel.config.js +0 -3
- package/jest.config.js +0 -5
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useState, useEffect } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import uuidv1 from 'uuid/v1';
|
|
4
|
+
import Accordion from '@blaze-react/accordion';
|
|
4
5
|
import { useApolloClient } from '@apollo/client';
|
|
5
6
|
import { getQuery } from '@blaze-cms/admin-ui-utils';
|
|
6
7
|
import { formFieldTypes } from '@blaze-cms/react-form-builder';
|
|
@@ -10,53 +11,51 @@ import { PUBLISHED, UNPUBLISHED } from '../../../../constants';
|
|
|
10
11
|
import CustomSidebarInfoContainer from './container/CustomSidebarInfoContainer';
|
|
11
12
|
import EntityNavLinks from '../EntitiyNavLinks';
|
|
12
13
|
|
|
13
|
-
const SideBarRelations = ({ schema, onChange, formData, entity }) => {
|
|
14
|
+
const SideBarRelations = ({ schema, onChange, formData, entity, isOpen, onToggle }) => {
|
|
14
15
|
const { relation: RelationComponent } = formFieldTypes;
|
|
15
16
|
const {
|
|
16
17
|
formattedStatus,
|
|
17
18
|
formattedUpdated,
|
|
18
19
|
formattedCreated,
|
|
19
20
|
formattedPublished,
|
|
21
|
+
updatedBy,
|
|
20
22
|
status
|
|
21
23
|
} = formData;
|
|
22
24
|
const client = useApolloClient();
|
|
23
25
|
|
|
24
26
|
const [relationsComponents, setRelationsComponents] = useState(null);
|
|
25
27
|
|
|
26
|
-
useEffect(
|
|
27
|
-
() => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (!entityIdentifier) return null;
|
|
28
|
+
useEffect(() => {
|
|
29
|
+
(async () => {
|
|
30
|
+
const fetchRelationSchema = async ({ entityIdentifier }) => {
|
|
31
|
+
if (!entityIdentifier) return null;
|
|
31
32
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
33
|
+
const {
|
|
34
|
+
data: {
|
|
35
|
+
getEntitySchemas: [relationSchema]
|
|
36
|
+
}
|
|
37
|
+
} = await client.query({
|
|
38
|
+
query: getQuery('GET_ENTITY_SCHEMA'),
|
|
39
|
+
variables: { identifier: entityIdentifier }
|
|
40
|
+
});
|
|
41
|
+
return relationSchema;
|
|
42
|
+
};
|
|
42
43
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
44
|
+
if (!relationsComponents && schema) {
|
|
45
|
+
const allRelationComponents = await Promise.all(
|
|
46
|
+
schema.relations
|
|
47
|
+
.filter(({ showInForm, foreignKey }) => showInForm && schema.properties[foreignKey])
|
|
48
|
+
.map(async relation => ({
|
|
49
|
+
id: uuidv1(),
|
|
50
|
+
staticData: relation,
|
|
51
|
+
schema: await fetchRelationSchema(relation)
|
|
52
|
+
}))
|
|
53
|
+
);
|
|
53
54
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
[client, relationsComponents, schema, schema.relations]
|
|
59
|
-
);
|
|
55
|
+
setRelationsComponents(allRelationComponents);
|
|
56
|
+
}
|
|
57
|
+
})();
|
|
58
|
+
}, [client, relationsComponents, schema, schema.relations]);
|
|
60
59
|
const { id: itemId } = entity;
|
|
61
60
|
const { identifier: itemEntity, interfaces } = schema;
|
|
62
61
|
|
|
@@ -66,7 +65,16 @@ const SideBarRelations = ({ schema, onChange, formData, entity }) => {
|
|
|
66
65
|
});
|
|
67
66
|
|
|
68
67
|
return (
|
|
69
|
-
<div
|
|
68
|
+
<div
|
|
69
|
+
className={classnames('sidebar', { 'sidebar--collapsed': !isOpen })}
|
|
70
|
+
data-testid="sideBarRelations-main-div">
|
|
71
|
+
<div
|
|
72
|
+
className="sidebar__toggle-button"
|
|
73
|
+
onClick={onToggle}
|
|
74
|
+
role="button"
|
|
75
|
+
aria-label={isOpen ? 'Collapse sidebar' : 'Expand sidebar'}>
|
|
76
|
+
<i className="material-icons">{isOpen ? 'keyboard_arrow_right' : 'keyboard_arrow_left'}</i>
|
|
77
|
+
</div>
|
|
70
78
|
<div className="sidebar__content">
|
|
71
79
|
<div className="sidebar__status">
|
|
72
80
|
{formattedCreated && (
|
|
@@ -82,19 +90,21 @@ const SideBarRelations = ({ schema, onChange, formData, entity }) => {
|
|
|
82
90
|
)}
|
|
83
91
|
</div>
|
|
84
92
|
)}
|
|
85
|
-
{!schema.displayProperties.disableDefaultAdminInfo &&
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
93
|
+
{!schema.displayProperties.disableDefaultAdminInfo && formattedCreated && (
|
|
94
|
+
<>
|
|
95
|
+
<p>
|
|
96
|
+
Created: <span>{formattedCreated}</span>
|
|
97
|
+
</p>
|
|
98
|
+
<p>
|
|
99
|
+
Updated: <span>{formattedUpdated}</span>
|
|
100
|
+
</p>
|
|
101
|
+
{updatedBy && (
|
|
102
|
+
<p>
|
|
103
|
+
Updated by: <span>{updatedBy.name}</span>
|
|
104
|
+
</p>
|
|
105
|
+
)}
|
|
106
|
+
</>
|
|
107
|
+
)}
|
|
98
108
|
|
|
99
109
|
<CustomSidebarInfoContainer
|
|
100
110
|
id={itemId}
|
|
@@ -106,16 +116,26 @@ const SideBarRelations = ({ schema, onChange, formData, entity }) => {
|
|
|
106
116
|
<VersionsList itemEntity={itemEntity} itemId={itemId} interfaces={interfaces} />
|
|
107
117
|
<EntityNavLinks schema={schema} />
|
|
108
118
|
|
|
109
|
-
{relationsComponents &&
|
|
110
|
-
|
|
111
|
-
<
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
+
{relationsComponents && (
|
|
120
|
+
<Accordion isOpen>
|
|
121
|
+
<Accordion.Header>
|
|
122
|
+
<b>Classification</b>
|
|
123
|
+
</Accordion.Header>
|
|
124
|
+
<Accordion.Content>
|
|
125
|
+
<Accordion.ContentDetails>
|
|
126
|
+
{relationsComponents.map(({ id, staticData, schema: entitySchema }) => (
|
|
127
|
+
<RelationComponent
|
|
128
|
+
formData={formData}
|
|
129
|
+
schema={entitySchema}
|
|
130
|
+
key={id}
|
|
131
|
+
staticData={staticData}
|
|
132
|
+
onSelect={onChange}
|
|
133
|
+
/>
|
|
134
|
+
))}
|
|
135
|
+
</Accordion.ContentDetails>
|
|
136
|
+
</Accordion.Content>
|
|
137
|
+
</Accordion>
|
|
138
|
+
)}
|
|
119
139
|
</div>
|
|
120
140
|
</div>
|
|
121
141
|
);
|
|
@@ -125,11 +145,14 @@ SideBarRelations.propTypes = {
|
|
|
125
145
|
schema: PropTypes.object.isRequired,
|
|
126
146
|
onChange: PropTypes.func.isRequired,
|
|
127
147
|
formData: PropTypes.object.isRequired,
|
|
128
|
-
entity: PropTypes.object
|
|
148
|
+
entity: PropTypes.object,
|
|
149
|
+
isOpen: PropTypes.bool,
|
|
150
|
+
onToggle: PropTypes.func
|
|
129
151
|
};
|
|
130
|
-
|
|
131
152
|
SideBarRelations.defaultProps = {
|
|
132
|
-
entity: {}
|
|
153
|
+
entity: {},
|
|
154
|
+
isOpen: true,
|
|
155
|
+
onToggle: () => {}
|
|
133
156
|
};
|
|
134
157
|
|
|
135
158
|
export default SideBarRelations;
|
package/src/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js
CHANGED
|
@@ -2,6 +2,7 @@ import PropTypes from 'prop-types';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import InfoBoxValue from '../../../../InfoBoxes/presentational/InfoBoxValue';
|
|
4
4
|
import InfoBoxLabel from '../../../../InfoBoxes/presentational/InfoBoxLabel';
|
|
5
|
+
import InfoBoxTooltip from '../../../../InfoBoxes/InfoBoxTooltip';
|
|
5
6
|
|
|
6
7
|
const CustomSidebarInfo = ({ items, customSidebarInfoKey }) => {
|
|
7
8
|
if (!items) return null;
|
|
@@ -12,10 +13,11 @@ const CustomSidebarInfo = ({ items, customSidebarInfoKey }) => {
|
|
|
12
13
|
if (!info.label || !info.value) return null;
|
|
13
14
|
|
|
14
15
|
return (
|
|
15
|
-
<p>
|
|
16
|
+
<p key={`${customSidebarInfoKey}-${info.label.toLowerCase()}`}>
|
|
16
17
|
<InfoBoxLabel item={info} />
|
|
17
18
|
<span>
|
|
18
19
|
<InfoBoxValue item={info} />
|
|
20
|
+
<InfoBoxTooltip info={info} position="left" />
|
|
19
21
|
</span>
|
|
20
22
|
</p>
|
|
21
23
|
);
|
|
@@ -30,9 +32,9 @@ const CustomSidebarInfo = ({ items, customSidebarInfoKey }) => {
|
|
|
30
32
|
);
|
|
31
33
|
};
|
|
32
34
|
|
|
33
|
-
export default CustomSidebarInfo;
|
|
34
|
-
|
|
35
35
|
CustomSidebarInfo.propTypes = {
|
|
36
36
|
customSidebarInfoKey: PropTypes.string.isRequired,
|
|
37
37
|
items: PropTypes.array.isRequired
|
|
38
38
|
};
|
|
39
|
+
|
|
40
|
+
export default CustomSidebarInfo;
|
|
@@ -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);
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import has from 'lodash.has';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
DEBUG_PARAM,
|
|
4
|
+
ENTITY_PUBLISHED,
|
|
5
|
+
KEY_TO_CHECK,
|
|
6
|
+
SELECT_DEFAULT_VALUE
|
|
7
|
+
} from '../../../constants';
|
|
3
8
|
|
|
4
9
|
function canViewPage(formData, entity, schema, entityIsPublished) {
|
|
5
10
|
return (
|
|
@@ -28,7 +33,13 @@ function validateSideBarRelations(updatedFormValues, requiredChildField) {
|
|
|
28
33
|
|
|
29
34
|
async function onViewUrlClick(getFullUrl) {
|
|
30
35
|
const fullUrl = await getFullUrl();
|
|
31
|
-
if (fullUrl)
|
|
36
|
+
if (fullUrl) {
|
|
37
|
+
const delimiter = fullUrl.includes('?') ? '&' : '?';
|
|
38
|
+
const debugParam = process.env.BLAZE_DISABLE_URL_DEBUG_PARAM
|
|
39
|
+
? ''
|
|
40
|
+
: `${delimiter}${DEBUG_PARAM}`;
|
|
41
|
+
window.open(`${fullUrl}${debugParam}`, '_blank');
|
|
42
|
+
}
|
|
32
43
|
}
|
|
33
44
|
|
|
34
45
|
function getUpdatedFormValues({ id, value, requiredChildField, formValues }) {
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import PropTypes from 'prop-types';
|
|
3
|
+
import Tooltip from '@blaze-react/tooltip';
|
|
4
|
+
|
|
5
|
+
const InfoBoxTooltip = ({ info, ...tooltipProps }) => {
|
|
6
|
+
const { tooltipContent, tooltipIcon } = info;
|
|
7
|
+
if (!tooltipContent) return null;
|
|
8
|
+
|
|
9
|
+
const renderTooltipIcon = icon => {
|
|
10
|
+
if (!icon) return null;
|
|
11
|
+
return <i className={`${icon} info-box--icon`} />;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<Tooltip
|
|
16
|
+
tooltipContent={tooltipContent}
|
|
17
|
+
trigger="click"
|
|
18
|
+
className="info-box--tooltip"
|
|
19
|
+
{...tooltipProps}>
|
|
20
|
+
{renderTooltipIcon(tooltipIcon)}
|
|
21
|
+
</Tooltip>
|
|
22
|
+
);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
InfoBoxTooltip.propTypes = {
|
|
26
|
+
info: PropTypes.shape({
|
|
27
|
+
tooltipContent: PropTypes.node,
|
|
28
|
+
tooltipIcon: PropTypes.string
|
|
29
|
+
}).isRequired
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default InfoBoxTooltip;
|
|
@@ -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
|
});
|
|
@@ -2,6 +2,7 @@ import PropTypes from 'prop-types';
|
|
|
2
2
|
import React from 'react';
|
|
3
3
|
import InfoBoxValue from './InfoBoxValue';
|
|
4
4
|
import InfoBoxLabel from './InfoBoxLabel';
|
|
5
|
+
import InfoBoxTooltip from '../InfoBoxTooltip';
|
|
5
6
|
|
|
6
7
|
const InfoBox = ({ items, infoBoxKey }) => {
|
|
7
8
|
if (!items) return null;
|
|
@@ -18,6 +19,7 @@ const InfoBox = ({ items, infoBoxKey }) => {
|
|
|
18
19
|
</div>
|
|
19
20
|
<div className="info-box--value">
|
|
20
21
|
<InfoBoxValue item={info} />
|
|
22
|
+
<InfoBoxTooltip info={info} />
|
|
21
23
|
</div>
|
|
22
24
|
</div>
|
|
23
25
|
);
|
|
@@ -32,9 +34,9 @@ const InfoBox = ({ items, infoBoxKey }) => {
|
|
|
32
34
|
);
|
|
33
35
|
};
|
|
34
36
|
|
|
35
|
-
export default InfoBox;
|
|
36
|
-
|
|
37
37
|
InfoBox.propTypes = {
|
|
38
38
|
infoBoxKey: PropTypes.string.isRequired,
|
|
39
39
|
items: PropTypes.array.isRequired
|
|
40
40
|
};
|
|
41
|
+
|
|
42
|
+
export default InfoBox;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import React, { useEffect, useState, Fragment } from 'react';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
|
-
import More from '@blaze-react/more';
|
|
4
3
|
import { useApolloClient } from '@apollo/client';
|
|
5
4
|
import { withRouter, Link, useLocation } from 'react-router-dom';
|
|
6
5
|
import { PageHeader, DeleteAction, CardPrompt } from '@blaze-cms/admin';
|
|
7
6
|
import { useToasts } from '@blaze-react/toaster';
|
|
8
7
|
import { RenderHook } from '@blaze-cms/plugin-render-hooks-ui';
|
|
9
8
|
import ListingTableContent from './ListingTableContent';
|
|
9
|
+
import SearchFilter from './SearchFilter/SearchFilter';
|
|
10
10
|
import availableActions from '../EntityManager/Entity/actions-handlers';
|
|
11
11
|
import { fetchData } from './service';
|
|
12
12
|
import { populateRows, formatRows, getParsedRowData } from './mappers/populate-rows';
|
|
@@ -38,7 +38,7 @@ const ListingTable = ({ match, entitySchema, history }) => {
|
|
|
38
38
|
...queryParams,
|
|
39
39
|
offset: currentPage * queryParamsDefault.limit - queryParamsDefault.limit
|
|
40
40
|
};
|
|
41
|
-
await doQuery(
|
|
41
|
+
await doQuery([], updatedQueryParams);
|
|
42
42
|
setPreviousSchema({ id: entitySchema.id });
|
|
43
43
|
}
|
|
44
44
|
})();
|
|
@@ -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,35 +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
|
-
<PageHeader.Actions>
|
|
183
|
-
<More>
|
|
184
|
-
<More.Avatar isMoreMenu>
|
|
185
|
-
<span className="material-icons">more_vert</span>
|
|
186
|
-
</More.Avatar>
|
|
187
|
-
<More.Content isMoreMenu />
|
|
188
|
-
</More>
|
|
189
|
-
</PageHeader.Actions>
|
|
190
|
-
</Fragment>
|
|
191
|
-
)}
|
|
171
|
+
{createAction.active && !showAddButton && (
|
|
172
|
+
<Link data-testid="addEntity" className="button button--small" to={`${match.url}/create`}>
|
|
173
|
+
Add
|
|
174
|
+
</Link>
|
|
175
|
+
)}
|
|
192
176
|
</PageHeader>
|
|
193
177
|
{showAddButton ? (
|
|
194
178
|
<CardPrompt>
|
|
@@ -207,6 +191,11 @@ const ListingTable = ({ match, entitySchema, history }) => {
|
|
|
207
191
|
listFilters={listFilters}
|
|
208
192
|
setListFilters={updateListingFilters}
|
|
209
193
|
/>
|
|
194
|
+
<SearchFilter
|
|
195
|
+
schema={entitySchema}
|
|
196
|
+
listFilters={listFilters}
|
|
197
|
+
setListFilters={updateListingFilters}
|
|
198
|
+
/>
|
|
210
199
|
<ListingTableContent
|
|
211
200
|
totalItems={totalItems}
|
|
212
201
|
currentPage={currentPage}
|
|
@@ -214,6 +203,9 @@ const ListingTable = ({ match, entitySchema, history }) => {
|
|
|
214
203
|
handleOnPageChange={handleOnPageChange}
|
|
215
204
|
tableData={tableData}
|
|
216
205
|
onCloseCardPrompt={onCloseCardPrompt}
|
|
206
|
+
schema={entitySchema}
|
|
207
|
+
listFilters={listFilters}
|
|
208
|
+
setListFilters={updateListingFilters}
|
|
217
209
|
/>
|
|
218
210
|
</>
|
|
219
211
|
)}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import React from 'react';
|
|
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
|
|
|
@@ -13,36 +12,53 @@ const ListingTableContent = ({
|
|
|
13
12
|
currentPage,
|
|
14
13
|
totalItems
|
|
15
14
|
}) => {
|
|
15
|
+
const ref = useRef(null);
|
|
16
16
|
const displayTable = tableData && tableData.rows && !!tableData.rows.length;
|
|
17
17
|
const { isEnquiry } = tableData;
|
|
18
18
|
const className = `page__content${isEnquiry ? ' array-table' : ''}`;
|
|
19
19
|
|
|
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
|
+
);
|
|
27
|
+
|
|
28
|
+
firstRowCells.forEach((element, i) => {
|
|
29
|
+
const styles = window.getComputedStyle(element);
|
|
30
|
+
|
|
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
|
+
}
|
|
57
|
+
|
|
20
58
|
return (
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
<div className={className}>
|
|
25
|
-
<Table
|
|
26
|
-
onSort={onSort}
|
|
27
|
-
data={tableData}
|
|
28
|
-
checkboxes={!isEnquiry}
|
|
29
|
-
onSelect={handleSelect}
|
|
30
|
-
data-testid="listing-table-content"
|
|
31
|
-
/>
|
|
32
|
-
<Pagination
|
|
33
|
-
visiblePages={10}
|
|
34
|
-
totalItems={totalItems}
|
|
35
|
-
currentPage={currentPage}
|
|
36
|
-
onPageChange={handleOnPageChange}
|
|
37
|
-
/>
|
|
38
|
-
</div>
|
|
39
|
-
</>
|
|
40
|
-
) : (
|
|
41
|
-
<span className="table-no-results" data-testid="no-results">
|
|
42
|
-
No results
|
|
43
|
-
</span>
|
|
44
|
-
)}
|
|
45
|
-
</>
|
|
59
|
+
<span className="table-no-results" data-testid="no-results">
|
|
60
|
+
No results
|
|
61
|
+
</span>
|
|
46
62
|
);
|
|
47
63
|
};
|
|
48
64
|
|