@blaze-cms/plugin-data-ui 0.131.0-project-admin-customisations.2 → 0.132.0-admin-updates.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -47
- package/README.md +0 -42
- package/lib/components/EntityDataListing/EntityDataListing.js +24 -3
- package/lib/components/EntityDataListing/EntityDataListing.js.map +1 -1
- package/lib/components/EntityManager/Entity/Entity.js +3 -16
- package/lib/components/EntityManager/Entity/Entity.js.map +1 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/index.js +2 -12
- package/lib/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
- package/lib/components/ListingTable/ListingTable.js +80 -113
- package/lib/components/ListingTable/ListingTable.js.map +1 -1
- package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js +20 -8
- package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
- package/lib/components/ListingTable/mappers/populate-rows.js +26 -92
- package/lib/components/ListingTable/mappers/populate-rows.js.map +1 -1
- package/lib/components/ListingTable/service/index.js +11 -73
- package/lib/components/ListingTable/service/index.js.map +1 -1
- package/lib/index.js +11 -3
- package/lib/index.js.map +1 -1
- package/lib/utils/add-content-menu-items.js +13 -64
- package/lib/utils/add-content-menu-items.js.map +1 -1
- package/lib/utils/build-listing-query.js +2 -11
- package/lib/utils/build-listing-query.js.map +1 -1
- package/lib/utils/get-default-query-params.js +4 -3
- package/lib/utils/get-default-query-params.js.map +1 -1
- package/lib-es/components/EntityDataListing/EntityDataListing.js +14 -3
- package/lib-es/components/EntityDataListing/EntityDataListing.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/Entity.js +3 -16
- package/lib-es/components/EntityManager/Entity/Entity.js.map +1 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js +2 -12
- package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
- package/lib-es/components/ListingTable/ListingTable.js +49 -46
- package/lib-es/components/ListingTable/ListingTable.js.map +1 -1
- package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js +19 -11
- package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
- package/lib-es/components/ListingTable/mappers/populate-rows.js +24 -76
- package/lib-es/components/ListingTable/mappers/populate-rows.js.map +1 -1
- package/lib-es/components/ListingTable/service/index.js +7 -65
- package/lib-es/components/ListingTable/service/index.js.map +1 -1
- package/lib-es/index.js +9 -1
- package/lib-es/index.js.map +1 -1
- package/lib-es/utils/add-content-menu-items.js +5 -49
- package/lib-es/utils/add-content-menu-items.js.map +1 -1
- package/lib-es/utils/build-listing-query.js +1 -10
- package/lib-es/utils/build-listing-query.js.map +1 -1
- package/lib-es/utils/get-default-query-params.js +3 -1
- package/lib-es/utils/get-default-query-params.js.map +1 -1
- package/package.json +9 -10
- package/src/components/EntityDataListing/EntityDataListing.js +12 -3
- package/src/components/EntityManager/Entity/Entity.js +1 -10
- package/src/components/EntityManager/Entity/SideBarRelations/index.js +16 -34
- package/src/components/ListingTable/ListingTable.js +38 -57
- package/src/components/ListingTable/ListingTableContent/ListingTableContent.js +22 -8
- package/src/components/ListingTable/mappers/populate-rows.js +18 -83
- package/src/components/ListingTable/service/index.js +5 -42
- package/src/index.js +8 -1
- package/src/utils/add-content-menu-items.js +3 -45
- package/src/utils/build-listing-query.js +1 -11
- package/src/utils/get-default-query-params.js +1 -1
- package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +0 -39
- package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js.map +0 -1
- package/lib/components/EntityManager/Entity/EntitiyNavLinks/index.js +0 -12
- package/lib/components/EntityManager/Entity/EntitiyNavLinks/index.js.map +0 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +0 -44
- package/lib/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js.map +0 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +0 -32
- package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +0 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +0 -45
- package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +0 -1
- package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +0 -38
- package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +0 -1
- package/lib/components/InfoBoxes/InfoBoxes.js +0 -36
- package/lib/components/InfoBoxes/InfoBoxes.js.map +0 -1
- package/lib/components/InfoBoxes/container/InfoBoxContainer.js +0 -44
- package/lib/components/InfoBoxes/container/InfoBoxContainer.js.map +0 -1
- package/lib/components/InfoBoxes/helpers/build-dynamic-query.js +0 -25
- package/lib/components/InfoBoxes/helpers/build-dynamic-query.js.map +0 -1
- package/lib/components/InfoBoxes/hooks/useData.js +0 -42
- package/lib/components/InfoBoxes/hooks/useData.js.map +0 -1
- package/lib/components/InfoBoxes/hooks/useInfoBox.js +0 -26
- package/lib/components/InfoBoxes/hooks/useInfoBox.js.map +0 -1
- package/lib/components/InfoBoxes/index.js +0 -12
- package/lib/components/InfoBoxes/index.js.map +0 -1
- package/lib/components/InfoBoxes/presentational/InfoBox.js +0 -46
- package/lib/components/InfoBoxes/presentational/InfoBox.js.map +0 -1
- package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +0 -30
- package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js.map +0 -1
- package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/index.js +0 -3
- package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/index.js.map +0 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +0 -30
- package/lib-es/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js.map +0 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +0 -26
- package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +0 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +0 -39
- package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +0 -1
- package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +0 -24
- package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +0 -1
- package/lib-es/components/InfoBoxes/InfoBoxes.js +0 -28
- package/lib-es/components/InfoBoxes/InfoBoxes.js.map +0 -1
- package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js +0 -30
- package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js.map +0 -1
- package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js +0 -25
- package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js.map +0 -1
- package/lib-es/components/InfoBoxes/hooks/useData.js +0 -37
- package/lib-es/components/InfoBoxes/hooks/useData.js.map +0 -1
- package/lib-es/components/InfoBoxes/hooks/useInfoBox.js +0 -19
- package/lib-es/components/InfoBoxes/hooks/useInfoBox.js.map +0 -1
- package/lib-es/components/InfoBoxes/index.js +0 -3
- package/lib-es/components/InfoBoxes/index.js.map +0 -1
- package/lib-es/components/InfoBoxes/presentational/InfoBox.js +0 -31
- package/lib-es/components/InfoBoxes/presentational/InfoBox.js.map +0 -1
- package/src/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +0 -26
- package/src/components/EntityManager/Entity/EntitiyNavLinks/index.js +0 -3
- package/src/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +0 -22
- package/src/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +0 -33
- package/src/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +0 -28
- package/src/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +0 -33
- package/src/components/InfoBoxes/InfoBoxes.js +0 -24
- package/src/components/InfoBoxes/container/InfoBoxContainer.js +0 -22
- package/src/components/InfoBoxes/helpers/build-dynamic-query.js +0 -25
- package/src/components/InfoBoxes/hooks/useData.js +0 -20
- package/src/components/InfoBoxes/hooks/useInfoBox.js +0 -13
- package/src/components/InfoBoxes/index.js +0 -3
- package/src/components/InfoBoxes/presentational/InfoBox.js +0 -34
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-default-query-params.js","names":["getDefaultQueryParams","schema","updated","properties","adminDefaultListingFilter","where","displayProperties","limit","offset","sort","property","direction"],"sources":["../../src/utils/get-default-query-params.js"],"sourcesContent":["const getDefaultQueryParams = schema => {\n const updated = schema.properties && schema.properties.updated;\n const { adminDefaultListingFilter: where } = schema.displayProperties || {};\n\n return {\n where,\n limit: 40,\n offset: 0,\n sort: updated\n ? [\n {\n property: 'updated',\n direction: 'desc'\n }\n ]\n : []\n };\n};\n\nexport { getDefaultQueryParams };\n"],"mappings":"AAAA,MAAMA,qBAAqB,
|
|
1
|
+
{"version":3,"file":"get-default-query-params.js","names":["getDefaultQueryParams","schema","updated","properties","adminDefaultListingFilter","where","displayProperties","limit","offset","sort","property","direction"],"sources":["../../src/utils/get-default-query-params.js"],"sourcesContent":["const getDefaultQueryParams = ({ schema }) => {\n const updated = schema.properties && schema.properties.updated;\n const { adminDefaultListingFilter: where } = schema.displayProperties || {};\n\n return {\n where,\n limit: 40,\n offset: 0,\n sort: updated\n ? [\n {\n property: 'updated',\n direction: 'desc'\n }\n ]\n : []\n };\n};\n\nexport { getDefaultQueryParams };\n"],"mappings":"AAAA,MAAMA,qBAAqB,GAAGA,CAAC;EAAEC;AAAO,CAAC,KAAK;EAC5C,MAAMC,OAAO,GAAGD,MAAM,CAACE,UAAU,IAAIF,MAAM,CAACE,UAAU,CAACD,OAAO;EAC9D,MAAM;IAAEE,yBAAyB,EAAEC;EAAM,CAAC,GAAGJ,MAAM,CAACK,iBAAiB,IAAI,CAAC,CAAC;EAE3E,OAAO;IACLD,KAAK;IACLE,KAAK,EAAE,EAAE;IACTC,MAAM,EAAE,CAAC;IACTC,IAAI,EAAEP,OAAO,GACT,CACE;MACEQ,QAAQ,EAAE,SAAS;MACnBC,SAAS,EAAE;IACb,CAAC,CACF,GACD;EACN,CAAC;AACH,CAAC;AAED,SAASX,qBAAqB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blaze-cms/plugin-data-ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.132.0-admin-updates.0",
|
|
4
4
|
"description": "Blaze plugin data ui",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"module": "lib-es/index.js",
|
|
@@ -27,13 +27,12 @@
|
|
|
27
27
|
},
|
|
28
28
|
"license": "GPL-3.0",
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@blaze-cms/admin-ui-utils": "0.
|
|
31
|
-
"@blaze-cms/core-errors": "0.
|
|
32
|
-
"@blaze-cms/
|
|
33
|
-
"@blaze-cms/react-
|
|
34
|
-
"@blaze-cms/
|
|
35
|
-
"@blaze-cms/
|
|
36
|
-
"@blaze-cms/versioning-ui": "0.131.0-project-admin-customisations.0",
|
|
30
|
+
"@blaze-cms/admin-ui-utils": "0.132.0-admin-updates.0",
|
|
31
|
+
"@blaze-cms/core-errors": "0.132.0-admin-updates.0",
|
|
32
|
+
"@blaze-cms/react-form-builder": "0.132.0-admin-updates.0",
|
|
33
|
+
"@blaze-cms/react-page-builder": "0.132.0-admin-updates.0",
|
|
34
|
+
"@blaze-cms/setup-ui": "0.132.0-admin-updates.0",
|
|
35
|
+
"@blaze-cms/versioning-ui": "0.132.0-admin-updates.0",
|
|
37
36
|
"@blaze-react/button": "0.5.19",
|
|
38
37
|
"@blaze-react/more": "0.5.19",
|
|
39
38
|
"@blaze-react/multiselect": "0.6.6",
|
|
@@ -54,7 +53,7 @@
|
|
|
54
53
|
"uuid": "^3.3.3"
|
|
55
54
|
},
|
|
56
55
|
"devDependencies": {
|
|
57
|
-
"@blaze-cms/core-ui": "0.
|
|
56
|
+
"@blaze-cms/core-ui": "0.132.0-admin-updates.0"
|
|
58
57
|
},
|
|
59
58
|
"peerDependencies": {
|
|
60
59
|
"@apollo/client": "3.x",
|
|
@@ -66,5 +65,5 @@
|
|
|
66
65
|
"lib/*",
|
|
67
66
|
"lib-es/*"
|
|
68
67
|
],
|
|
69
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "fd6ece22f357131c0b0e5201e5e1df825389b860"
|
|
70
69
|
}
|
|
@@ -6,22 +6,31 @@ import { getQuery } from '@blaze-cms/admin-ui-utils';
|
|
|
6
6
|
import ListingTable from '../ListingTable/ListingTable';
|
|
7
7
|
import { withContext } from '../../utils/hoc/withContext';
|
|
8
8
|
|
|
9
|
-
const EntityDataListing = ({ match }) => {
|
|
9
|
+
const EntityDataListing = ({ match, menuItems }) => {
|
|
10
10
|
const {
|
|
11
11
|
params: { entityIdentifier: identifier }
|
|
12
12
|
} = match;
|
|
13
13
|
|
|
14
|
+
const [[selectedMenuItem]] = menuItems
|
|
15
|
+
.map(([_, { items }]) => {
|
|
16
|
+
const item = items.filter(({ uri }) => uri.endsWith(`/${identifier}`));
|
|
17
|
+
|
|
18
|
+
return item.length ? item : null;
|
|
19
|
+
})
|
|
20
|
+
.filter(Boolean);
|
|
21
|
+
|
|
14
22
|
const { data: { getEntitySchemas = [] } = {} } = useQuery(getQuery('GET_ENTITY_SCHEMA'), {
|
|
15
23
|
variables: { identifier }
|
|
16
24
|
});
|
|
17
25
|
|
|
18
26
|
if (!getEntitySchemas.length) return '';
|
|
19
27
|
|
|
20
|
-
return <ListingTable entitySchema={getEntitySchemas[0]} />;
|
|
28
|
+
return <ListingTable entitySchema={getEntitySchemas[0]} selectedMenuItem={selectedMenuItem} />;
|
|
21
29
|
};
|
|
22
30
|
|
|
23
31
|
EntityDataListing.propTypes = {
|
|
24
|
-
match: PropTypes.object.isRequired
|
|
32
|
+
match: PropTypes.object.isRequired,
|
|
33
|
+
menuItems: PropTypes.array.isRequired
|
|
25
34
|
};
|
|
26
35
|
|
|
27
36
|
export default withContext(EntityDataListing);
|
|
@@ -3,7 +3,6 @@ import React, { useEffect, useState, useRef } from 'react';
|
|
|
3
3
|
import { withRouter, Prompt } from 'react-router-dom';
|
|
4
4
|
import { useApolloClient } from '@apollo/client';
|
|
5
5
|
import PropTypes from 'prop-types';
|
|
6
|
-
import { RenderHook } from '@blaze-cms/plugin-render-hooks-ui';
|
|
7
6
|
import { getQuery, GET_CURRENT_TAB_ID } from '@blaze-cms/admin-ui-utils';
|
|
8
7
|
import { FormBuilder, parseFormValues } from '@blaze-cms/react-form-builder';
|
|
9
8
|
import { DeleteAction, CopyDataFromAction } from '@blaze-cms/admin';
|
|
@@ -35,7 +34,6 @@ import {
|
|
|
35
34
|
checkFulfilConditions
|
|
36
35
|
} from '../utils/entity';
|
|
37
36
|
import useToggle from '../../../utils/hooks/useToggle';
|
|
38
|
-
import InfoBoxes from '../../InfoBoxes/InfoBoxes';
|
|
39
37
|
|
|
40
38
|
const Entity = ({
|
|
41
39
|
formData,
|
|
@@ -442,8 +440,6 @@ const Entity = ({
|
|
|
442
440
|
<div className="page__content--fixed">
|
|
443
441
|
<div className="page__content">
|
|
444
442
|
<div className="content">
|
|
445
|
-
<RenderHook hookKey={`entity:${action}:main:top`} entity={entity} schema={schema} />
|
|
446
|
-
<InfoBoxes id={entity.id} schema={schema} />
|
|
447
443
|
<Tabs
|
|
448
444
|
enabled={showPageBuilderTabs}
|
|
449
445
|
onTabChange={tabId => {
|
|
@@ -465,17 +461,12 @@ const Entity = ({
|
|
|
465
461
|
isNewEntity={isNewEntity}
|
|
466
462
|
/>
|
|
467
463
|
</Tabs>
|
|
468
|
-
<RenderHook
|
|
469
|
-
hookKey={`entity:${action}:main:bottom`}
|
|
470
|
-
entity={entity}
|
|
471
|
-
schema={schema}
|
|
472
|
-
/>
|
|
473
464
|
</div>
|
|
474
465
|
</div>
|
|
475
466
|
</div>
|
|
476
467
|
</div>
|
|
477
468
|
|
|
478
|
-
<div className="column column--one-third page-sidebar
|
|
469
|
+
<div className="column column--one-third page-sidebar">
|
|
479
470
|
{showSideBarRelations && (
|
|
480
471
|
<SideBarRelations
|
|
481
472
|
entity={entity}
|
|
@@ -7,8 +7,6 @@ import { formFieldTypes } from '@blaze-cms/react-form-builder';
|
|
|
7
7
|
import classnames from 'classnames';
|
|
8
8
|
import { VersionsList } from '@blaze-cms/versioning-ui';
|
|
9
9
|
import { PUBLISHED, UNPUBLISHED } from '../../../../constants';
|
|
10
|
-
import CustomSidebarInfoContainer from './container/CustomSidebarInfoContainer';
|
|
11
|
-
import EntityNavLinks from '../EntitiyNavLinks';
|
|
12
10
|
|
|
13
11
|
const SideBarRelations = ({ schema, onChange, formData, entity }) => {
|
|
14
12
|
const { relation: RelationComponent } = formFieldTypes;
|
|
@@ -20,9 +18,7 @@ const SideBarRelations = ({ schema, onChange, formData, entity }) => {
|
|
|
20
18
|
status
|
|
21
19
|
} = formData;
|
|
22
20
|
const client = useApolloClient();
|
|
23
|
-
|
|
24
21
|
const [relationsComponents, setRelationsComponents] = useState(null);
|
|
25
|
-
|
|
26
22
|
useEffect(
|
|
27
23
|
() => {
|
|
28
24
|
(async () => {
|
|
@@ -68,42 +64,28 @@ const SideBarRelations = ({ schema, onChange, formData, entity }) => {
|
|
|
68
64
|
return (
|
|
69
65
|
<div className="sidebar" data-testid="sideBarRelations-main-div">
|
|
70
66
|
<div className="sidebar__content">
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
<div className="
|
|
74
|
-
<
|
|
75
|
-
|
|
76
|
-
<span className={statusClassName}>{formattedStatus}</span>
|
|
77
|
-
</div>
|
|
78
|
-
{formattedStatus === PUBLISHED && (
|
|
79
|
-
<p>
|
|
80
|
-
{formattedStatus} on: <span> {formattedPublished}</span>
|
|
81
|
-
</p>
|
|
82
|
-
)}
|
|
67
|
+
{formattedCreated && (
|
|
68
|
+
<div className="sidebar__status">
|
|
69
|
+
<div className="sidebar__status__wrapper">
|
|
70
|
+
<b>Status</b>
|
|
71
|
+
<span className={statusClassName}>{formattedStatus}</span>
|
|
83
72
|
</div>
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
{!schema.displayProperties.adminMainInfoProperty && (
|
|
87
|
-
<>
|
|
73
|
+
{formattedStatus === PUBLISHED && (
|
|
88
74
|
<p>
|
|
89
|
-
|
|
75
|
+
{formattedStatus} on: <span> {formattedPublished}</span>
|
|
90
76
|
</p>
|
|
91
|
-
|
|
92
|
-
Updated: <span>{formattedUpdated}</span>
|
|
93
|
-
</p>
|
|
94
|
-
</>
|
|
95
|
-
)}
|
|
77
|
+
)}
|
|
96
78
|
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
79
|
+
<p>
|
|
80
|
+
Created: <span>{formattedCreated}</span>
|
|
81
|
+
</p>
|
|
82
|
+
<p>
|
|
83
|
+
Updated: <span>{formattedUpdated}</span>
|
|
84
|
+
</p>
|
|
85
|
+
</div>
|
|
86
|
+
)}
|
|
103
87
|
|
|
104
88
|
<VersionsList itemEntity={itemEntity} itemId={itemId} interfaces={interfaces} />
|
|
105
|
-
<EntityNavLinks schema={schema} />
|
|
106
|
-
|
|
107
89
|
{relationsComponents &&
|
|
108
90
|
relationsComponents.map(({ id, staticData, schema: entitySchema }) => (
|
|
109
91
|
<RelationComponent
|
|
@@ -3,27 +3,27 @@ import React, { useEffect, useState, Fragment } from 'react';
|
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
4
|
import { withRouter, Link } from 'react-router-dom';
|
|
5
5
|
import More from '@blaze-react/more';
|
|
6
|
+
import { MainContext, useMainContext } from '@blaze-cms/admin-ui-utils';
|
|
6
7
|
import { PageHeader, DeleteAction } from '@blaze-cms/admin';
|
|
7
8
|
import { useToasts } from '@blaze-react/toaster';
|
|
8
|
-
import { RenderHook } from '@blaze-cms/plugin-render-hooks-ui';
|
|
9
9
|
import ListingTableContent from './ListingTableContent';
|
|
10
10
|
import availableActions from '../EntityManager/Entity/actions-handlers';
|
|
11
11
|
import { fetchData } from './service';
|
|
12
|
-
import { populateRows, formatRows
|
|
12
|
+
import { populateRows, formatRows } from './mappers/populate-rows';
|
|
13
13
|
import { getDefaultQueryParams } from '../../utils/get-default-query-params';
|
|
14
14
|
|
|
15
15
|
const OVER_SCAN_BUFFER = 10;
|
|
16
16
|
|
|
17
|
-
const ListingTable = ({ match, entitySchema }) => {
|
|
17
|
+
const ListingTable = ({ match, entitySchema, selectedMenuItem }) => {
|
|
18
18
|
const [tableData, setTableData] = useState({});
|
|
19
19
|
const [modalStatus, setModalStatus] = useState(false);
|
|
20
20
|
const [itemToDelete, setItemToDelete] = useState({});
|
|
21
21
|
const [previousSchema, setPreviousSchema] = useState({ id: null });
|
|
22
22
|
const [scrollToIndex, setScrollToIndex] = useState(0);
|
|
23
23
|
const [verifiedRanges, setVerifiedRanges] = useState([]);
|
|
24
|
-
const queryParamsDefault = getDefaultQueryParams(entitySchema);
|
|
24
|
+
const queryParamsDefault = getDefaultQueryParams({ schema: entitySchema });
|
|
25
25
|
const [queryParams, setQueryParams] = useState(queryParamsDefault);
|
|
26
|
-
const
|
|
26
|
+
const { menuItems, setMenuItems } = useMainContext(MainContext);
|
|
27
27
|
const client = useApolloClient();
|
|
28
28
|
const { addToast } = useToasts();
|
|
29
29
|
|
|
@@ -34,7 +34,20 @@ const ListingTable = ({ match, entitySchema }) => {
|
|
|
34
34
|
entitySchema.id !== previousSchema.id ||
|
|
35
35
|
(previousSchema.id === null && entitySchema.id)
|
|
36
36
|
) {
|
|
37
|
-
await
|
|
37
|
+
const data = await fetchData({
|
|
38
|
+
client,
|
|
39
|
+
querySettings: {
|
|
40
|
+
entitySchema,
|
|
41
|
+
queryParams: queryParamsDefault
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
const populatedTable = populateRows({
|
|
45
|
+
toggleModal,
|
|
46
|
+
url: match.url,
|
|
47
|
+
entitySchema,
|
|
48
|
+
rows: data
|
|
49
|
+
});
|
|
50
|
+
setTableData(populatedTable);
|
|
38
51
|
setPreviousSchema({ id: entitySchema.id });
|
|
39
52
|
}
|
|
40
53
|
})();
|
|
@@ -42,33 +55,18 @@ const ListingTable = ({ match, entitySchema }) => {
|
|
|
42
55
|
[client, entitySchema, match.url, previousSchema.id, queryParams] // eslint-disable-line react-hooks/exhaustive-deps
|
|
43
56
|
);
|
|
44
57
|
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
const populatedTable = populateRows({
|
|
56
|
-
toggleModal,
|
|
57
|
-
url: match.url,
|
|
58
|
-
entitySchema,
|
|
59
|
-
rows: data
|
|
60
|
-
});
|
|
61
|
-
|
|
62
|
-
setTableData(populatedTable);
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
const updateListingFilters = async filters => {
|
|
66
|
-
await doQuery(filters);
|
|
67
|
-
setListFilters(filters);
|
|
58
|
+
const onCloseCardPrompt = () => {
|
|
59
|
+
const updatedSelectedMenuItem = {
|
|
60
|
+
...selectedMenuItem,
|
|
61
|
+
isDisplayedPrompt: false
|
|
62
|
+
};
|
|
63
|
+
const [{ header, items }] = menuItems;
|
|
64
|
+
const updatedItems = items.map(
|
|
65
|
+
item => (item.name === selectedMenuItem.name ? updatedSelectedMenuItem : item)
|
|
66
|
+
);
|
|
67
|
+
setMenuItems([{ header, items: updatedItems }]);
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
const onCloseCardPrompt = () => null;
|
|
71
|
-
|
|
72
70
|
const toggleModal = item => {
|
|
73
71
|
setModalStatus(!!item);
|
|
74
72
|
setItemToDelete(item || {});
|
|
@@ -109,22 +107,15 @@ const ListingTable = ({ match, entitySchema }) => {
|
|
|
109
107
|
querySettings: {
|
|
110
108
|
entitySchema,
|
|
111
109
|
queryParams: sortQueryParams
|
|
112
|
-
}
|
|
113
|
-
listFilters
|
|
110
|
+
}
|
|
114
111
|
});
|
|
115
|
-
const { columns
|
|
112
|
+
const { columns } = tableData;
|
|
116
113
|
const [firstColumn] = columns;
|
|
117
114
|
|
|
118
115
|
setTableData({
|
|
119
116
|
...tableData,
|
|
120
117
|
appliedSort: { [property]: direction },
|
|
121
|
-
rows: formatRows({
|
|
122
|
-
rows: getParsedRowData(data),
|
|
123
|
-
url: match.url,
|
|
124
|
-
toggleModal,
|
|
125
|
-
firstColumn,
|
|
126
|
-
isEnquiry
|
|
127
|
-
})
|
|
118
|
+
rows: formatRows({ rows: data, url: match.url, toggleModal, firstColumn })
|
|
128
119
|
});
|
|
129
120
|
};
|
|
130
121
|
|
|
@@ -142,17 +133,11 @@ const ListingTable = ({ match, entitySchema }) => {
|
|
|
142
133
|
querySettings: {
|
|
143
134
|
entitySchema,
|
|
144
135
|
queryParams: updatedQueryParams
|
|
145
|
-
}
|
|
146
|
-
listFilters
|
|
136
|
+
}
|
|
147
137
|
});
|
|
148
138
|
const updatedRows = [
|
|
149
139
|
...tableData.rows,
|
|
150
|
-
...formatRows({
|
|
151
|
-
rows: getParsedRowData(data),
|
|
152
|
-
url: match.url,
|
|
153
|
-
toggleModal,
|
|
154
|
-
isEnquiry: tableData.isEnquiry
|
|
155
|
-
})
|
|
140
|
+
...formatRows({ rows: data, url: match.url, toggleModal })
|
|
156
141
|
];
|
|
157
142
|
|
|
158
143
|
setVerifiedRanges([...verifiedRanges, loadIndex]);
|
|
@@ -166,7 +151,6 @@ const ListingTable = ({ match, entitySchema }) => {
|
|
|
166
151
|
};
|
|
167
152
|
|
|
168
153
|
if (!tableData || !tableData.rows) return 'loading';
|
|
169
|
-
const showAddButton = !!tableData.rows.length && !tableData.isEnquiry;
|
|
170
154
|
|
|
171
155
|
return (
|
|
172
156
|
<div className="page">
|
|
@@ -178,7 +162,7 @@ const ListingTable = ({ match, entitySchema }) => {
|
|
|
178
162
|
/>
|
|
179
163
|
)}
|
|
180
164
|
<PageHeader title={entitySchema.displayName} subtitle="">
|
|
181
|
-
{
|
|
165
|
+
{(!selectedMenuItem.isDisplayedPrompt || !!tableData.rows.length) && (
|
|
182
166
|
<Fragment>
|
|
183
167
|
<Link
|
|
184
168
|
data-testid="addEntity"
|
|
@@ -197,17 +181,13 @@ const ListingTable = ({ match, entitySchema }) => {
|
|
|
197
181
|
</Fragment>
|
|
198
182
|
)}
|
|
199
183
|
</PageHeader>
|
|
200
|
-
<RenderHook
|
|
201
|
-
hookKey="entity:listing:main:top"
|
|
202
|
-
schema={entitySchema}
|
|
203
|
-
setListFilters={updateListingFilters}
|
|
204
|
-
/>
|
|
205
184
|
<ListingTableContent
|
|
206
185
|
overScanBuffer={OVER_SCAN_BUFFER}
|
|
207
186
|
onSort={handleSort}
|
|
208
187
|
onRenderItems={handleRenderedItems}
|
|
209
188
|
tableData={tableData}
|
|
210
189
|
onCloseCardPrompt={onCloseCardPrompt}
|
|
190
|
+
selectedMenuItem={selectedMenuItem}
|
|
211
191
|
scrollToIndex={scrollToIndex}
|
|
212
192
|
/>
|
|
213
193
|
</div>
|
|
@@ -215,7 +195,8 @@ const ListingTable = ({ match, entitySchema }) => {
|
|
|
215
195
|
};
|
|
216
196
|
ListingTable.propTypes = {
|
|
217
197
|
entitySchema: PropTypes.object.isRequired,
|
|
218
|
-
match: PropTypes.object.isRequired
|
|
198
|
+
match: PropTypes.object.isRequired,
|
|
199
|
+
selectedMenuItem: PropTypes.object.isRequired
|
|
219
200
|
};
|
|
220
201
|
|
|
221
202
|
export default withRouter(ListingTable);
|
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import Table from '@blaze-react/table';
|
|
3
3
|
import PropTypes from 'prop-types';
|
|
4
|
-
import {
|
|
4
|
+
import { CardPrompt } from '@blaze-cms/admin';
|
|
5
|
+
import { Link, withRouter } from 'react-router-dom';
|
|
5
6
|
|
|
6
7
|
const ListingTableContent = ({
|
|
7
8
|
tableData,
|
|
8
9
|
handleSelect,
|
|
10
|
+
onCloseCardPrompt,
|
|
11
|
+
selectedMenuItem,
|
|
12
|
+
match,
|
|
9
13
|
onSort,
|
|
10
14
|
onClickRow,
|
|
11
15
|
overScanBuffer,
|
|
@@ -13,14 +17,12 @@ const ListingTableContent = ({
|
|
|
13
17
|
scrollToIndex
|
|
14
18
|
}) => {
|
|
15
19
|
const displayTable = tableData && tableData.rows && !!tableData.rows.length;
|
|
16
|
-
const { isEnquiry } = tableData;
|
|
17
|
-
const className = `page__content${isEnquiry ? ' array-table' : ''}`;
|
|
18
20
|
|
|
19
21
|
return (
|
|
20
22
|
<>
|
|
21
|
-
{displayTable
|
|
23
|
+
{displayTable ? (
|
|
22
24
|
<>
|
|
23
|
-
<div className=
|
|
25
|
+
<div className="page__content">
|
|
24
26
|
<Table
|
|
25
27
|
scrollToIndex={scrollToIndex}
|
|
26
28
|
onSort={onSort}
|
|
@@ -28,12 +30,23 @@ const ListingTableContent = ({
|
|
|
28
30
|
overScanBuffer={overScanBuffer}
|
|
29
31
|
onRenderItems={onRenderItems}
|
|
30
32
|
data={tableData}
|
|
31
|
-
checkboxes
|
|
33
|
+
checkboxes
|
|
32
34
|
onSelect={handleSelect}
|
|
33
35
|
data-testid="listing-table-content"
|
|
34
36
|
/>
|
|
35
37
|
</div>
|
|
36
38
|
</>
|
|
39
|
+
) : (
|
|
40
|
+
selectedMenuItem.isDisplayedPrompt && (
|
|
41
|
+
<CardPrompt onClose={onCloseCardPrompt} data-testid="card-prompt">
|
|
42
|
+
<Link
|
|
43
|
+
className="button button--rounded button--cta"
|
|
44
|
+
to={`${match.url}/create`}
|
|
45
|
+
data-testid="add-button">
|
|
46
|
+
Add
|
|
47
|
+
</Link>
|
|
48
|
+
</CardPrompt>
|
|
49
|
+
)
|
|
37
50
|
)}
|
|
38
51
|
</>
|
|
39
52
|
);
|
|
@@ -41,6 +54,8 @@ const ListingTableContent = ({
|
|
|
41
54
|
|
|
42
55
|
ListingTableContent.propTypes = {
|
|
43
56
|
tableData: PropTypes.object.isRequired,
|
|
57
|
+
onCloseCardPrompt: PropTypes.func.isRequired,
|
|
58
|
+
selectedMenuItem: PropTypes.object.isRequired,
|
|
44
59
|
match: PropTypes.shape({
|
|
45
60
|
url: PropTypes.string
|
|
46
61
|
}).isRequired,
|
|
@@ -58,8 +73,7 @@ ListingTableContent.defaultProps = {
|
|
|
58
73
|
onClickRow: () => {},
|
|
59
74
|
overScanBuffer: 0,
|
|
60
75
|
scrollToIndex: 0,
|
|
61
|
-
onRenderItems: () => {}
|
|
62
|
-
selectedMenuItem: null
|
|
76
|
+
onRenderItems: () => {}
|
|
63
77
|
};
|
|
64
78
|
|
|
65
79
|
export default withRouter(ListingTableContent);
|
|
@@ -3,22 +3,18 @@ import { Link } from 'react-router-dom';
|
|
|
3
3
|
import TableActions from '../TableActions';
|
|
4
4
|
import { ACTIONS } from '../../../constants';
|
|
5
5
|
|
|
6
|
-
const formatRows = ({ rows, url, toggleModal, label, firstColumn = 'name'
|
|
6
|
+
const formatRows = ({ rows, url, toggleModal, label, firstColumn = 'name' }) =>
|
|
7
7
|
rows.map(data => {
|
|
8
8
|
const editUrl = `${url}/update/${data.id}`;
|
|
9
|
-
|
|
9
|
+
return {
|
|
10
10
|
...data,
|
|
11
11
|
[firstColumn]: (
|
|
12
12
|
<Link to={editUrl} role="button">
|
|
13
13
|
{data[firstColumn]}
|
|
14
14
|
</Link>
|
|
15
|
-
)
|
|
15
|
+
),
|
|
16
|
+
actions: <TableActions editUrl={editUrl} data={data} showDeleteModal={toggleModal} />
|
|
16
17
|
};
|
|
17
|
-
if (!isEnquiry)
|
|
18
|
-
rowProps.actions = (
|
|
19
|
-
<TableActions editUrl={editUrl} data={data} showDeleteModal={toggleModal} />
|
|
20
|
-
);
|
|
21
|
-
return rowProps;
|
|
22
18
|
});
|
|
23
19
|
|
|
24
20
|
const getSanitizedColumnLabel = columnProp => {
|
|
@@ -32,82 +28,22 @@ const getSanitizedColumnLabel = columnProp => {
|
|
|
32
28
|
return sanitizedChar;
|
|
33
29
|
};
|
|
34
30
|
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
<span className="table-row-list__group__item__label"> {label}:</span>
|
|
42
|
-
{url ? (
|
|
43
|
-
<Link to={url} role="button" className="table-row-list__group__item__value">
|
|
44
|
-
{value}
|
|
45
|
-
</Link>
|
|
46
|
-
) : (
|
|
47
|
-
<span className="table-row-list__group__item__value"> {value}</span>
|
|
48
|
-
)}
|
|
49
|
-
</div>
|
|
50
|
-
))}
|
|
51
|
-
</div>
|
|
52
|
-
))}
|
|
53
|
-
</div>
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
const buildArrayRowData = rowData => {
|
|
57
|
-
const dataGroups = [];
|
|
58
|
-
const groups = Math.ceil(rowData.length / 3) || 1;
|
|
59
|
-
for (let index = 0; index < groups; index += 1) {
|
|
60
|
-
const currentStart = index * groups;
|
|
61
|
-
dataGroups[index] = rowData.slice(currentStart, currentStart + 3);
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
return buildArrayRowContent(dataGroups);
|
|
65
|
-
};
|
|
66
|
-
|
|
67
|
-
const getParsedRowData = rows =>
|
|
68
|
-
rows.map(rowData =>
|
|
69
|
-
Object.keys(rowData).reduce((acc, key) => {
|
|
70
|
-
const parsedData = Array.isArray(rowData[key])
|
|
71
|
-
? buildArrayRowData(rowData[key])
|
|
72
|
-
: rowData[key];
|
|
73
|
-
return { ...acc, [key]: parsedData };
|
|
74
|
-
}, {})
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
const getColumnsAndLabels = (listingProperties, allProperties, rows) => {
|
|
78
|
-
const columns = [];
|
|
79
|
-
const labels = {};
|
|
80
|
-
|
|
81
|
-
listingProperties.forEach(listingProperty => {
|
|
82
|
-
const propKey = listingProperty.includes(' ') ? listingProperty.split(' ')[0] : listingProperty;
|
|
83
|
-
const { label } = allProperties[propKey] || {};
|
|
84
|
-
columns.push(propKey);
|
|
85
|
-
labels[propKey] = label || getSanitizedColumnLabel(propKey);
|
|
86
|
-
});
|
|
87
|
-
const parsedRowData = getParsedRowData(rows);
|
|
88
|
-
|
|
89
|
-
return { columns, labels, parsedRowData };
|
|
31
|
+
const getColumnLabels = (listingProperties, properties, dynamicProperties) => {
|
|
32
|
+
const allProperties = { ...properties, ...dynamicProperties };
|
|
33
|
+
return listingProperties.reduce((acc, listingProperty) => {
|
|
34
|
+
const label = allProperties[listingProperty].label || getSanitizedColumnLabel(listingProperty);
|
|
35
|
+
return { ...acc, ...{ [listingProperty]: label } };
|
|
36
|
+
}, {});
|
|
90
37
|
};
|
|
91
38
|
|
|
92
39
|
const populateRows = ({ toggleModal, url, entitySchema, rows }) => {
|
|
93
|
-
const {
|
|
94
|
-
|
|
95
|
-
listingProperties,
|
|
96
|
-
properties,
|
|
97
|
-
dynamicProperties = {},
|
|
98
|
-
formProperties
|
|
99
|
-
} = entitySchema;
|
|
100
|
-
|
|
101
|
-
const isEnquiry = schemaId === 'enquiry';
|
|
102
|
-
const columnOptions = !isEnquiry ? [...listingProperties, ACTIONS] : [...listingProperties];
|
|
103
|
-
|
|
104
|
-
const allProperties = { ...properties, ...dynamicProperties };
|
|
105
|
-
const { columns, labels, parsedRowData } = getColumnsAndLabels(
|
|
106
|
-
columnOptions,
|
|
107
|
-
allProperties,
|
|
108
|
-
rows
|
|
109
|
-
);
|
|
40
|
+
const { listingProperties, properties, dynamicProperties = {}, formProperties } = entitySchema;
|
|
41
|
+
const columns = [...listingProperties, ACTIONS];
|
|
110
42
|
const [firstColumn] = columns;
|
|
43
|
+
const labels = {
|
|
44
|
+
...getColumnLabels(listingProperties, properties, dynamicProperties),
|
|
45
|
+
[ACTIONS]: ACTIONS
|
|
46
|
+
};
|
|
111
47
|
|
|
112
48
|
return {
|
|
113
49
|
identification: 'id',
|
|
@@ -115,9 +51,8 @@ const populateRows = ({ toggleModal, url, entitySchema, rows }) => {
|
|
|
115
51
|
columns,
|
|
116
52
|
labels,
|
|
117
53
|
orderBy: [...formProperties],
|
|
118
|
-
rows: formatRows({ firstColumn, rows
|
|
119
|
-
isEnquiry
|
|
54
|
+
rows: formatRows({ firstColumn, rows, url, toggleModal })
|
|
120
55
|
};
|
|
121
56
|
};
|
|
122
57
|
|
|
123
|
-
export { populateRows, formatRows
|
|
58
|
+
export { populateRows, formatRows };
|
|
@@ -1,49 +1,12 @@
|
|
|
1
1
|
import buildListingQuery from '../../../utils/build-listing-query';
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
const
|
|
5
|
-
const { sort, offset, limit, where } = queryParams;
|
|
6
|
-
const [{ property, direction }] = sort;
|
|
7
|
-
const parsedOffset = `${property}:${direction}`;
|
|
8
|
-
|
|
9
|
-
if (!isSearchQuery)
|
|
10
|
-
return {
|
|
11
|
-
...queryParams,
|
|
12
|
-
where: !Array.isArray(listFilters) ? listFilters : where
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
const rawQuery = {
|
|
16
|
-
bool: {
|
|
17
|
-
must: listFilters || [],
|
|
18
|
-
filter: [
|
|
19
|
-
{
|
|
20
|
-
term: {
|
|
21
|
-
entityIdentifier: identifier
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
]
|
|
25
|
-
}
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
return {
|
|
29
|
-
limit,
|
|
30
|
-
offset,
|
|
31
|
-
sort: parsedOffset,
|
|
32
|
-
where: JSON.stringify(rawQuery)
|
|
33
|
-
};
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
const fetchData = async ({ client, querySettings: { entitySchema, queryParams }, listFilters }) => {
|
|
3
|
+
const fetchData = async ({ client, querySettings: { entitySchema, queryParams } }) => {
|
|
4
|
+
const query = buildListingQuery(entitySchema);
|
|
37
5
|
const {
|
|
38
|
-
|
|
39
|
-
} =
|
|
40
|
-
|
|
41
|
-
const isSearchQuery = source === 'search';
|
|
42
|
-
const query = buildListingQuery(entitySchema, isSearchQuery);
|
|
43
|
-
const variables = buildVariables({ entitySchema, listFilters, queryParams, isSearchQuery });
|
|
44
|
-
const { data = {} } = await client.query({ query, variables, fetchPolicy: 'network-only' });
|
|
6
|
+
data: { listingData }
|
|
7
|
+
} = await client.query({ query, variables: queryParams, fetchPolicy: 'network-only' });
|
|
45
8
|
|
|
46
|
-
return
|
|
9
|
+
return listingData;
|
|
47
10
|
};
|
|
48
11
|
|
|
49
12
|
export { fetchData };
|