@blaze-cms/plugin-data-ui 0.146.0-node18-core-styles-tooltips.45 → 0.146.0-node18-tooltips.38
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 +33 -129
- package/lib-es/components/EntityDataListing/EntityDataListing.js +33 -0
- package/lib-es/components/EntityDataListing/EntityDataListing.js.map +1 -0
- package/lib-es/components/EntityDataListing/index.js +3 -0
- package/lib-es/components/EntityDataListing/index.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +30 -0
- package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/index.js +3 -0
- package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/index.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/Entity.js +452 -0
- package/lib-es/components/EntityManager/Entity/Entity.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/EntityHeader/EntityHeader.js +103 -0
- package/lib-es/components/EntityManager/Entity/EntityHeader/EntityHeader.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js +47 -0
- package/lib-es/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/index.js +3 -0
- package/lib-es/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/index.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/EntityHeader/index.js +3 -0
- package/lib-es/components/EntityManager/Entity/EntityHeader/index.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +30 -0
- package/lib-es/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +29 -0
- package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +49 -0
- package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js +133 -0
- package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +36 -0
- package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/actions-handlers/create/index.js +5 -0
- package/lib-es/components/EntityManager/Entity/actions-handlers/create/index.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/actions-handlers/create/submit.js +46 -0
- package/lib-es/components/EntityManager/Entity/actions-handlers/create/submit.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/actions-handlers/delete/delete.js +32 -0
- package/lib-es/components/EntityManager/Entity/actions-handlers/delete/delete.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/actions-handlers/delete/index.js +5 -0
- package/lib-es/components/EntityManager/Entity/actions-handlers/delete/index.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/actions-handlers/index.js +12 -0
- package/lib-es/components/EntityManager/Entity/actions-handlers/index.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/actions-handlers/shared/index.js +5 -0
- package/lib-es/components/EntityManager/Entity/actions-handlers/shared/index.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/actions-handlers/shared/publish.js +39 -0
- package/lib-es/components/EntityManager/Entity/actions-handlers/shared/publish.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/actions-handlers/update/index.js +5 -0
- package/lib-es/components/EntityManager/Entity/actions-handlers/update/index.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/actions-handlers/update/submit.js +53 -0
- package/lib-es/components/EntityManager/Entity/actions-handlers/update/submit.js.map +1 -0
- package/lib-es/components/EntityManager/Entity/index.js +3 -0
- package/lib-es/components/EntityManager/Entity/index.js.map +1 -0
- package/lib-es/components/EntityManager/EntityManager.js +133 -0
- package/lib-es/components/EntityManager/EntityManager.js.map +1 -0
- package/lib-es/components/EntityManager/index.js +3 -0
- package/lib-es/components/EntityManager/index.js.map +1 -0
- package/lib-es/components/EntityManager/utils/RecordEditContext/index.js +6 -0
- package/lib-es/components/EntityManager/utils/RecordEditContext/index.js.map +1 -0
- package/lib-es/components/EntityManager/utils/data-mappers.js +55 -0
- package/lib-es/components/EntityManager/utils/data-mappers.js.map +1 -0
- package/lib-es/components/EntityManager/utils/entity.js +70 -0
- package/lib-es/components/EntityManager/utils/entity.js.map +1 -0
- package/lib-es/components/EntityManager/utils/entityAvailableActions.js +56 -0
- package/lib-es/components/EntityManager/utils/entityAvailableActions.js.map +1 -0
- package/lib-es/components/EntityManager/utils/is-form-empty.js +9 -0
- package/lib-es/components/EntityManager/utils/is-form-empty.js.map +1 -0
- package/lib-es/components/EntityManager/utils/query.js +23 -0
- package/lib-es/components/EntityManager/utils/query.js.map +1 -0
- 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 +28 -0
- package/lib-es/components/InfoBoxes/InfoBoxes.js.map +1 -0
- package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js +38 -0
- package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js.map +1 -0
- package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js +28 -0
- package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js.map +1 -0
- package/lib-es/components/InfoBoxes/hooks/useData.js +39 -0
- package/lib-es/components/InfoBoxes/hooks/useData.js.map +1 -0
- package/lib-es/components/InfoBoxes/hooks/useInfoBox.js +17 -0
- package/lib-es/components/InfoBoxes/hooks/useInfoBox.js.map +1 -0
- package/lib-es/components/InfoBoxes/index.js +3 -0
- package/lib-es/components/InfoBoxes/index.js.map +1 -0
- package/lib-es/components/InfoBoxes/presentational/InfoBox.js +40 -0
- package/lib-es/components/InfoBoxes/presentational/InfoBox.js.map +1 -0
- package/lib-es/components/InfoBoxes/presentational/InfoBoxLabel.js +12 -0
- package/lib-es/components/InfoBoxes/presentational/InfoBoxLabel.js.map +1 -0
- package/lib-es/components/InfoBoxes/presentational/InfoBoxValue.js +30 -0
- package/lib-es/components/InfoBoxes/presentational/InfoBoxValue.js.map +1 -0
- package/lib-es/components/ListingTable/ListingTable.js +208 -0
- package/lib-es/components/ListingTable/ListingTable.js.map +1 -0
- package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js +72 -0
- package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -0
- package/lib-es/components/ListingTable/ListingTableContent/index.js +3 -0
- package/lib-es/components/ListingTable/ListingTableContent/index.js.map +1 -0
- 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 +34 -0
- package/lib-es/components/ListingTable/TableActions/TableActions.js.map +1 -0
- package/lib-es/components/ListingTable/TableActions/index.js +3 -0
- package/lib-es/components/ListingTable/TableActions/index.js.map +1 -0
- package/lib-es/components/ListingTable/index.js +3 -0
- package/lib-es/components/ListingTable/index.js.map +1 -0
- package/lib-es/components/ListingTable/mappers/populate-rows.js +140 -0
- package/lib-es/components/ListingTable/mappers/populate-rows.js.map +1 -0
- package/lib-es/components/ListingTable/service/index.js +87 -0
- package/lib-es/components/ListingTable/service/index.js.map +1 -0
- package/lib-es/components/Tabs/index.js +40 -0
- package/lib-es/components/Tabs/index.js.map +1 -0
- package/lib-es/components/hooks/useCallbackDebounce.js +12 -0
- package/lib-es/components/hooks/useCallbackDebounce.js.map +1 -0
- package/lib-es/constants.js +42 -0
- package/lib-es/constants.js.map +1 -0
- package/lib-es/icons/ContentIcon.js +80 -0
- package/lib-es/icons/ContentIcon.js.map +1 -0
- package/lib-es/icons/SettingsIcon.js +36 -0
- package/lib-es/icons/SettingsIcon.js.map +1 -0
- package/lib-es/icons/TaxonomyIcon.js +60 -0
- package/lib-es/icons/TaxonomyIcon.js.map +1 -0
- package/lib-es/icons/UsersIcon.js +33 -0
- package/lib-es/icons/UsersIcon.js.map +1 -0
- package/lib-es/icons/index.js +6 -0
- package/lib-es/icons/index.js.map +1 -0
- package/lib-es/index.js +84 -0
- package/lib-es/index.js.map +1 -0
- package/lib-es/utils/add-content-menu-items.js +72 -0
- package/lib-es/utils/add-content-menu-items.js.map +1 -0
- package/lib-es/utils/build-create-entity-mutation.js +21 -0
- package/lib-es/utils/build-create-entity-mutation.js.map +1 -0
- package/lib-es/utils/build-delete-entity-mutation.js +18 -0
- package/lib-es/utils/build-delete-entity-mutation.js.map +1 -0
- package/lib-es/utils/build-listing-query.js +28 -0
- package/lib-es/utils/build-listing-query.js.map +1 -0
- package/lib-es/utils/build-update-data-query.js +24 -0
- package/lib-es/utils/build-update-data-query.js.map +1 -0
- package/lib-es/utils/build-update-publish-unpublish-mutation.js +22 -0
- package/lib-es/utils/build-update-publish-unpublish-mutation.js.map +1 -0
- package/lib-es/utils/get-default-query-params.js +17 -0
- package/lib-es/utils/get-default-query-params.js.map +1 -0
- package/lib-es/utils/hoc/withContext.js +8 -0
- package/lib-es/utils/hoc/withContext.js.map +1 -0
- package/lib-es/utils/hooks/useToggle.js +8 -0
- package/lib-es/utils/hooks/useToggle.js.map +1 -0
- package/lib-es/utils/index.js +3 -0
- package/lib-es/utils/index.js.map +1 -0
- package/package.json +10 -10
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { gql } from '@apollo/client';
|
|
2
|
+
import { BlazeError } from '@blaze-cms/core-errors';
|
|
3
|
+
export default function buildDynamicQuery({
|
|
4
|
+
id,
|
|
5
|
+
schema,
|
|
6
|
+
properties
|
|
7
|
+
}) {
|
|
8
|
+
if (!id) return null;
|
|
9
|
+
if (!schema || !schema.actions || !schema.actions.get || !schema.properties) {
|
|
10
|
+
throw new BlazeError('DataEntity query requires get action, properties and fields from entity schema');
|
|
11
|
+
}
|
|
12
|
+
const fields = properties.map(infoProperty => `${infoProperty} {
|
|
13
|
+
label
|
|
14
|
+
value
|
|
15
|
+
showLabel
|
|
16
|
+
url
|
|
17
|
+
tooltipIcon
|
|
18
|
+
tooltipContent
|
|
19
|
+
}`);
|
|
20
|
+
return gql`query getInfoBoxData($id: String!){
|
|
21
|
+
${schema.actions.get}( id: $id ) {
|
|
22
|
+
id
|
|
23
|
+
${fields.map(field => field)}
|
|
24
|
+
__typename
|
|
25
|
+
}
|
|
26
|
+
}`;
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=build-dynamic-query.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"build-dynamic-query.js","names":["gql","BlazeError","buildDynamicQuery","id","schema","properties","actions","get","fields","map","infoProperty","field"],"sources":["../../../../src/components/InfoBoxes/helpers/build-dynamic-query.js"],"sourcesContent":["import { gql } from '@apollo/client';\nimport { BlazeError } from '@blaze-cms/core-errors';\n\nexport default function buildDynamicQuery({ id, schema, properties }) {\n if (!id) return null;\n\n if (!schema || !schema.actions || !schema.actions.get || !schema.properties) {\n throw new BlazeError(\n 'DataEntity query requires get action, properties and fields from entity schema'\n );\n }\n\n const fields = properties.map(\n infoProperty =>\n `${infoProperty} {\n label\n value\n showLabel\n url\n tooltipIcon\n tooltipContent\n }`\n );\n\n return gql`query getInfoBoxData($id: String!){\n ${schema.actions.get}( id: $id ) {\n id\n ${fields.map(field => field)}\n __typename\n }\n }`;\n}\n"],"mappings":"AAAA,SAASA,GAAG,QAAQ,gBAAgB;AACpC,SAASC,UAAU,QAAQ,wBAAwB;AAEnD,eAAe,SAASC,iBAAiBA,CAAC;EAAEC,EAAE;EAAEC,MAAM;EAAEC;AAAW,CAAC,EAAE;EACpE,IAAI,CAACF,EAAE,EAAE,OAAO,IAAI;EAEpB,IAAI,CAACC,MAAM,IAAI,CAACA,MAAM,CAACE,OAAO,IAAI,CAACF,MAAM,CAACE,OAAO,CAACC,GAAG,IAAI,CAACH,MAAM,CAACC,UAAU,EAAE;IAC3E,MAAM,IAAIJ,UAAU,CAClB,gFACF,CAAC;EACH;EAEA,MAAMO,MAAM,GAAGH,UAAU,CAACI,GAAG,CAC3BC,YAAY,IACV,GAAGA,YAAY;AACrB;AACA;AACA;AACA;AACA;AACA;AACA,MACE,CAAC;EAED,OAAOV,GAAG;AACZ,MAAMI,MAAM,CAACE,OAAO,CAACC,GAAG;AACxB;AACA,QAAQC,MAAM,CAACC,GAAG,CAACE,KAAK,IAAIA,KAAK,CAAC;AAClC;AACA;AACA,IAAI;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { useQuery, gql } from '@apollo/client';
|
|
2
|
+
import useInfoBoxData from './useInfoBox';
|
|
3
|
+
function useData({
|
|
4
|
+
id,
|
|
5
|
+
schema,
|
|
6
|
+
infoBox
|
|
7
|
+
}) {
|
|
8
|
+
const {
|
|
9
|
+
query
|
|
10
|
+
} = useInfoBoxData({
|
|
11
|
+
id,
|
|
12
|
+
schema,
|
|
13
|
+
infoBox
|
|
14
|
+
});
|
|
15
|
+
const infoBoxQuery = query || gql`
|
|
16
|
+
query {
|
|
17
|
+
__typename
|
|
18
|
+
}
|
|
19
|
+
`;
|
|
20
|
+
const {
|
|
21
|
+
data = {},
|
|
22
|
+
loading,
|
|
23
|
+
error,
|
|
24
|
+
refetch
|
|
25
|
+
} = useQuery(infoBoxQuery, {
|
|
26
|
+
variables: {
|
|
27
|
+
id
|
|
28
|
+
},
|
|
29
|
+
skip: !query
|
|
30
|
+
});
|
|
31
|
+
return {
|
|
32
|
+
data: data.__typename !== 'Query' ? data : null,
|
|
33
|
+
loading,
|
|
34
|
+
error,
|
|
35
|
+
refetch
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
export default useData;
|
|
39
|
+
//# sourceMappingURL=useData.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useData.js","names":["useQuery","gql","useInfoBoxData","useData","id","schema","infoBox","query","infoBoxQuery","data","loading","error","refetch","variables","skip","__typename"],"sources":["../../../../src/components/InfoBoxes/hooks/useData.js"],"sourcesContent":["import { useQuery, gql } from '@apollo/client';\nimport useInfoBoxData from './useInfoBox';\n\nfunction useData({ id, schema, infoBox }) {\n const { query } = useInfoBoxData({ id, schema, infoBox });\n\n const infoBoxQuery =\n query ||\n gql`\n query {\n __typename\n }\n `;\n\n const {\n data = {},\n loading,\n error,\n refetch\n } = useQuery(infoBoxQuery, {\n variables: { id },\n skip: !query\n });\n\n return { data: data.__typename !== 'Query' ? data : null, loading, error, refetch };\n}\n\nexport default useData;\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,GAAG,QAAQ,gBAAgB;AAC9C,OAAOC,cAAc,MAAM,cAAc;AAEzC,SAASC,OAAOA,CAAC;EAAEC,EAAE;EAAEC,MAAM;EAAEC;AAAQ,CAAC,EAAE;EACxC,MAAM;IAAEC;EAAM,CAAC,GAAGL,cAAc,CAAC;IAAEE,EAAE;IAAEC,MAAM;IAAEC;EAAQ,CAAC,CAAC;EAEzD,MAAME,YAAY,GAChBD,KAAK,IACLN,GAAG;AACP;AACA;AACA;AACA,KAAK;EAEH,MAAM;IACJQ,IAAI,GAAG,CAAC,CAAC;IACTC,OAAO;IACPC,KAAK;IACLC;EACF,CAAC,GAAGZ,QAAQ,CAACQ,YAAY,EAAE;IACzBK,SAAS,EAAE;MAAET;IAAG,CAAC;IACjBU,IAAI,EAAE,CAACP;EACT,CAAC,CAAC;EAEF,OAAO;IAAEE,IAAI,EAAEA,IAAI,CAACM,UAAU,KAAK,OAAO,GAAGN,IAAI,GAAG,IAAI;IAAEC,OAAO;IAAEC,KAAK;IAAEC;EAAQ,CAAC;AACrF;AAEA,eAAeT,OAAO","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import buildDynamicQuery from '../helpers/build-dynamic-query';
|
|
2
|
+
function useInfoBox({
|
|
3
|
+
id,
|
|
4
|
+
schema,
|
|
5
|
+
infoBox
|
|
6
|
+
}) {
|
|
7
|
+
const query = buildDynamicQuery({
|
|
8
|
+
id,
|
|
9
|
+
schema,
|
|
10
|
+
properties: [infoBox.property]
|
|
11
|
+
});
|
|
12
|
+
return {
|
|
13
|
+
query: query || null
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
export default useInfoBox;
|
|
17
|
+
//# sourceMappingURL=useInfoBox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useInfoBox.js","names":["buildDynamicQuery","useInfoBox","id","schema","infoBox","query","properties","property"],"sources":["../../../../src/components/InfoBoxes/hooks/useInfoBox.js"],"sourcesContent":["import buildDynamicQuery from '../helpers/build-dynamic-query';\n\nfunction useInfoBox({ id, schema, infoBox }) {\n const query = buildDynamicQuery({\n id,\n schema,\n properties: [infoBox.property]\n });\n\n return { query: query || null };\n}\n\nexport default useInfoBox;\n"],"mappings":"AAAA,OAAOA,iBAAiB,MAAM,gCAAgC;AAE9D,SAASC,UAAUA,CAAC;EAAEC,EAAE;EAAEC,MAAM;EAAEC;AAAQ,CAAC,EAAE;EAC3C,MAAMC,KAAK,GAAGL,iBAAiB,CAAC;IAC9BE,EAAE;IACFC,MAAM;IACNG,UAAU,EAAE,CAACF,OAAO,CAACG,QAAQ;EAC/B,CAAC,CAAC;EAEF,OAAO;IAAEF,KAAK,EAAEA,KAAK,IAAI;EAAK,CAAC;AACjC;AAEA,eAAeJ,UAAU","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["InfoBoxes"],"sources":["../../../src/components/InfoBoxes/index.js"],"sourcesContent":["import InfoBoxes from './InfoBoxes';\n\nexport default InfoBoxes;\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,aAAa;AAEnC,eAAeA,SAAS","ignoreList":[]}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import InfoBoxValue from './InfoBoxValue';
|
|
4
|
+
import InfoBoxLabel from './InfoBoxLabel';
|
|
5
|
+
import InfoBoxTooltip from '../InfoBoxTooltip';
|
|
6
|
+
const InfoBox = ({
|
|
7
|
+
items,
|
|
8
|
+
infoBoxKey
|
|
9
|
+
}) => {
|
|
10
|
+
if (!items) return null;
|
|
11
|
+
const infoBoxItems = items.map(item => Object.values(item).map(info => {
|
|
12
|
+
if (!info.label || !info.value) return null;
|
|
13
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
14
|
+
className: "info-box--item",
|
|
15
|
+
key: `${infoBoxKey}-${info.label.toLowerCase()}`
|
|
16
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
17
|
+
className: "info-box--label"
|
|
18
|
+
}, /*#__PURE__*/React.createElement(InfoBoxLabel, {
|
|
19
|
+
item: info
|
|
20
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
21
|
+
className: "info-box--value"
|
|
22
|
+
}, /*#__PURE__*/React.createElement(InfoBoxValue, {
|
|
23
|
+
item: info
|
|
24
|
+
}), /*#__PURE__*/React.createElement(InfoBoxTooltip, {
|
|
25
|
+
info: info
|
|
26
|
+
})));
|
|
27
|
+
}).filter(Boolean));
|
|
28
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
29
|
+
className: "info-box",
|
|
30
|
+
key: infoBoxKey
|
|
31
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
32
|
+
className: "info-box--container"
|
|
33
|
+
}, infoBoxItems));
|
|
34
|
+
};
|
|
35
|
+
InfoBox.propTypes = {
|
|
36
|
+
infoBoxKey: PropTypes.string.isRequired,
|
|
37
|
+
items: PropTypes.array.isRequired
|
|
38
|
+
};
|
|
39
|
+
export default InfoBox;
|
|
40
|
+
//# sourceMappingURL=InfoBox.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InfoBox.js","names":["PropTypes","React","InfoBoxValue","InfoBoxLabel","InfoBoxTooltip","InfoBox","items","infoBoxKey","infoBoxItems","map","item","Object","values","info","label","value","createElement","className","key","toLowerCase","filter","Boolean","propTypes","string","isRequired","array"],"sources":["../../../../src/components/InfoBoxes/presentational/InfoBox.js"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\nimport InfoBoxValue from './InfoBoxValue';\nimport InfoBoxLabel from './InfoBoxLabel';\nimport InfoBoxTooltip from '../InfoBoxTooltip';\n\nconst InfoBox = ({ items, infoBoxKey }) => {\n if (!items) return null;\n\n const infoBoxItems = items.map(item =>\n Object.values(item)\n .map(info => {\n if (!info.label || !info.value) return null;\n\n return (\n <div className=\"info-box--item\" key={`${infoBoxKey}-${info.label.toLowerCase()}`}>\n <div className=\"info-box--label\">\n <InfoBoxLabel item={info} />\n </div>\n <div className=\"info-box--value\">\n <InfoBoxValue item={info} />\n <InfoBoxTooltip info={info} />\n </div>\n </div>\n );\n })\n .filter(Boolean)\n );\n\n return (\n <div className=\"info-box\" key={infoBoxKey}>\n <div className=\"info-box--container\">{infoBoxItems}</div>\n </div>\n );\n};\n\nInfoBox.propTypes = {\n infoBoxKey: PropTypes.string.isRequired,\n items: PropTypes.array.isRequired\n};\n\nexport default InfoBox;\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,YAAY;AAClC,OAAOC,KAAK,MAAM,OAAO;AACzB,OAAOC,YAAY,MA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AU;EACvClB,KAAK,EAAEN,SAAS,CAACyB,KAAK,CAACD;AACzB,CAAC;AAED,eAAenB,OAAO","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InfoBoxLabel.js","names":["InfoBoxLabel","item","suffix","label","showLabel"],"sources":["../../../../src/components/InfoBoxes/presentational/InfoBoxLabel.js"],"sourcesContent":["const InfoBoxLabel = ({ item, suffix = ' ' }) => {\n const { label, showLabel = true } = item;\n return showLabel ? `${label}:${suffix}` : null;\n};\n\nexport default InfoBoxLabel;\n"],"mappings":"AAAA,MAAMA,YAAY,GAAGA,CAAC;EAAEC,IAAI;EAAEC,MAAM,GAAG;AAAI,CAAC,KAAK;EAC/C,MAAM;IAAEC,KAAK;IAAEC,SAAS,GAAG;EAAK,CAAC,GAAGH,IAAI;EACxC,OAAOG,SAAS,GAAG,GAAGD,KAAK,IAAID,MAAM,EAAE,GAAG,IAAI;AAChD,CAAC;AAED,eAAeF,YAAY","ignoreList":[]}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import PropTypes from 'prop-types';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { Link } from 'react-router-dom';
|
|
4
|
+
const InfoBoxValue = ({
|
|
5
|
+
item = {}
|
|
6
|
+
}) => {
|
|
7
|
+
const {
|
|
8
|
+
url,
|
|
9
|
+
value
|
|
10
|
+
} = item;
|
|
11
|
+
if (url) {
|
|
12
|
+
if (url.startsWith('http')) {
|
|
13
|
+
return /*#__PURE__*/React.createElement("a", {
|
|
14
|
+
href: url,
|
|
15
|
+
target: "_blank",
|
|
16
|
+
rel: "noopener noreferrer"
|
|
17
|
+
}, value);
|
|
18
|
+
}
|
|
19
|
+
return /*#__PURE__*/React.createElement(Link, {
|
|
20
|
+
to: url,
|
|
21
|
+
target: "_blank"
|
|
22
|
+
}, value);
|
|
23
|
+
}
|
|
24
|
+
return value;
|
|
25
|
+
};
|
|
26
|
+
InfoBoxValue.propTypes = {
|
|
27
|
+
item: PropTypes.object.isRequired
|
|
28
|
+
};
|
|
29
|
+
export default InfoBoxValue;
|
|
30
|
+
//# sourceMappingURL=InfoBoxValue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"InfoBoxValue.js","names":["PropTypes","React","Link","InfoBoxValue","item","url","value","startsWith","createElement","href","target","rel","to","propTypes","object","isRequired"],"sources":["../../../../src/components/InfoBoxes/presentational/InfoBoxValue.js"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\nimport { Link } from 'react-router-dom';\n\nconst InfoBoxValue = ({ item = {} }) => {\n const { url, value } = item;\n if (url) {\n if (url.startsWith('http')) {\n return (\n <a href={url} target=\"_blank\" rel=\"noopener noreferrer\">\n {value}\n </a>\n );\n }\n return (\n <Link to={url} target=\"_blank\">\n {value}\n </Link>\n );\n }\n\n return value;\n};\n\nInfoBoxValue.propTypes = {\n item: PropTypes.object.isRequired\n};\n\nexport default InfoBoxValue;\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,YAAY;AAClC,OAAOC,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,QAAQ,kBAAkB;AAEvC,MAAMC,YAAY,GAAGA,CAAC;EAAEC,IAAI,GAAG,CAAC;AAAE,CAAC,KAAK;EACtC,MAAM;IAAEC,GAAG;IAAEC;EAAM,CAAC,GAAGF,IAAI;EAC3B,IAAIC,GAAG,EAAE;IACP,IAAIA,GAAG,CAACE,UAAU,CAAC,MAAM,CAAC,EAAE;MAC1B,oBACEN,KAAA,CAAAO,aAAA;QAAGC,IAAI,EAAEJ,GAAI;QAACK,MAAM,EAAC,QAAQ;QAACC,GAAG,EAAC;MAAqB,GACpDL,KACA,CAAC;IAER;IACA,oBACEL,KAAA,CAAAO,aAAA,CAACN,IAAI;MAACU,EAAE,EAAEP,GAAI;MAACK,MAAM,EAAC;IAAQ,GAC3BJ,KACG,CAAC;EAEX;EAEA,OAAOA,KAAK;AACd,CAAC;AAEDH,YAAY,CAACU,SAAS,GAAG;EACvBT,IAAI,EAAEJ,SAAS,CAACc,MAAM,CAACC;AACzB,CAAC;AAED,eAAeZ,YAAY","ignoreList":[]}
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
2
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
3
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
|
+
import React, { useEffect, useState, Fragment } from 'react';
|
|
5
|
+
import PropTypes from 'prop-types';
|
|
6
|
+
import { useApolloClient } from '@apollo/client';
|
|
7
|
+
import { withRouter, Link, useLocation } from 'react-router-dom';
|
|
8
|
+
import { PageHeader, DeleteAction, CardPrompt } from '@blaze-cms/admin';
|
|
9
|
+
import { useToasts } from '@blaze-react/toaster';
|
|
10
|
+
import { RenderHook } from '@blaze-cms/plugin-render-hooks-ui';
|
|
11
|
+
import ListingTableContent from './ListingTableContent';
|
|
12
|
+
import SearchFilter from './SearchFilter/SearchFilter';
|
|
13
|
+
import availableActions from '../EntityManager/Entity/actions-handlers';
|
|
14
|
+
import { fetchData } from './service';
|
|
15
|
+
import { populateRows, formatRows, getParsedRowData } from './mappers/populate-rows';
|
|
16
|
+
import { getDefaultQueryParams } from '../../utils/get-default-query-params';
|
|
17
|
+
const ListingTable = ({
|
|
18
|
+
match,
|
|
19
|
+
entitySchema,
|
|
20
|
+
history
|
|
21
|
+
}) => {
|
|
22
|
+
const [tableData, setTableData] = useState({});
|
|
23
|
+
const [modalStatus, setModalStatus] = useState(false);
|
|
24
|
+
const [itemToDelete, setItemToDelete] = useState({});
|
|
25
|
+
const [previousSchema, setPreviousSchema] = useState({
|
|
26
|
+
id: null
|
|
27
|
+
});
|
|
28
|
+
const [totalItems, setTotalItems] = useState(0);
|
|
29
|
+
const queryParamsDefault = getDefaultQueryParams(entitySchema);
|
|
30
|
+
const [queryParams, setQueryParams] = useState(queryParamsDefault);
|
|
31
|
+
const [listFilters, setListFilters] = useState([]);
|
|
32
|
+
const client = useApolloClient();
|
|
33
|
+
const {
|
|
34
|
+
addToast
|
|
35
|
+
} = useToasts();
|
|
36
|
+
const location = useLocation();
|
|
37
|
+
const searchParams = new URLSearchParams(location.search);
|
|
38
|
+
const currentPage = Number(searchParams.get('page')) || 1;
|
|
39
|
+
useEffect(() => {
|
|
40
|
+
(async () => {
|
|
41
|
+
if (entitySchema.id !== previousSchema.id || previousSchema.id === null && entitySchema.id) {
|
|
42
|
+
const updatedQueryParams = _objectSpread(_objectSpread({}, queryParams), {}, {
|
|
43
|
+
offset: currentPage * queryParamsDefault.limit - queryParamsDefault.limit
|
|
44
|
+
});
|
|
45
|
+
await doQuery([], updatedQueryParams);
|
|
46
|
+
setPreviousSchema({
|
|
47
|
+
id: entitySchema.id
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
})();
|
|
51
|
+
}, [client, entitySchema, match.url, previousSchema.id, queryParams] // eslint-disable-line react-hooks/exhaustive-deps
|
|
52
|
+
);
|
|
53
|
+
const doQuery = async (filters = listFilters, params = queryParamsDefault) => {
|
|
54
|
+
const {
|
|
55
|
+
listingData,
|
|
56
|
+
totalRecords
|
|
57
|
+
} = await fetchData({
|
|
58
|
+
client,
|
|
59
|
+
querySettings: {
|
|
60
|
+
entitySchema,
|
|
61
|
+
queryParams: params
|
|
62
|
+
},
|
|
63
|
+
listFilters: filters
|
|
64
|
+
});
|
|
65
|
+
const populatedTable = populateRows({
|
|
66
|
+
toggleModal,
|
|
67
|
+
url: match.url,
|
|
68
|
+
entitySchema,
|
|
69
|
+
rows: listingData
|
|
70
|
+
});
|
|
71
|
+
setTableData(populatedTable);
|
|
72
|
+
setTotalItems(totalRecords);
|
|
73
|
+
};
|
|
74
|
+
const handleOnPageChange = async ({
|
|
75
|
+
pageNumber,
|
|
76
|
+
offset: _offset
|
|
77
|
+
}) => {
|
|
78
|
+
const updatedQueryParams = _objectSpread(_objectSpread({}, queryParams), {}, {
|
|
79
|
+
offset: _offset
|
|
80
|
+
});
|
|
81
|
+
await doQuery(listFilters, updatedQueryParams);
|
|
82
|
+
history.push(`?page=${pageNumber}`);
|
|
83
|
+
document.getElementsByClassName('page')[0].scrollTo(0, 0);
|
|
84
|
+
};
|
|
85
|
+
const updateListingFilters = async filters => {
|
|
86
|
+
await doQuery(filters);
|
|
87
|
+
setListFilters(filters);
|
|
88
|
+
};
|
|
89
|
+
const onCloseCardPrompt = () => null;
|
|
90
|
+
const toggleModal = item => {
|
|
91
|
+
setModalStatus(!!item);
|
|
92
|
+
setItemToDelete(item || {});
|
|
93
|
+
};
|
|
94
|
+
const deleteAction = async () => {
|
|
95
|
+
await availableActions.delete.submit({
|
|
96
|
+
entitySchema,
|
|
97
|
+
parsedFormValues: {
|
|
98
|
+
id: itemToDelete.id
|
|
99
|
+
},
|
|
100
|
+
client
|
|
101
|
+
}, addToast);
|
|
102
|
+
toggleModal();
|
|
103
|
+
const updatedTableData = _objectSpread(_objectSpread({}, tableData), {}, {
|
|
104
|
+
rows: tableData.rows.filter(({
|
|
105
|
+
id
|
|
106
|
+
}) => id !== itemToDelete.id)
|
|
107
|
+
});
|
|
108
|
+
setTableData(updatedTableData);
|
|
109
|
+
};
|
|
110
|
+
const handleSort = async event => {
|
|
111
|
+
const [[property, direction]] = Object.entries(event);
|
|
112
|
+
const sortQueryParams = _objectSpread(_objectSpread({}, queryParamsDefault), {}, {
|
|
113
|
+
sort: [{
|
|
114
|
+
property,
|
|
115
|
+
direction
|
|
116
|
+
}]
|
|
117
|
+
});
|
|
118
|
+
setQueryParams(sortQueryParams);
|
|
119
|
+
const {
|
|
120
|
+
listingData
|
|
121
|
+
} = await fetchData({
|
|
122
|
+
client,
|
|
123
|
+
querySettings: {
|
|
124
|
+
entitySchema,
|
|
125
|
+
queryParams: sortQueryParams
|
|
126
|
+
},
|
|
127
|
+
listFilters
|
|
128
|
+
});
|
|
129
|
+
const {
|
|
130
|
+
columns,
|
|
131
|
+
isEnquiry
|
|
132
|
+
} = tableData;
|
|
133
|
+
const [firstColumn] = columns;
|
|
134
|
+
setTableData(_objectSpread(_objectSpread({}, tableData), {}, {
|
|
135
|
+
appliedSort: {
|
|
136
|
+
[property]: direction
|
|
137
|
+
},
|
|
138
|
+
rows: formatRows({
|
|
139
|
+
rows: getParsedRowData(listingData),
|
|
140
|
+
url: match.url,
|
|
141
|
+
toggleModal,
|
|
142
|
+
firstColumn,
|
|
143
|
+
isEnquiry,
|
|
144
|
+
entitySchema
|
|
145
|
+
})
|
|
146
|
+
}));
|
|
147
|
+
history.push('?page=1');
|
|
148
|
+
};
|
|
149
|
+
if (!tableData || !tableData.rows) return 'loading';
|
|
150
|
+
const {
|
|
151
|
+
displayProperties: {
|
|
152
|
+
adminCrudActions: {
|
|
153
|
+
create: createAction = {
|
|
154
|
+
active: true
|
|
155
|
+
},
|
|
156
|
+
delete: _deleteAction = {
|
|
157
|
+
active: true
|
|
158
|
+
}
|
|
159
|
+
} = {}
|
|
160
|
+
} = {}
|
|
161
|
+
} = entitySchema;
|
|
162
|
+
const showAddButton = !tableData.rows.length && listFilters.length === 0;
|
|
163
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
164
|
+
className: "page"
|
|
165
|
+
}, modalStatus && _deleteAction.active && /*#__PURE__*/React.createElement(DeleteAction, {
|
|
166
|
+
"data-testid": "deleteEntity",
|
|
167
|
+
onClose: toggleModal,
|
|
168
|
+
deleteAction: deleteAction,
|
|
169
|
+
itemName: itemToDelete.name
|
|
170
|
+
}), /*#__PURE__*/React.createElement(PageHeader, {
|
|
171
|
+
title: entitySchema.displayName,
|
|
172
|
+
subtitle: ""
|
|
173
|
+
}, createAction.active && !showAddButton && /*#__PURE__*/React.createElement(Link, {
|
|
174
|
+
"data-testid": "addEntity",
|
|
175
|
+
className: "button button--small",
|
|
176
|
+
to: `${match.url}/create`
|
|
177
|
+
}, "Add")), showAddButton ? /*#__PURE__*/React.createElement(CardPrompt, null, /*#__PURE__*/React.createElement(Link, {
|
|
178
|
+
className: "button button--rounded button--cta",
|
|
179
|
+
to: `${match.url}/create`,
|
|
180
|
+
"data-testid": "add-button"
|
|
181
|
+
}, "Add")) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(RenderHook, {
|
|
182
|
+
hookKey: "entity:listing:main:top",
|
|
183
|
+
schema: entitySchema,
|
|
184
|
+
listFilters: listFilters,
|
|
185
|
+
setListFilters: updateListingFilters
|
|
186
|
+
}), /*#__PURE__*/React.createElement(SearchFilter, {
|
|
187
|
+
schema: entitySchema,
|
|
188
|
+
listFilters: listFilters,
|
|
189
|
+
setListFilters: updateListingFilters
|
|
190
|
+
}), /*#__PURE__*/React.createElement(ListingTableContent, {
|
|
191
|
+
totalItems: totalItems,
|
|
192
|
+
currentPage: currentPage,
|
|
193
|
+
onSort: handleSort,
|
|
194
|
+
handleOnPageChange: handleOnPageChange,
|
|
195
|
+
tableData: tableData,
|
|
196
|
+
onCloseCardPrompt: onCloseCardPrompt,
|
|
197
|
+
schema: entitySchema,
|
|
198
|
+
listFilters: listFilters,
|
|
199
|
+
setListFilters: updateListingFilters
|
|
200
|
+
})));
|
|
201
|
+
};
|
|
202
|
+
ListingTable.propTypes = {
|
|
203
|
+
entitySchema: PropTypes.object.isRequired,
|
|
204
|
+
match: PropTypes.object.isRequired,
|
|
205
|
+
history: PropTypes.object.isRequired
|
|
206
|
+
};
|
|
207
|
+
export default withRouter(ListingTable);
|
|
208
|
+
//# sourceMappingURL=ListingTable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListingTable.js","names":["React","useEffect","useState","Fragment","PropTypes","useApolloClient","withRouter","Link","useLocation","PageHeader","DeleteAction","CardPrompt","useToasts","RenderHook","ListingTableContent","SearchFilter","availableActions","fetchData","populateRows","formatRows","getParsedRowData","getDefaultQueryParams","ListingTable","match","entitySchema","history","tableData","setTableData","modalStatus","setModalStatus","itemToDelete","setItemToDelete","previousSchema","setPreviousSchema","id","totalItems","setTotalItems","queryParamsDefault","queryParams","setQueryParams","listFilters","setListFilters","client","addToast","location","searchParams","URLSearchParams","search","currentPage","Number","get","updatedQueryParams","_objectSpread","offset","limit","doQuery","url","filters","params","listingData","totalRecords","querySettings","populatedTable","toggleModal","rows","handleOnPageChange","pageNumber","_offset","push","document","getElementsByClassName","scrollTo","updateListingFilters","onCloseCardPrompt","item","deleteAction","delete","submit","parsedFormValues","updatedTableData","filter","handleSort","event","property","direction","Object","entries","sortQueryParams","sort","columns","isEnquiry","firstColumn","appliedSort","displayProperties","adminCrudActions","create","createAction","active","_deleteAction","showAddButton","length","createElement","className","onClose","itemName","name","title","displayName","subtitle","to","hookKey","schema","onSort","propTypes","object","isRequired"],"sources":["../../../src/components/ListingTable/ListingTable.js"],"sourcesContent":["import React, { useEffect, useState, Fragment } from 'react';\nimport PropTypes from 'prop-types';\nimport { useApolloClient } from '@apollo/client';\nimport { withRouter, Link, useLocation } from 'react-router-dom';\nimport { PageHeader, DeleteAction, CardPrompt } from '@blaze-cms/admin';\nimport { useToasts } from '@blaze-react/toaster';\nimport { RenderHook } from '@blaze-cms/plugin-render-hooks-ui';\nimport ListingTableContent from './ListingTableContent';\nimport SearchFilter from './SearchFilter/SearchFilter';\nimport availableActions from '../EntityManager/Entity/actions-handlers';\nimport { fetchData } from './service';\nimport { populateRows, formatRows, getParsedRowData } from './mappers/populate-rows';\nimport { getDefaultQueryParams } from '../../utils/get-default-query-params';\n\nconst ListingTable = ({ match, entitySchema, history }) => {\n const [tableData, setTableData] = useState({});\n const [modalStatus, setModalStatus] = useState(false);\n const [itemToDelete, setItemToDelete] = useState({});\n const [previousSchema, setPreviousSchema] = useState({ id: null });\n const [totalItems, setTotalItems] = useState(0);\n const queryParamsDefault = getDefaultQueryParams(entitySchema);\n const [queryParams, setQueryParams] = useState(queryParamsDefault);\n const [listFilters, setListFilters] = useState([]);\n const client = useApolloClient();\n const { addToast } = useToasts();\n const location = useLocation();\n const searchParams = new URLSearchParams(location.search);\n const currentPage = Number(searchParams.get('page')) || 1;\n\n useEffect(\n () => {\n (async () => {\n if (\n entitySchema.id !== previousSchema.id ||\n (previousSchema.id === null && entitySchema.id)\n ) {\n const updatedQueryParams = {\n ...queryParams,\n offset: currentPage * queryParamsDefault.limit - queryParamsDefault.limit\n };\n await doQuery([], updatedQueryParams);\n setPreviousSchema({ id: entitySchema.id });\n }\n })();\n },\n [client, entitySchema, match.url, previousSchema.id, queryParams] // eslint-disable-line react-hooks/exhaustive-deps\n );\n\n const doQuery = async (filters = listFilters, params = queryParamsDefault) => {\n const { listingData, totalRecords } = await fetchData({\n client,\n querySettings: {\n entitySchema,\n queryParams: params\n },\n listFilters: filters\n });\n\n const populatedTable = populateRows({\n toggleModal,\n url: match.url,\n entitySchema,\n rows: listingData\n });\n\n setTableData(populatedTable);\n setTotalItems(totalRecords);\n };\n\n const handleOnPageChange = async ({ pageNumber, offset: _offset }) => {\n const updatedQueryParams = {\n ...queryParams,\n offset: _offset\n };\n\n await doQuery(listFilters, updatedQueryParams);\n\n history.push(`?page=${pageNumber}`);\n document.getElementsByClassName('page')[0].scrollTo(0, 0);\n };\n\n const updateListingFilters = async filters => {\n await doQuery(filters);\n setListFilters(filters);\n };\n\n const onCloseCardPrompt = () => null;\n\n const toggleModal = item => {\n setModalStatus(!!item);\n setItemToDelete(item || {});\n };\n\n const deleteAction = async () => {\n await availableActions.delete.submit(\n {\n entitySchema,\n parsedFormValues: { id: itemToDelete.id },\n client\n },\n addToast\n );\n\n toggleModal();\n\n const updatedTableData = {\n ...tableData,\n rows: tableData.rows.filter(({ id }) => id !== itemToDelete.id)\n };\n\n setTableData(updatedTableData);\n };\n\n const handleSort = async event => {\n const [[property, direction]] = Object.entries(event);\n const sortQueryParams = {\n ...queryParamsDefault,\n sort: [{ property, direction }]\n };\n setQueryParams(sortQueryParams);\n\n const { listingData } = await fetchData({\n client,\n querySettings: {\n entitySchema,\n queryParams: sortQueryParams\n },\n listFilters\n });\n const { columns, isEnquiry } = tableData;\n const [firstColumn] = columns;\n\n setTableData({\n ...tableData,\n appliedSort: { [property]: direction },\n rows: formatRows({\n rows: getParsedRowData(listingData),\n url: match.url,\n toggleModal,\n firstColumn,\n isEnquiry,\n entitySchema\n })\n });\n history.push('?page=1');\n };\n if (!tableData || !tableData.rows) return 'loading';\n\n const {\n displayProperties: {\n adminCrudActions: {\n create: createAction = { active: true },\n delete: _deleteAction = { active: true }\n } = {}\n } = {}\n } = entitySchema;\n\n const showAddButton = !tableData.rows.length && listFilters.length === 0;\n\n return (\n <div className=\"page\">\n {modalStatus && _deleteAction.active && (\n <DeleteAction\n data-testid=\"deleteEntity\"\n onClose={toggleModal}\n deleteAction={deleteAction}\n itemName={itemToDelete.name}\n />\n )}\n <PageHeader title={entitySchema.displayName} subtitle=\"\">\n {createAction.active && !showAddButton && (\n <Link data-testid=\"addEntity\" className=\"button button--small\" to={`${match.url}/create`}>\n Add\n </Link>\n )}\n </PageHeader>\n {showAddButton ? (\n <CardPrompt>\n <Link\n className=\"button button--rounded button--cta\"\n to={`${match.url}/create`}\n data-testid=\"add-button\">\n Add\n </Link>\n </CardPrompt>\n ) : (\n <>\n <RenderHook\n hookKey=\"entity:listing:main:top\"\n schema={entitySchema}\n listFilters={listFilters}\n setListFilters={updateListingFilters}\n />\n <SearchFilter\n schema={entitySchema}\n listFilters={listFilters}\n setListFilters={updateListingFilters}\n />\n <ListingTableContent\n totalItems={totalItems}\n currentPage={currentPage}\n onSort={handleSort}\n handleOnPageChange={handleOnPageChange}\n tableData={tableData}\n onCloseCardPrompt={onCloseCardPrompt}\n schema={entitySchema}\n listFilters={listFilters}\n setListFilters={updateListingFilters}\n />\n </>\n )}\n </div>\n );\n};\nListingTable.propTypes = {\n entitySchema: PropTypes.object.isRequired,\n match: PropTypes.object.isRequired,\n history: PropTypes.object.isRequired\n};\n\nexport default withRouter(ListingTable);\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,OAAO;AAC5D,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,eAAe,QAAQ,gBAAgB;AAChD,SAASC,UAAU,EAAEC,IAAI,EAAEC,WAAW,QAAQ,kBAAkB;AAChE,SAASC,UAAU,EAAEC,YAAY,EAAEC,UAAU,QAAQ,kBAAkB;AACvE,SAASC,SAAS,QAAQ,sBAAsB;AAChD,SAASC,UAAU,QAAQ,mCAAmC;AAC9D,OAAOC,mBAAmB,MAAM,uBAAuB;AACvD,OAAOC,YAAY,MAAM,6BAA6B;AACtD,OAAOC,gBAAgB,MAAM,0CAA0C;AACvE,SAASC,SAAS,QAAQ,WAAW;AACrC,SAASC,YAAY,EAAEC,UAAU,EAAEC,gBAAgB,QAAQ,yBAAyB;AACpF,SAASC,qBAAqB,QAAQ,sCAAsC;AAE5E,MAAMC,YAAY,GAAGA,CAAC;EAAEC,KAAK;EAAEC,YAAY;EAAEC;AAAQ,CAAC,KAAK;EACzD,MAAM,CAACC,SAAS,EAAEC,YAAY,CAAC,GAAGzB,QAAQ,CAAC,CAAC,CAAC,CAAC;EAC9C,MAAM,CAAC0B,WAAW,EAAEC,cAAc,CAAC,GAAG3B,QAAQ,CAAC,KAAK,CAAC;EACrD,MAAM,CAAC4B,YAAY,EAAEC,eAAe,CAAC,GAAG7B,QAAQ,CAAC,CAAC,CAAC,CAAC;EACpD,MAAM,CAAC8B,cAAc,EAAEC,iBAAiB,CAAC,GAAG/B,QAAQ,CAAC;IAAEgC,EAAE,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@@ -0,0 +1,72 @@
|
|
|
1
|
+
import React, { useEffect, useRef } from 'react';
|
|
2
|
+
import Table from '@blaze-react/table';
|
|
3
|
+
import Pagination from '@blaze-react/pagination';
|
|
4
|
+
import PropTypes from 'prop-types';
|
|
5
|
+
import { withRouter } from 'react-router-dom';
|
|
6
|
+
const ListingTableContent = ({
|
|
7
|
+
tableData,
|
|
8
|
+
handleSelect,
|
|
9
|
+
onSort,
|
|
10
|
+
handleOnPageChange,
|
|
11
|
+
currentPage,
|
|
12
|
+
totalItems
|
|
13
|
+
}) => {
|
|
14
|
+
const ref = useRef(null);
|
|
15
|
+
const displayTable = tableData && tableData.rows && !!tableData.rows.length;
|
|
16
|
+
const {
|
|
17
|
+
isEnquiry
|
|
18
|
+
} = tableData;
|
|
19
|
+
const className = `page__content${isEnquiry ? ' array-table' : ''}`;
|
|
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('.table-body .table-row:first-child .table-cell');
|
|
25
|
+
firstRowCells.forEach((element, i) => {
|
|
26
|
+
const styles = window.getComputedStyle(element);
|
|
27
|
+
if (tableHeadCells[i]) {
|
|
28
|
+
tableHeadCells[i].style.flex = styles.flex;
|
|
29
|
+
tableHeadCells[i].style['justify-content'] = styles['justify-content'];
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}, [tableData, displayTable]);
|
|
34
|
+
if (displayTable) {
|
|
35
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
ref: ref,
|
|
37
|
+
className: className
|
|
38
|
+
}, /*#__PURE__*/React.createElement(Table, {
|
|
39
|
+
onSort: onSort,
|
|
40
|
+
data: tableData,
|
|
41
|
+
onSelect: handleSelect,
|
|
42
|
+
"data-testid": "listing-table-content"
|
|
43
|
+
}), /*#__PURE__*/React.createElement(Pagination, {
|
|
44
|
+
visiblePages: 10,
|
|
45
|
+
totalItems: totalItems,
|
|
46
|
+
currentPage: currentPage,
|
|
47
|
+
onPageChange: handleOnPageChange
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
return /*#__PURE__*/React.createElement("span", {
|
|
51
|
+
className: "table-no-results",
|
|
52
|
+
"data-testid": "no-results"
|
|
53
|
+
}, "No results");
|
|
54
|
+
};
|
|
55
|
+
ListingTableContent.propTypes = {
|
|
56
|
+
tableData: PropTypes.object.isRequired,
|
|
57
|
+
match: PropTypes.shape({
|
|
58
|
+
url: PropTypes.string
|
|
59
|
+
}).isRequired,
|
|
60
|
+
handleSelect: PropTypes.func,
|
|
61
|
+
onSort: PropTypes.func,
|
|
62
|
+
handleOnPageChange: PropTypes.func,
|
|
63
|
+
currentPage: PropTypes.number.isRequired,
|
|
64
|
+
totalItems: PropTypes.number.isRequired
|
|
65
|
+
};
|
|
66
|
+
ListingTableContent.defaultProps = {
|
|
67
|
+
handleSelect: () => {},
|
|
68
|
+
onSort: () => {},
|
|
69
|
+
handleOnPageChange: () => {}
|
|
70
|
+
};
|
|
71
|
+
export default withRouter(ListingTableContent);
|
|
72
|
+
//# sourceMappingURL=ListingTableContent.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ListingTableContent.js","names":["React","useEffect","useRef","Table","Pagination","PropTypes","withRouter","ListingTableContent","tableData","handleSelect","onSort","handleOnPageChange","currentPage","totalItems","ref","displayTable","rows","length","isEnquiry","className","current","tableHeadCells","querySelectorAll","firstRowCells","forEach","element","i","styles","window","getComputedStyle","style","flex","createElement","data","onSelect","visiblePages","onPageChange","propTypes","object","isRequired","match","shape","url","string","func","number","defaultProps"],"sources":["../../../../src/components/ListingTable/ListingTableContent/ListingTableContent.js"],"sourcesContent":["import React, { useEffect, useRef } from 'react';\nimport Table from '@blaze-react/table';\nimport Pagination from '@blaze-react/pagination';\nimport PropTypes from 'prop-types';\nimport { withRouter } from 'react-router-dom';\n\nconst ListingTableContent = ({\n tableData,\n handleSelect,\n onSort,\n handleOnPageChange,\n currentPage,\n totalItems\n}) => {\n const ref = useRef(null);\n const displayTable = tableData && tableData.rows && !!tableData.rows.length;\n const { isEnquiry } = tableData;\n const className = `page__content${isEnquiry ? ' array-table' : ''}`;\n\n useEffect(() => {\n // set table head to match body column widths to handle dynamic content\n if (ref.current && displayTable) {\n const tableHeadCells = ref.current.querySelectorAll('.table-head .table-cell');\n const firstRowCells = ref.current.querySelectorAll(\n '.table-body .table-row:first-child .table-cell'\n );\n\n firstRowCells.forEach((element, i) => {\n const styles = window.getComputedStyle(element);\n\n if (tableHeadCells[i]) {\n tableHeadCells[i].style.flex = styles.flex;\n tableHeadCells[i].style['justify-content'] = styles['justify-content'];\n }\n });\n }\n }, [tableData, displayTable]);\n\n if (displayTable) {\n return (\n <div ref={ref} className={className}>\n <Table\n onSort={onSort}\n data={tableData}\n onSelect={handleSelect}\n data-testid=\"listing-table-content\"\n />\n <Pagination\n visiblePages={10}\n totalItems={totalItems}\n currentPage={currentPage}\n onPageChange={handleOnPageChange}\n />\n </div>\n );\n }\n\n return (\n <span className=\"table-no-results\" data-testid=\"no-results\">\n No results\n </span>\n );\n};\n\nListingTableContent.propTypes = {\n tableData: PropTypes.object.isRequired,\n match: PropTypes.shape({\n url: PropTypes.string\n }).isRequired,\n handleSelect: PropTypes.func,\n onSort: PropTypes.func,\n handleOnPageChange: PropTypes.func,\n currentPage: PropTypes.number.isRequired,\n totalItems: PropTypes.number.isRequired\n};\n\nListingTableContent.defaultProps = {\n handleSelect: () => { },\n onSort: () => { },\n handleOnPageChange: () => { }\n};\n\nexport default withRouter(ListingTableContent);\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,MAAM,QAAQ,OAAO;AAChD,OAAOC,KAAK,MAAM,oBAAoB;AACtC,OAAOC,UAAU,MAAM,yBAAyB;AAChD,OAAOC,SAAS,MAAM,YAAY;AA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CnB,KAAA,CAAAgC,aAAA,CAAC7B,KAAK;MACJO,MAAM,EAAEA,MAAO;MACfuB,IAAI,EAAEzB,SAAU;MAChB0B,QAAQ,EAAEzB,YAAa;MACvB,eAAY;IAAuB,CACpC,CAAC,eACFT,KAAA,CAAAgC,aAAA,CAAC5B,UAAU;MACT+B,YAAY,EAAE,EAAG;MACjBtB,UAAU,EAAEA,UAAW;MACvBD,WAAW,EAAEA,WAAY;MACzBwB,YAAY,EAAEzB;IAAmB,CAClC,CACE,CAAC;EAEV;EAEA,oBACEX,KAAA,CAAAgC,aAAA;IAAMb,SAAS,EAAC,kBAAkB;IAAC,eAAY;EAAY,GAAC,YAEtD,CAAC;AAEX,CAAC;AAEDZ,mBAAmB,CAAC8B,SAAS,GAAG;EAC9B7B,SAAS,EAAEH,SAAS,CAACiC,MAAM,CAACC,UAAU;EACtCC,KAAK,EAAEnC,SAAS,CAACoC,KAAK,CAAC;IACrBC,GAAG,EAAErC,SAAS,CAACsC;EACjB,CAAC,CAAC,CAACJ,UAAU;EACb9B,YAAY,EAAEJ,SAAS,CAACuC,IAAI;EAC5BlC,MAAM,EAAEL,SAAS,CAACuC,IAAI;EACtBjC,kBAAkB,EAAEN,SAAS,CAACuC,IAAI;EAClChC,WAAW,EAAEP,SAAS,CAACwC,MAAM,CAACN,UAAU;EACxC1B,UAAU,EAAER,SAAS,CAACwC,MAAM,CAACN;AAC/B,CAAC;AAEDhC,mBAAmB,CAACuC,YAAY,GAAG;EACjCrC,YAAY,EAAEA,CAAA,KAAM,CAAE,CAAC;EACvBC,MAAM,EAAEA,CAAA,KAAM,CAAE,CAAC;EACjBC,kBAAkB,EAAEA,CAAA,KAAM,CAAE;AAC9B,CAAC;AAED,eAAeL,UAAU,CAACC,mBAAmB,CAAC","ignoreList":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":["ListingTableContent"],"sources":["../../../../src/components/ListingTable/ListingTableContent/index.js"],"sourcesContent":["import ListingTableContent from './ListingTableContent';\n\nexport default ListingTableContent;\n"],"mappings":"AAAA,OAAOA,mBAAmB,MAAM,uBAAuB;AAEvD,eAAeA,mBAAmB","ignoreList":[]}
|