@blaze-cms/plugin-data-ui 0.131.0-admin-updates.2 → 0.131.0-project-admin-customisations.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.
Files changed (108) hide show
  1. package/CHANGELOG.md +13 -5
  2. package/README.md +42 -0
  3. package/lib/components/EntityDataListing/EntityDataListing.js +3 -24
  4. package/lib/components/EntityDataListing/EntityDataListing.js.map +1 -1
  5. package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +39 -0
  6. package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js.map +1 -0
  7. package/lib/components/EntityManager/Entity/EntitiyNavLinks/index.js +12 -0
  8. package/lib/components/EntityManager/Entity/EntitiyNavLinks/index.js.map +1 -0
  9. package/lib/components/EntityManager/Entity/Entity.js +15 -2
  10. package/lib/components/EntityManager/Entity/Entity.js.map +1 -1
  11. package/lib/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +44 -0
  12. package/lib/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js.map +1 -0
  13. package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +32 -0
  14. package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +1 -0
  15. package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +45 -0
  16. package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +1 -0
  17. package/lib/components/EntityManager/Entity/SideBarRelations/index.js +12 -2
  18. package/lib/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
  19. package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +38 -0
  20. package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +1 -0
  21. package/lib/components/InfoBoxes/InfoBoxes.js +36 -0
  22. package/lib/components/InfoBoxes/InfoBoxes.js.map +1 -0
  23. package/lib/components/InfoBoxes/container/InfoBoxContainer.js +44 -0
  24. package/lib/components/InfoBoxes/container/InfoBoxContainer.js.map +1 -0
  25. package/lib/components/InfoBoxes/helpers/build-dynamic-query.js +25 -0
  26. package/lib/components/InfoBoxes/helpers/build-dynamic-query.js.map +1 -0
  27. package/lib/components/InfoBoxes/hooks/useData.js +42 -0
  28. package/lib/components/InfoBoxes/hooks/useData.js.map +1 -0
  29. package/lib/components/InfoBoxes/hooks/useInfoBox.js +26 -0
  30. package/lib/components/InfoBoxes/hooks/useInfoBox.js.map +1 -0
  31. package/lib/components/InfoBoxes/index.js +12 -0
  32. package/lib/components/InfoBoxes/index.js.map +1 -0
  33. package/lib/components/InfoBoxes/presentational/InfoBox.js +46 -0
  34. package/lib/components/InfoBoxes/presentational/InfoBox.js.map +1 -0
  35. package/lib/components/ListingTable/ListingTable.js +19 -33
  36. package/lib/components/ListingTable/ListingTable.js.map +1 -1
  37. package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js +9 -14
  38. package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
  39. package/lib/components/ListingTable/mappers/populate-rows.js +92 -26
  40. package/lib/components/ListingTable/mappers/populate-rows.js.map +1 -1
  41. package/lib/index.js +3 -11
  42. package/lib/index.js.map +1 -1
  43. package/lib/utils/add-content-menu-items.js +64 -13
  44. package/lib/utils/add-content-menu-items.js.map +1 -1
  45. package/lib-es/components/EntityDataListing/EntityDataListing.js +3 -14
  46. package/lib-es/components/EntityDataListing/EntityDataListing.js.map +1 -1
  47. package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +30 -0
  48. package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js.map +1 -0
  49. package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/index.js +3 -0
  50. package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/index.js.map +1 -0
  51. package/lib-es/components/EntityManager/Entity/Entity.js +15 -2
  52. package/lib-es/components/EntityManager/Entity/Entity.js.map +1 -1
  53. package/lib-es/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +30 -0
  54. package/lib-es/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js.map +1 -0
  55. package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +26 -0
  56. package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +1 -0
  57. package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +39 -0
  58. package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +1 -0
  59. package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js +12 -2
  60. package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
  61. package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +24 -0
  62. package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +1 -0
  63. package/lib-es/components/InfoBoxes/InfoBoxes.js +28 -0
  64. package/lib-es/components/InfoBoxes/InfoBoxes.js.map +1 -0
  65. package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js +30 -0
  66. package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js.map +1 -0
  67. package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js +25 -0
  68. package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js.map +1 -0
  69. package/lib-es/components/InfoBoxes/hooks/useData.js +37 -0
  70. package/lib-es/components/InfoBoxes/hooks/useData.js.map +1 -0
  71. package/lib-es/components/InfoBoxes/hooks/useInfoBox.js +19 -0
  72. package/lib-es/components/InfoBoxes/hooks/useInfoBox.js.map +1 -0
  73. package/lib-es/components/InfoBoxes/index.js +3 -0
  74. package/lib-es/components/InfoBoxes/index.js.map +1 -0
  75. package/lib-es/components/InfoBoxes/presentational/InfoBox.js +31 -0
  76. package/lib-es/components/InfoBoxes/presentational/InfoBox.js.map +1 -0
  77. package/lib-es/components/ListingTable/ListingTable.js +19 -32
  78. package/lib-es/components/ListingTable/ListingTable.js.map +1 -1
  79. package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js +12 -15
  80. package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
  81. package/lib-es/components/ListingTable/mappers/populate-rows.js +76 -24
  82. package/lib-es/components/ListingTable/mappers/populate-rows.js.map +1 -1
  83. package/lib-es/index.js +1 -9
  84. package/lib-es/index.js.map +1 -1
  85. package/lib-es/utils/add-content-menu-items.js +49 -5
  86. package/lib-es/utils/add-content-menu-items.js.map +1 -1
  87. package/package.json +10 -9
  88. package/src/components/EntityDataListing/EntityDataListing.js +3 -12
  89. package/src/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +26 -0
  90. package/src/components/EntityManager/Entity/EntitiyNavLinks/index.js +3 -0
  91. package/src/components/EntityManager/Entity/Entity.js +9 -0
  92. package/src/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +22 -0
  93. package/src/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +33 -0
  94. package/src/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +28 -0
  95. package/src/components/EntityManager/Entity/SideBarRelations/index.js +34 -16
  96. package/src/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +33 -0
  97. package/src/components/InfoBoxes/InfoBoxes.js +24 -0
  98. package/src/components/InfoBoxes/container/InfoBoxContainer.js +22 -0
  99. package/src/components/InfoBoxes/helpers/build-dynamic-query.js +25 -0
  100. package/src/components/InfoBoxes/hooks/useData.js +20 -0
  101. package/src/components/InfoBoxes/hooks/useInfoBox.js +13 -0
  102. package/src/components/InfoBoxes/index.js +3 -0
  103. package/src/components/InfoBoxes/presentational/InfoBox.js +34 -0
  104. package/src/components/ListingTable/ListingTable.js +23 -22
  105. package/src/components/ListingTable/ListingTableContent/ListingTableContent.js +9 -18
  106. package/src/components/ListingTable/mappers/populate-rows.js +83 -18
  107. package/src/index.js +1 -8
  108. package/src/utils/add-content-menu-items.js +45 -3
@@ -1 +1 @@
1
- {"version":3,"file":"ListingTableContent.js","names":["React","Table","PropTypes","CardPrompt","Link","withRouter","ListingTableContent","tableData","handleSelect","onCloseCardPrompt","selectedMenuItem","match","onSort","onClickRow","overScanBuffer","onRenderItems","scrollToIndex","displayTable","rows","length","createElement","Fragment","className","data","checkboxes","onSelect","isDisplayedPrompt","onClose","to","url","propTypes","object","isRequired","func","shape","string","number","defaultProps"],"sources":["../../../../src/components/ListingTable/ListingTableContent/ListingTableContent.js"],"sourcesContent":["import React from 'react';\nimport Table from '@blaze-react/table';\nimport PropTypes from 'prop-types';\nimport { CardPrompt } from '@blaze-cms/admin';\nimport { Link, withRouter } from 'react-router-dom';\n\nconst ListingTableContent = ({\n tableData,\n handleSelect,\n onCloseCardPrompt,\n selectedMenuItem,\n match,\n onSort,\n onClickRow,\n overScanBuffer,\n onRenderItems,\n scrollToIndex\n}) => {\n const displayTable = tableData && tableData.rows && !!tableData.rows.length;\n\n return (\n <>\n {displayTable ? (\n <>\n <div className=\"page__content\">\n <Table\n scrollToIndex={scrollToIndex}\n onSort={onSort}\n onClickRow={onClickRow}\n overScanBuffer={overScanBuffer}\n onRenderItems={onRenderItems}\n data={tableData}\n checkboxes\n onSelect={handleSelect}\n data-testid=\"listing-table-content\"\n />\n </div>\n </>\n ) : (\n selectedMenuItem.isDisplayedPrompt && (\n <CardPrompt onClose={onCloseCardPrompt} data-testid=\"card-prompt\">\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 </>\n );\n};\n\nListingTableContent.propTypes = {\n tableData: PropTypes.object.isRequired,\n onCloseCardPrompt: PropTypes.func.isRequired,\n selectedMenuItem: PropTypes.object.isRequired,\n match: PropTypes.shape({\n url: PropTypes.string\n }).isRequired,\n handleSelect: PropTypes.func,\n onSort: PropTypes.func,\n onClickRow: PropTypes.func,\n overScanBuffer: PropTypes.number,\n scrollToIndex: PropTypes.number,\n onRenderItems: PropTypes.func\n};\n\nListingTableContent.defaultProps = {\n handleSelect: () => {},\n onSort: () => {},\n onClickRow: () => {},\n overScanBuffer: 0,\n scrollToIndex: 0,\n onRenderItems: () => {}\n};\n\nexport default withRouter(ListingTableContent);\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,KAAK,MAAM,oBAAoB;AACtC,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,IAAI,EAAEC,UAAU,QAAQ,kBAAkB;AAEnD,MAAMC,mBAAmB,GAAGA,CAAC;EAC3BC,SAAS;EACTC,YAAY;EACZC,iBAAiB;EACjBC,gBAAgB;EAChBC,KAAK;EACLC,MAAM;EACNC,UAAU;EACVC,cAAc;EACdC,aAAa;EACbC;AACF,CAAC,KAAK;EACJ,MAAMC,YAAY,GAAGV,SAAS,IAAIA,SAAS,CAACW,IAAI,IAAI,CAAC,CAACX,SAAS,CAACW,IAAI,CAACC,MAAM;EAE3E,oBACEnB,KAAA,CAAAoB,aAAA,CAAApB,KAAA,CAAAqB,QAAA,QACGJ,YAAY,gBACXjB,KAAA,CAAAoB,aAAA,CAAApB,KAAA,CAAAqB,QAAA,qBACErB,KAAA,CAAAoB,aAAA;IAAKE,SAAS,EAAC;EAAe,gBAC5BtB,KAAA,CAAAoB,aAAA,CAACnB,KAAK;IACJe,aAAa,EAAEA,aAAc;IAC7BJ,MAAM,EAAEA,MAAO;IACfC,UAAU,EAAEA,UAAW;IACvBC,cAAc,EAAEA,cAAe;IAC/BC,aAAa,EAAEA,aAAc;IAC7BQ,IAAI,EAAEhB,SAAU;IAChBiB,UAAU;IACVC,QAAQ,EAAEjB,YAAa;IACvB,eAAY;EAAuB,CACpC,CACE,CACL,CAAC,GAEHE,gBAAgB,CAACgB,iBAAiB,iBAChC1B,KAAA,CAAAoB,aAAA,CAACjB,UAAU;IAACwB,OAAO,EAAElB,iBAAkB;IAAC,eAAY;EAAa,gBAC/DT,KAAA,CAAAoB,aAAA,CAAChB,IAAI;IACHkB,SAAS,EAAC,oCAAoC;IAC9CM,EAAE,EAAG,GAAEjB,KAAK,CAACkB,GAAI,SAAS;IAC1B,eAAY;EAAY,GAAC,KAErB,CACI,CAGhB,CAAC;AAEP,CAAC;AAEDvB,mBAAmB,CAACwB,SAAS,GAAG;EAC9BvB,SAAS,EAAEL,SAAS,CAAC6B,MAAM,CAACC,UAAU;EACtCvB,iBAAiB,EAAEP,SAAS,CAAC+B,IAAI,CAACD,UAAU;EAC5CtB,gBAAgB,EAAER,SAAS,CAAC6B,MAAM,CAACC,UAAU;EAC7CrB,KAAK,EAAET,SAAS,CAACgC,KAAK,CAAC;IACrBL,GAAG,EAAE3B,SAAS,CAACiC;EACjB,CAAC,CAAC,CAACH,UAAU;EACbxB,YAAY,EAAEN,SAAS,CAAC+B,IAAI;EAC5BrB,MAAM,EAAEV,SAAS,CAAC+B,IAAI;EACtBpB,UAAU,EAAEX,SAAS,CAAC+B,IAAI;EAC1BnB,cAAc,EAAEZ,SAAS,CAACkC,MAAM;EAChCpB,aAAa,EAAEd,SAAS,CAACkC,MAAM;EAC/BrB,aAAa,EAAEb,SAAS,CAAC+B;AAC3B,CAAC;AAED3B,mBAAmB,CAAC+B,YAAY,GAAG;EACjC7B,YAAY,EAAEA,CAAA,KAAM,CAAC,CAAC;EACtBI,MAAM,EAAEA,CAAA,KAAM,CAAC,CAAC;EAChBC,UAAU,EAAEA,CAAA,KAAM,CAAC,CAAC;EACpBC,cAAc,EAAE,CAAC;EACjBE,aAAa,EAAE,CAAC;EAChBD,aAAa,EAAEA,CAAA,KAAM,CAAC;AACxB,CAAC;AAED,eAAeV,UAAU,CAACC,mBAAmB,CAAC"}
1
+ {"version":3,"file":"ListingTableContent.js","names":["React","Table","PropTypes","withRouter","ListingTableContent","tableData","handleSelect","onCloseCardPrompt","selectedMenuItem","match","onSort","onClickRow","overScanBuffer","onRenderItems","scrollToIndex","displayTable","rows","length","isEnquiry","className","createElement","Fragment","data","checkboxes","onSelect","propTypes","object","isRequired","func","shape","url","string","number","defaultProps"],"sources":["../../../../src/components/ListingTable/ListingTableContent/ListingTableContent.js"],"sourcesContent":["import React from 'react';\nimport Table from '@blaze-react/table';\nimport PropTypes from 'prop-types';\nimport { withRouter } from 'react-router-dom';\n\nconst ListingTableContent = ({\n tableData,\n handleSelect,\n onCloseCardPrompt,\n selectedMenuItem,\n match,\n onSort,\n onClickRow,\n overScanBuffer,\n onRenderItems,\n scrollToIndex\n}) => {\n const displayTable = tableData && tableData.rows && !!tableData.rows.length;\n const { isEnquiry } = tableData;\n const className = `page__content${isEnquiry ? ' array-table' : ''}`;\n\n return (\n <>\n {displayTable && (\n <>\n <div className={className}>\n <Table\n scrollToIndex={scrollToIndex}\n onSort={onSort}\n onClickRow={onClickRow}\n overScanBuffer={overScanBuffer}\n onRenderItems={onRenderItems}\n data={tableData}\n checkboxes={!isEnquiry}\n onSelect={handleSelect}\n data-testid=\"listing-table-content\"\n />\n </div>\n </>\n )}\n </>\n );\n};\n\nListingTableContent.propTypes = {\n tableData: PropTypes.object.isRequired,\n onCloseCardPrompt: PropTypes.func.isRequired,\n selectedMenuItem: PropTypes.object,\n match: PropTypes.shape({\n url: PropTypes.string\n }).isRequired,\n handleSelect: PropTypes.func,\n onSort: PropTypes.func,\n onClickRow: PropTypes.func,\n overScanBuffer: PropTypes.number,\n scrollToIndex: PropTypes.number,\n onRenderItems: PropTypes.func\n};\n\nListingTableContent.defaultProps = {\n handleSelect: () => {},\n onSort: () => {},\n onClickRow: () => {},\n overScanBuffer: 0,\n scrollToIndex: 0,\n onRenderItems: () => {},\n selectedMenuItem: null\n};\n\nexport default withRouter(ListingTableContent);\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,KAAK,MAAM,oBAAoB;AACtC,OA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CAAC6B;EACjB,CAAC,CAAC,CAACJ,UAAU;EACbrB,YAAY,EAAEJ,SAAS,CAAC0B,IAAI;EAC5BlB,MAAM,EAAER,SAAS,CAAC0B,IAAI;EACtBjB,UAAU,EAAET,SAAS,CAAC0B,IAAI;EAC1BhB,cAAc,EAAEV,SAAS,CAAC8B,MAAM;EAChClB,aAAa,EAAEZ,SAAS,CAAC8B,MAAM;EAC/BnB,aAAa,EAAEX,SAAS,CAAC0B;AAC3B,CAAC;AAEDxB,mBAAmB,CAAC6B,YAAY,GAAG;EACjC3B,YAAY,EAAEA,CAAA,KAAM,CAAC,CAAC;EACtBI,MAAM,EAAEA,CAAA,KAAM,CAAC,CAAC;EAChBC,UAAU,EAAEA,CAAA,KAAM,CAAC,CAAC;EACpBC,cAAc,EAAE,CAAC;EACjBE,aAAa,EAAE,CAAC;EAChBD,aAAa,EAAEA,CAAA,KAAM,CAAC,CAAC;EACvBL,gBAAgB,EAAE;AACpB,CAAC;AAED,eAAeL,UAAU,CAACC,mBAAmB,CAAC"}
@@ -10,20 +10,22 @@ const formatRows = ({
10
10
  url,
11
11
  toggleModal,
12
12
  label,
13
- firstColumn = 'name'
13
+ firstColumn = 'name',
14
+ isEnquiry
14
15
  }) => rows.map(data => {
15
16
  const editUrl = `${url}/update/${data.id}`;
16
- return _objectSpread(_objectSpread({}, data), {}, {
17
+ const rowProps = _objectSpread(_objectSpread({}, data), {}, {
17
18
  [firstColumn]: /*#__PURE__*/React.createElement(Link, {
18
19
  to: editUrl,
19
20
  role: "button"
20
- }, data[firstColumn]),
21
- actions: /*#__PURE__*/React.createElement(TableActions, {
22
- editUrl: editUrl,
23
- data: data,
24
- showDeleteModal: toggleModal
25
- })
21
+ }, data[firstColumn])
26
22
  });
23
+ if (!isEnquiry) rowProps.actions = /*#__PURE__*/React.createElement(TableActions, {
24
+ editUrl: editUrl,
25
+ data: data,
26
+ showDeleteModal: toggleModal
27
+ });
28
+ return rowProps;
27
29
  });
28
30
  const getSanitizedColumnLabel = columnProp => {
29
31
  let sanitizedChar = '';
@@ -32,14 +34,57 @@ const getSanitizedColumnLabel = columnProp => {
32
34
  }
33
35
  return sanitizedChar;
34
36
  };
35
- const getColumnLabels = (listingProperties, properties, dynamicProperties) => {
36
- const allProperties = _objectSpread(_objectSpread({}, properties), dynamicProperties);
37
- return listingProperties.reduce((acc, listingProperty) => {
38
- const label = allProperties[listingProperty].label || getSanitizedColumnLabel(listingProperty);
39
- return _objectSpread(_objectSpread({}, acc), {
40
- [listingProperty]: label
41
- });
42
- }, {});
37
+ const buildArrayRowContent = rowData => /*#__PURE__*/React.createElement("div", {
38
+ className: "table-row-list"
39
+ }, rowData.map(rowGroup => /*#__PURE__*/React.createElement("div", {
40
+ className: "table-row-list__group"
41
+ }, rowGroup.map(({
42
+ label,
43
+ value,
44
+ url
45
+ }) => /*#__PURE__*/React.createElement("div", {
46
+ className: "table-row-list__group__item"
47
+ }, /*#__PURE__*/React.createElement("span", {
48
+ className: "table-row-list__group__item__label"
49
+ }, " ", label, ":"), url ? /*#__PURE__*/React.createElement(Link, {
50
+ to: url,
51
+ role: "button",
52
+ className: "table-row-list__group__item__value"
53
+ }, value) : /*#__PURE__*/React.createElement("span", {
54
+ className: "table-row-list__group__item__value"
55
+ }, " ", value))))));
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
+ return buildArrayRowContent(dataGroups);
64
+ };
65
+ const getParsedRowData = rows => rows.map(rowData => Object.keys(rowData).reduce((acc, key) => {
66
+ const parsedData = Array.isArray(rowData[key]) ? buildArrayRowData(rowData[key]) : rowData[key];
67
+ return _objectSpread(_objectSpread({}, acc), {}, {
68
+ [key]: parsedData
69
+ });
70
+ }, {}));
71
+ const getColumnsAndLabels = (listingProperties, allProperties, rows) => {
72
+ const columns = [];
73
+ const labels = {};
74
+ listingProperties.forEach(listingProperty => {
75
+ const propKey = listingProperty.includes(' ') ? listingProperty.split(' ')[0] : listingProperty;
76
+ const {
77
+ label
78
+ } = allProperties[propKey] || {};
79
+ columns.push(propKey);
80
+ labels[propKey] = label || getSanitizedColumnLabel(propKey);
81
+ });
82
+ const parsedRowData = getParsedRowData(rows);
83
+ return {
84
+ columns,
85
+ labels,
86
+ parsedRowData
87
+ };
43
88
  };
44
89
  const populateRows = ({
45
90
  toggleModal,
@@ -48,16 +93,21 @@ const populateRows = ({
48
93
  rows
49
94
  }) => {
50
95
  const {
96
+ id: schemaId,
51
97
  listingProperties,
52
98
  properties,
53
99
  dynamicProperties = {},
54
100
  formProperties
55
101
  } = entitySchema;
56
- const columns = [...listingProperties, ACTIONS];
102
+ const isEnquiry = schemaId === 'enquiry';
103
+ const columnOptions = !isEnquiry ? [...listingProperties, ACTIONS] : [...listingProperties];
104
+ const allProperties = _objectSpread(_objectSpread({}, properties), dynamicProperties);
105
+ const {
106
+ columns,
107
+ labels,
108
+ parsedRowData
109
+ } = getColumnsAndLabels(columnOptions, allProperties, rows);
57
110
  const [firstColumn] = columns;
58
- const labels = _objectSpread(_objectSpread({}, getColumnLabels(listingProperties, properties, dynamicProperties)), {}, {
59
- [ACTIONS]: ACTIONS
60
- });
61
111
  return {
62
112
  identification: 'id',
63
113
  sort: null,
@@ -66,11 +116,13 @@ const populateRows = ({
66
116
  orderBy: [...formProperties],
67
117
  rows: formatRows({
68
118
  firstColumn,
69
- rows,
119
+ rows: parsedRowData,
70
120
  url,
71
- toggleModal
72
- })
121
+ toggleModal,
122
+ isEnquiry
123
+ }),
124
+ isEnquiry
73
125
  };
74
126
  };
75
- export { populateRows, formatRows };
127
+ export { populateRows, formatRows, getParsedRowData };
76
128
  //# sourceMappingURL=populate-rows.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"populate-rows.js","names":["React","Link","TableActions","ACTIONS","formatRows","rows","url","toggleModal","label","firstColumn","map","data","editUrl","id","_objectSpread","createElement","to","role","actions","showDeleteModal","getSanitizedColumnLabel","columnProp","sanitizedChar","index","length","toUpperCase","toLowerCase","getColumnLabels","listingProperties","properties","dynamicProperties","allProperties","reduce","acc","listingProperty","populateRows","entitySchema","formProperties","columns","labels","identification","sort","orderBy"],"sources":["../../../../src/components/ListingTable/mappers/populate-rows.js"],"sourcesContent":["import React from 'react';\nimport { Link } from 'react-router-dom';\nimport TableActions from '../TableActions';\nimport { ACTIONS } from '../../../constants';\n\nconst formatRows = ({ rows, url, toggleModal, label, firstColumn = 'name' }) =>\n rows.map(data => {\n const editUrl = `${url}/update/${data.id}`;\n return {\n ...data,\n [firstColumn]: (\n <Link to={editUrl} role=\"button\">\n {data[firstColumn]}\n </Link>\n ),\n actions: <TableActions editUrl={editUrl} data={data} showDeleteModal={toggleModal} />\n };\n });\n\nconst getSanitizedColumnLabel = columnProp => {\n let sanitizedChar = '';\n\n for (let index = 0; index < columnProp.length; index += 1) {\n if (index && columnProp[index] === columnProp[index].toUpperCase())\n sanitizedChar = `${sanitizedChar} ${columnProp[index].toLowerCase()}`;\n else sanitizedChar += columnProp[index];\n }\n return sanitizedChar;\n};\n\nconst getColumnLabels = (listingProperties, properties, dynamicProperties) => {\n const allProperties = { ...properties, ...dynamicProperties };\n return listingProperties.reduce((acc, listingProperty) => {\n const label = allProperties[listingProperty].label || getSanitizedColumnLabel(listingProperty);\n return { ...acc, ...{ [listingProperty]: label } };\n }, {});\n};\n\nconst populateRows = ({ toggleModal, url, entitySchema, rows }) => {\n const { listingProperties, properties, dynamicProperties = {}, formProperties } = entitySchema;\n const columns = [...listingProperties, ACTIONS];\n const [firstColumn] = columns;\n const labels = {\n ...getColumnLabels(listingProperties, properties, dynamicProperties),\n [ACTIONS]: ACTIONS\n };\n\n return {\n identification: 'id',\n sort: null,\n columns,\n labels,\n orderBy: [...formProperties],\n rows: formatRows({ firstColumn, rows, url, toggleModal })\n };\n};\n\nexport { populateRows, formatRows };\n"],"mappings":";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ows","rows","url","toggleModal","label","firstColumn","isEnquiry","map","data","editUrl","id","rowProps","_objectSpread","createElement","to","role","actions","showDeleteModal","getSanitizedColumnLabel","columnProp","sanitizedChar","index","length","toUpperCase","toLowerCase","buildArrayRowContent","rowData","className","rowGroup","value","buildArrayRowData","dataGroups","groups","Math","ceil","currentStart","slice","getParsedRowData","Object","keys","reduce","acc","key","parsedData","Array","isArray","getColumnsAndLabels","listingProperties","allProperties","columns","labels","forEach","listingProperty","propKey","includes","split","push","parsedRowData","populateRows","entitySchema","schemaId","properties","dynamicProperties","formProperties","columnOptions","identification","sort","orderBy"],"sources":["../../../../src/components/ListingTable/mappers/populate-rows.js"],"sourcesContent":["import React from 'react';\nimport { Link } from 'react-router-dom';\nimport TableActions from '../TableActions';\nimport { ACTIONS } from '../../../constants';\n\nconst formatRows = ({ rows, url, toggleModal, label, firstColumn = 'name', isEnquiry }) =>\n rows.map(data => {\n const editUrl = `${url}/update/${data.id}`;\n const rowProps = {\n ...data,\n [firstColumn]: (\n <Link to={editUrl} role=\"button\">\n {data[firstColumn]}\n </Link>\n )\n };\n if (!isEnquiry)\n rowProps.actions = (\n <TableActions editUrl={editUrl} data={data} showDeleteModal={toggleModal} />\n );\n return rowProps;\n });\n\nconst getSanitizedColumnLabel = columnProp => {\n let sanitizedChar = '';\n\n for (let index = 0; index < columnProp.length; index += 1) {\n if (index && columnProp[index] === columnProp[index].toUpperCase())\n sanitizedChar = `${sanitizedChar} ${columnProp[index].toLowerCase()}`;\n else sanitizedChar += columnProp[index];\n }\n return sanitizedChar;\n};\n\nconst buildArrayRowContent = rowData => (\n <div className=\"table-row-list\">\n {rowData.map(rowGroup => (\n <div className=\"table-row-list__group\">\n {rowGroup.map(({ label, value, url }) => (\n <div className=\"table-row-list__group__item\">\n <span className=\"table-row-list__group__item__label\"> {label}:</span>\n {url ? (\n <Link to={url} role=\"button\" className=\"table-row-list__group__item__value\">\n {value}\n </Link>\n ) : (\n <span className=\"table-row-list__group__item__value\"> {value}</span>\n )}\n </div>\n ))}\n </div>\n ))}\n </div>\n);\n\nconst buildArrayRowData = rowData => {\n const dataGroups = [];\n const groups = Math.ceil(rowData.length / 3) || 1;\n for (let index = 0; index < groups; index += 1) {\n const currentStart = index * groups;\n dataGroups[index] = rowData.slice(currentStart, currentStart + 3);\n }\n\n return buildArrayRowContent(dataGroups);\n};\n\nconst getParsedRowData = rows =>\n rows.map(rowData =>\n Object.keys(rowData).reduce((acc, key) => {\n const parsedData = Array.isArray(rowData[key])\n ? buildArrayRowData(rowData[key])\n : rowData[key];\n return { ...acc, [key]: parsedData };\n }, {})\n );\n\nconst getColumnsAndLabels = (listingProperties, allProperties, rows) => {\n const columns = [];\n const labels = {};\n\n listingProperties.forEach(listingProperty => {\n const propKey = listingProperty.includes(' ') ? listingProperty.split(' ')[0] : listingProperty;\n const { label } = allProperties[propKey] || {};\n columns.push(propKey);\n labels[propKey] = label || getSanitizedColumnLabel(propKey);\n });\n const parsedRowData = getParsedRowData(rows);\n\n return { columns, labels, parsedRowData };\n};\n\nconst populateRows = ({ toggleModal, url, entitySchema, rows }) => {\n const {\n id: schemaId,\n listingProperties,\n properties,\n dynamicProperties = {},\n formProperties\n } = entitySchema;\n\n const isEnquiry = schemaId === 'enquiry';\n const columnOptions = !isEnquiry ? [...listingProperties, ACTIONS] : [...listingProperties];\n\n const allProperties = { ...properties, ...dynamicProperties };\n const { columns, labels, parsedRowData } = getColumnsAndLabels(\n columnOptions,\n allProperties,\n rows\n );\n const [firstColumn] = columns;\n\n return {\n identification: 'id',\n sort: null,\n columns,\n labels,\n orderBy: [...formProperties],\n rows: formatRows({ firstColumn, rows: parsedRowData, url, toggleModal, isEnquiry }),\n isEnquiry\n };\n};\n\nexport { populateRows, formatRows, getParsedRowData };\n"],"mappings":";;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,QAAQ,kBAAkB;AACvC,OAAOC,YAAY,MAAM,iBAAiB;AAC1C,SAASC,OAAO,QAAQ,oBAAo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B,MAAMrD,SAAS,GAAGsD,QAAQ,KAAK,SAAS;EACxC,MAAMI,aAAa,GAAG,CAAC1D,SAAS,GAAG,CAAC,GAAGyC,iBAAiB,EAAEhD,OAAO,CAAC,GAAG,CAAC,GAAGgD,iBAAiB,CAAC;EAE3F,MAAMC,aAAa,GAAApC,aAAA,CAAAA,aAAA,KAAQiD,UAAU,GAAKC,iBAAiB,CAAE;EAC7D,MAAM;IAAEb,OAAO;IAAEC,MAAM;IAAEO;EAAc,CAAC,GAAGX,mBAAmB,CAC5DkB,aAAa,EACbhB,aAAa,EACb/C,IACF,CAAC;EACD,MAAM,CAACI,WAAW,CAAC,GAAG4C,OAAO;EAE7B,OAAO;IACLgB,cAAc,EAAE,IAAI;IACpBC,IAAI,EAAE,IAAI;IACVjB,OAAO;IACPC,MAAM;IACNiB,OAAO,EAAE,CAAC,GAAGJ,cAAc,CAAC;IAC5B9D,IAAI,EAAED,UAAU,CAAC;MAAEK,WAAW;MAAEJ,IAAI,EAAEwD,aAAa;MAAEvD,GAAG;MAAEC,WAAW;MAAEG;IAAU,CAAC,CAAC;IACnFA;EACF,CAAC;AACH,CAAC;AAED,SAASoD,YAAY,EAAE1D,UAAU,EAAEqC,gBAAgB"}
package/lib-es/index.js CHANGED
@@ -6,15 +6,7 @@ import getAddContentMenuItems from './utils/add-content-menu-items';
6
6
  const EntityDataListing = React.lazy(() => import( /* webpackChunkName: 'EntityDataListing' */'./components/EntityDataListing'));
7
7
  const EntityManager = React.lazy(() => import( /* webpackChunkName: 'EntityManager' */'./components/EntityManager'));
8
8
  export default async function load(app) {
9
- // To load different plugin information into menu
10
- const sectionKey = 'content';
11
- app.events.once('load:menu-section', addSection => {
12
- addSection(sectionKey, {
13
- header: 'content',
14
- order: 100
15
- });
16
- });
17
- app.events.once('load:menu-items', getAddContentMenuItems(app, sectionKey));
9
+ app.events.once('admin:menu:config:load', getAddContentMenuItems(app));
18
10
  app.events.once('load:custom:field:type', addFieldType => {
19
11
  Object.keys(formFieldTypes).forEach(type => {
20
12
  addFieldType({
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["getFormBuilderLookup","formFieldTypes","React","pkg","DATA_LISTING_PREFIX","PLUGIN_NAME","getAddContentMenuItems","EntityDataListing","lazy","EntityManager","load","app","sectionKey","events","once","addSection","header","order","addFieldType","Object","keys","forEach","type","component","emitAsync","entityDataListingRoute","path","key","exact","editEntityRoute","addEntityRoute","addRoute","name","version","pluginName"],"sources":["../src/index.js"],"sourcesContent":["import { getFormBuilderLookup, formFieldTypes } from '@blaze-cms/react-form-builder';\nimport React from 'react';\nimport pkg from '../package.json';\nimport { DATA_LISTING_PREFIX, PLUGIN_NAME } from './constants';\nimport getAddContentMenuItems from './utils/add-content-menu-items';\n\nconst EntityDataListing = React.lazy(() =>\n import(/* webpackChunkName: 'EntityDataListing' */ './components/EntityDataListing')\n);\nconst EntityManager = React.lazy(() =>\n import(/* webpackChunkName: 'EntityManager' */ './components/EntityManager')\n);\n\nexport default async function load(app) {\n // To load different plugin information into menu\n const sectionKey = 'content';\n\n app.events.once('load:menu-section', addSection => {\n addSection(sectionKey, { header: 'content', order: 100 });\n });\n\n app.events.once('load:menu-items', getAddContentMenuItems(app, sectionKey));\n\n app.events.once('load:custom:field:type', addFieldType => {\n Object.keys(formFieldTypes).forEach(type => {\n addFieldType({ type, component: formFieldTypes[type] });\n });\n });\n\n app.events.once('plugin:data-ui:load:loaded', async () => {\n await app.events.emitAsync('load:custom:field:type', getFormBuilderLookup.addFieldType);\n });\n\n const entityDataListingRoute = {\n path: `${DATA_LISTING_PREFIX}/:entityIdentifier`,\n key: 'entityDataListing',\n component: EntityDataListing,\n exact: true\n };\n\n const editEntityRoute = {\n path: `${DATA_LISTING_PREFIX}/:entityIdentifier/:action/:id`,\n key: 'editEntity',\n component: EntityManager,\n exact: true\n };\n\n const addEntityRoute = {\n path: `${DATA_LISTING_PREFIX}/:entityIdentifier/:action`,\n key: 'createEntity',\n component: EntityManager,\n exact: true\n };\n\n app.addRoute(entityDataListingRoute);\n app.addRoute(editEntityRoute);\n app.addRoute(addEntityRoute);\n\n return {\n name: PLUGIN_NAME,\n version: pkg.version\n };\n}\n\nload.pluginName = PLUGIN_NAME;\n"],"mappings":"AAAA,SAASA,oBAAoB,EAAEC,cAAc,QAAQ,+BAA+B;AACpF,OAAOC,KAAK,MAAM,OAAO;AACzB,OAAOC,GAAG,MAAM,iBAAiB;AACjC,SAASC,mBAAmB,EAAEC,WAAW,QAAQ,aAAa;AAC9D,OAAOC,sBAAsB,MAAM,gCAAgC;AAEnE,MAAMC,iBAAiB,GAAGL,KAAK,CAACM,IAAI,CAAC,MACnC,MAAM,EAAC,2CAA4C,gCAAgC,CACrF,CAAC;AACD,MAAMC,aAAa,GAAGP,KAAK,CAACM,IAAI,CAAC,MAC/B,MAAM,EAAC,uCAAwC,4BAA4B,CAC7E,CAAC;AAED,eAAe,eAAeE,IAAIA,CAACC,GAAG,EAAE;EACtC;EACA,MAAMC,UAAU,GAAG,SAAS;EAE5BD,GAAG,CAACE,MAAM,CAACC,IAAI,CAAC,mBAAmB,EAAEC,UAAU,IAAI;IACjDA,UAAU,CAACH,UAAU,EAAE;MAAEI,MAAM,EAAE,SAAS;MAAEC,KAAK,EAAE;IAAI,CAAC,CAAC;EAC3D,CAAC,CAAC;EAEFN,GAAG,CAACE,MAAM,CAACC,IAAI,CAAC,iBAAiB,EAAER,sBAAsB,CAACK,GAAG,EAAEC,UAAU,CAAC,CAAC;EAE3ED,GAAG,CAACE,MAAM,CAACC,IAAI,CAAC,wBAAwB,EAAEI,YAAY,IAAI;IACxDC,MAAM,CAACC,IAAI,CAACnB,cAAc,CAAC,CAACoB,OAAO,CAACC,IAAI,IAAI;MAC1CJ,YAAY,CAAC;QAAEI,IAAI;QAAEC,SAAS,EAAEtB,cAAc,CAACqB,IAAI;MAAE,CAAC,CAAC;IACzD,CAAC,CAAC;EACJ,CAAC,CAAC;EAEFX,GAAG,CAACE,MAAM,CAACC,IAAI,CAAC,4BAA4B,EAAE,YAAY;IACxD,MAAMH,GAAG,CAACE,MAAM,CAACW,SAAS,CAAC,wBAAwB,EAAExB,oBAAoB,CAACkB,YAAY,CAAC;EACzF,CAAC,CAAC;EAEF,MAAMO,sBAAsB,GAAG;IAC7BC,IAAI,EAAG,GAAEtB,mBAAoB,oBAAmB;IAChDuB,GAAG,EAAE,mBAAmB;IACxBJ,SAAS,EAAEhB,iBAAiB;IAC5BqB,KAAK,EAAE;EACT,CAAC;EAED,MAAMC,eAAe,GAAG;IACtBH,IAAI,EAAG,GAAEtB,mBAAoB,gCAA+B;IAC5DuB,GAAG,EAAE,YAAY;IACjBJ,SAAS,EAAEd,aAAa;IACxBmB,KAAK,EAAE;EACT,CAAC;EAED,MAAME,cAAc,GAAG;IACrBJ,IAAI,EAAG,GAAEtB,mBAAoB,4BAA2B;IACxDuB,GAAG,EAAE,cAAc;IACnBJ,SAAS,EAAEd,aAAa;IACxBmB,KAAK,EAAE;EACT,CAAC;EAEDjB,GAAG,CAACoB,QAAQ,CAACN,sBAAsB,CAAC;EACpCd,GAAG,CAACoB,QAAQ,CAACF,eAAe,CAAC;EAC7BlB,GAAG,CAACoB,QAAQ,CAACD,cAAc,CAAC;EAE5B,OAAO;IACLE,IAAI,EAAE3B,WAAW;IACjB4B,OAAO,EAAE9B,GAAG,CAAC8B;EACf,CAAC;AACH;AAEAvB,IAAI,CAACwB,UAAU,GAAG7B,WAAW"}
1
+ {"version":3,"file":"index.js","names":["getFormBuilderLookup","formFieldTypes","React","pkg","DATA_LISTING_PREFIX","PLUGIN_NAME","getAddContentMenuItems","EntityDataListing","lazy","EntityManager","load","app","events","once","addFieldType","Object","keys","forEach","type","component","emitAsync","entityDataListingRoute","path","key","exact","editEntityRoute","addEntityRoute","addRoute","name","version","pluginName"],"sources":["../src/index.js"],"sourcesContent":["import { getFormBuilderLookup, formFieldTypes } from '@blaze-cms/react-form-builder';\nimport React from 'react';\nimport pkg from '../package.json';\nimport { DATA_LISTING_PREFIX, PLUGIN_NAME } from './constants';\nimport getAddContentMenuItems from './utils/add-content-menu-items';\n\nconst EntityDataListing = React.lazy(() =>\n import(/* webpackChunkName: 'EntityDataListing' */ './components/EntityDataListing')\n);\nconst EntityManager = React.lazy(() =>\n import(/* webpackChunkName: 'EntityManager' */ './components/EntityManager')\n);\n\nexport default async function load(app) {\n app.events.once('admin:menu:config:load', getAddContentMenuItems(app));\n\n app.events.once('load:custom:field:type', addFieldType => {\n Object.keys(formFieldTypes).forEach(type => {\n addFieldType({ type, component: formFieldTypes[type] });\n });\n });\n\n app.events.once('plugin:data-ui:load:loaded', async () => {\n await app.events.emitAsync('load:custom:field:type', getFormBuilderLookup.addFieldType);\n });\n\n const entityDataListingRoute = {\n path: `${DATA_LISTING_PREFIX}/:entityIdentifier`,\n key: 'entityDataListing',\n component: EntityDataListing,\n exact: true\n };\n\n const editEntityRoute = {\n path: `${DATA_LISTING_PREFIX}/:entityIdentifier/:action/:id`,\n key: 'editEntity',\n component: EntityManager,\n exact: true\n };\n\n const addEntityRoute = {\n path: `${DATA_LISTING_PREFIX}/:entityIdentifier/:action`,\n key: 'createEntity',\n component: EntityManager,\n exact: true\n };\n\n app.addRoute(entityDataListingRoute);\n app.addRoute(editEntityRoute);\n app.addRoute(addEntityRoute);\n\n return {\n name: PLUGIN_NAME,\n version: pkg.version\n };\n}\n\nload.pluginName = PLUGIN_NAME;\n"],"mappings":"AAAA,SAASA,oBAAoB,EAAEC,cAAc,QAAQ,+BAA+B;AACpF,OAAOC,KAAK,MAAM,OAAO;AACzB,OAAOC,GAAG,MAAM,iBAAiB;AACjC,SAASC,mBAAmB,EAAEC,WAAW,QAAQ,aAAa;AAC9D,OAAOC,sBAAsB,MAAM,gCAAgC;AAEnE,MAAMC,iBAAiB,GAAGL,KAAK,CAACM,IAAI,CAAC,MACnC,MAAM,EAAC,2CAA4C,gCAAgC,CACrF,CAAC;AACD,MAAMC,aAAa,GAAGP,KAAK,CAACM,IAAI,CAAC,MAC/B,MAAM,EAA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E5B,OAAO;IACLE,IAAI,EAAEvB,WAAW;IACjBwB,OAAO,EAAE1B,GAAG,CAAC0B;EACf,CAAC;AACH;AAEAnB,IAAI,CAACoB,UAAU,GAAGzB,WAAW"}
@@ -2,8 +2,10 @@ import { getQuery } from '@blaze-cms/admin-ui-utils';
2
2
  const {
3
3
  MENU_PERMISSIONS
4
4
  } = require('../constants');
5
- function getAddContentMenuItems(app, sectionKey) {
6
- return async addItem => {
5
+ function getAddContentMenuItems(app) {
6
+ return async ({
7
+ addConfig
8
+ }) => {
7
9
  const client = app.getClient();
8
10
  const {
9
11
  data: {
@@ -16,15 +18,57 @@ function getAddContentMenuItems(app, sectionKey) {
16
18
  canDoActions: MENU_PERMISSIONS
17
19
  }
18
20
  });
21
+ if (!getEntitySchemas || !getEntitySchemas.length) return; // no items so don't add section
22
+
23
+ const menuItems = {};
24
+ const sectionMenuItems = {
25
+ content: {}
26
+ };
27
+ getEntitySchemas.forEach(({
28
+ id,
29
+ displayName,
30
+ displayProperties
31
+ }) => {
32
+ if (!displayProperties) return null;
33
+ const {
34
+ adminMenu: {
35
+ sectionKey = 'content'
36
+ } = {}
37
+ } = displayProperties;
38
+ const sectionItems = sectionMenuItems[sectionKey] || {};
39
+ sectionItems[id] = {
40
+ label: displayName,
41
+ uri: `/data-listing/${id}`
42
+ };
43
+ sectionMenuItems[sectionKey] = sectionItems;
44
+ });
45
+ const menuConfig = {
46
+ main: {
47
+ items: {
48
+ content: {
49
+ label: 'Content',
50
+ loadOpen: true,
51
+ order: 10,
52
+ items: menuItems
53
+ }
54
+ }
55
+ }
56
+ };
57
+ Object.entries(sectionMenuItems).forEach(([sectionKey, sectionItems]) => {
58
+ const sectionConfig = menuConfig.main.items[sectionKey] || {};
59
+ sectionConfig.items = sectionItems;
60
+ menuConfig.main.items[sectionKey] = sectionConfig;
61
+ });
19
62
  getEntitySchemas.forEach(({
20
63
  id,
21
64
  displayName
22
65
  }) => {
23
- addItem({
24
- name: displayName,
66
+ menuItems[id] = {
67
+ label: displayName,
25
68
  uri: `/data-listing/${id}`
26
- }, sectionKey);
69
+ };
27
70
  });
71
+ addConfig(menuConfig);
28
72
  };
29
73
  }
30
74
  export default getAddContentMenuItems;
@@ -1 +1 @@
1
- {"version":3,"file":"add-content-menu-items.js","names":["getQuery","MENU_PERMISSIONS","require","getAddContentMenuItems","app","sectionKey","addItem","client","getClient","data","getEntitySchemas","query","variables","canDoActions","forEach","id","displayName","name","uri"],"sources":["../../src/utils/add-content-menu-items.js"],"sourcesContent":["import { getQuery } from '@blaze-cms/admin-ui-utils';\n\nconst { MENU_PERMISSIONS } = require('../constants');\n\nfunction getAddContentMenuItems(app, sectionKey) {\n return async addItem => {\n const client = app.getClient();\n const {\n data: { getEntitySchemas }\n } = await client.query({\n query: getQuery('GET_USER_EDITABLE_ENTITIES'),\n variables: {\n // only return entities that the current user can do the following actions on\n canDoActions: MENU_PERMISSIONS\n }\n });\n getEntitySchemas.forEach(({ id, displayName }) => {\n addItem({ name: displayName, uri: `/data-listing/${id}` }, sectionKey);\n });\n };\n}\n\nexport default getAddContentMenuItems;\n"],"mappings":"AAAA,SAASA,QAAQ,QAAQ,2BAA2B;AAEpD,MAAM;EAAEC;AAAiB,CAAC,GAAGC,OAAO,CAAC,cAAc,CAAC;AAEpD,SAASC,sBAAsBA,CAACC,GAAG,EAAEC,UAAU,EAAE;EAC/C,OAAO,MAAMC,OAAO,IAAI;IACtB,MAAMC,MAAM,GAAGH,GAAG,CAACI,SAAS,CAAC,CAAC;IAC9B,MAAM;MACJC,IAAI,EAAE;QAAEC;MAAiB;IAC3B,CAAC,GAAG,MAAMH,MAAM,CAACI,KAAK,CAAC;MACrBA,KAAK,EAAEX,QAAQ,CAAC,4BAA4B,CAAC;MAC7CY,SAAS,EAAE;QACT;QACAC,YAAY,EAAEZ;MAChB;IACF,CAAC,CAAC;IACFS,gBAAgB,CAACI,OAAO,CAAC,CAAC;MAAEC,EAAE;MAAEC;IAAY,CAAC,KAAK;MAChDV,OAAO,CAAC;QAAEW,IAAI,EAAED,WAAW;QAAEE,GAAG,EAAG,iBAAgBH,EAAG;MAAE,CAAC,EAAEV,UAAU,CAAC;IACxE,CAAC,CAAC;EACJ,CAAC;AACH;AAEA,eAAeF,sBAAsB"}
1
+ {"version":3,"file":"add-content-menu-items.js","names":["getQuery","MENU_PERMISSIONS","require","getAddContentMenuItems","app","addConfig","client","getClient","data","getEntitySchemas","query","variables","canDoActions","length","menuItems","sectionMenuItems","content","forEach","id","displayName","displayProperties","adminMenu","sectionKey","sectionItems","label","uri","menuConfig","main","items","loadOpen","order","Object","entries","sectionConfig"],"sources":["../../src/utils/add-content-menu-items.js"],"sourcesContent":["import { getQuery } from '@blaze-cms/admin-ui-utils';\n\nconst { MENU_PERMISSIONS } = require('../constants');\n\nfunction getAddContentMenuItems(app) {\n return async ({ addConfig }) => {\n const client = app.getClient();\n const {\n data: { getEntitySchemas }\n } = await client.query({\n query: getQuery('GET_USER_EDITABLE_ENTITIES'),\n variables: {\n // only return entities that the current user can do the following actions on\n canDoActions: MENU_PERMISSIONS\n }\n });\n\n if (!getEntitySchemas || !getEntitySchemas.length) return; // no items so don't add section\n\n const menuItems = {};\n const sectionMenuItems = { content: {} };\n\n getEntitySchemas.forEach(({ id, displayName, displayProperties }) => {\n if (!displayProperties) return null;\n\n const { adminMenu: { sectionKey = 'content' } = {} } = displayProperties;\n const sectionItems = sectionMenuItems[sectionKey] || {};\n sectionItems[id] = {\n label: displayName,\n uri: `/data-listing/${id}`\n };\n sectionMenuItems[sectionKey] = sectionItems;\n });\n\n const menuConfig = {\n main: {\n items: {\n content: {\n label: 'Content',\n loadOpen: true,\n order: 10,\n items: menuItems\n }\n }\n }\n };\n\n Object.entries(sectionMenuItems).forEach(([sectionKey, sectionItems]) => {\n const sectionConfig = menuConfig.main.items[sectionKey] || {};\n sectionConfig.items = sectionItems;\n menuConfig.main.items[sectionKey] = sectionConfig;\n });\n\n getEntitySchemas.forEach(({ id, displayName }) => {\n menuItems[id] =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MG,UAAU,GAAG;MACjBC,IAAI,EAAE;QACJC,KAAK,EAAE;UACLZ,OAAO,EAAE;YACPQ,KAAK,EAAE,SAAS;YAChBK,QAAQ,EAAE,IAAI;YACdC,KAAK,EAAE,EAAE;YACTF,KAAK,EAAEd;UACT;QACF;MACF;IACF,CAAC;IAEDiB,MAAM,CAACC,OAAO,CAACjB,gBAAgB,CAAC,CAACE,OAAO,CAAC,CAAC,CAACK,UAAU,EAAEC,YAAY,CAAC,KAAK;MACvE,MAAMU,aAAa,GAAGP,UAAU,CAACC,IAAI,CAACC,KAAK,CAACN,UAAU,CAAC,IAAI,CAAC,CAAC;MAC7DW,aAAa,CAACL,KAAK,GAAGL,YAAY;MAClCG,UAAU,CAACC,IAAI,CAACC,KAAK,CAACN,UAAU,CAAC,GAAGW,aAAa;IACnD,CAAC,CAAC;IAEFxB,gBAAgB,CAACQ,OAAO,CAAC,CAAC;MAAEC,EAAE;MAAEC;IAAY,CAAC,KAAK;MAChDL,SAAS,CAACI,EAAE,CAAC,GAAG;QACdM,KAAK,EAAEL,WAAW;QAClBM,GAAG,EAAG,iBAAgBP,EAAG;MAC3B,CAAC;IACH,CAAC,CAAC;IAEFb,SAAS,CAACqB,UAAU,CAAC;EACvB,CAAC;AACH;AAEA,eAAevB,sBAAsB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blaze-cms/plugin-data-ui",
3
- "version": "0.131.0-admin-updates.2",
3
+ "version": "0.131.0-project-admin-customisations.0",
4
4
  "description": "Blaze plugin data ui",
5
5
  "main": "lib/index.js",
6
6
  "module": "lib-es/index.js",
@@ -27,12 +27,13 @@
27
27
  },
28
28
  "license": "GPL-3.0",
29
29
  "dependencies": {
30
- "@blaze-cms/admin-ui-utils": "0.131.0-admin-updates.0",
31
- "@blaze-cms/core-errors": "0.131.0-admin-updates.0",
32
- "@blaze-cms/react-form-builder": "0.131.0-admin-updates.0",
33
- "@blaze-cms/react-page-builder": "0.131.0-admin-updates.2",
34
- "@blaze-cms/setup-ui": "0.131.0-admin-updates.0",
35
- "@blaze-cms/versioning-ui": "0.131.0-admin-updates.0",
30
+ "@blaze-cms/admin-ui-utils": "0.131.0-project-admin-customisations.0",
31
+ "@blaze-cms/core-errors": "0.131.0-project-admin-customisations.0",
32
+ "@blaze-cms/plugin-render-hooks-ui": "0.131.0-project-admin-customisations.0",
33
+ "@blaze-cms/react-form-builder": "0.131.0-project-admin-customisations.0",
34
+ "@blaze-cms/react-page-builder": "0.131.0-project-admin-customisations.0",
35
+ "@blaze-cms/setup-ui": "0.131.0-project-admin-customisations.0",
36
+ "@blaze-cms/versioning-ui": "0.131.0-project-admin-customisations.0",
36
37
  "@blaze-react/button": "0.5.19",
37
38
  "@blaze-react/more": "0.5.19",
38
39
  "@blaze-react/multiselect": "0.6.6",
@@ -53,7 +54,7 @@
53
54
  "uuid": "^3.3.3"
54
55
  },
55
56
  "devDependencies": {
56
- "@blaze-cms/core-ui": "0.131.0-admin-updates.0"
57
+ "@blaze-cms/core-ui": "0.131.0-project-admin-customisations.0"
57
58
  },
58
59
  "peerDependencies": {
59
60
  "@apollo/client": "3.x",
@@ -65,5 +66,5 @@
65
66
  "lib/*",
66
67
  "lib-es/*"
67
68
  ],
68
- "gitHead": "5c9b447fae07ab1f26456d66d9607005faaa3d8d"
69
+ "gitHead": "409049b62066b81019273ca9ab431439659776ef"
69
70
  }
@@ -6,31 +6,22 @@ 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, menuItems }) => {
9
+ const EntityDataListing = ({ match }) => {
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
-
22
14
  const { data: { getEntitySchemas = [] } = {} } = useQuery(getQuery('GET_ENTITY_SCHEMA'), {
23
15
  variables: { identifier }
24
16
  });
25
17
 
26
18
  if (!getEntitySchemas.length) return '';
27
19
 
28
- return <ListingTable entitySchema={getEntitySchemas[0]} selectedMenuItem={selectedMenuItem} />;
20
+ return <ListingTable entitySchema={getEntitySchemas[0]} />;
29
21
  };
30
22
 
31
23
  EntityDataListing.propTypes = {
32
- match: PropTypes.object.isRequired,
33
- menuItems: PropTypes.array.isRequired
24
+ match: PropTypes.object.isRequired
34
25
  };
35
26
 
36
27
  export default withContext(EntityDataListing);
@@ -0,0 +1,26 @@
1
+ import { Link } from 'react-router-dom';
2
+ import React from 'react';
3
+
4
+ const EntityNavLinks = ({ schema }) => {
5
+ if (!schema) return null;
6
+
7
+ const {
8
+ displayProperties: { adminSectionNavigation }
9
+ } = schema;
10
+
11
+ if (!adminSectionNavigation) return null;
12
+
13
+ const links = Object.entries(adminSectionNavigation).map(([k, v]) => {
14
+ const { label, uri } = v;
15
+ const Wrapper = uri.startsWith('#') ? 'a' : Link;
16
+ return (
17
+ <Wrapper className="entity-section-link" href={uri} to={uri}>
18
+ {label}
19
+ </Wrapper>
20
+ );
21
+ });
22
+
23
+ return <div className="entity-section-links">{links}</div>;
24
+ };
25
+
26
+ export default EntityNavLinks;
@@ -0,0 +1,3 @@
1
+ import EntityNavLinks from './EntityNavLinks';
2
+
3
+ export default EntityNavLinks;
@@ -3,6 +3,7 @@ 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';
6
7
  import { getQuery, GET_CURRENT_TAB_ID } from '@blaze-cms/admin-ui-utils';
7
8
  import { FormBuilder, parseFormValues } from '@blaze-cms/react-form-builder';
8
9
  import { DeleteAction, CopyDataFromAction } from '@blaze-cms/admin';
@@ -34,6 +35,7 @@ import {
34
35
  checkFulfilConditions
35
36
  } from '../utils/entity';
36
37
  import useToggle from '../../../utils/hooks/useToggle';
38
+ import InfoBoxes from '../../InfoBoxes/InfoBoxes';
37
39
 
38
40
  const Entity = ({
39
41
  formData,
@@ -440,6 +442,8 @@ const Entity = ({
440
442
  <div className="page__content--fixed">
441
443
  <div className="page__content">
442
444
  <div className="content">
445
+ <RenderHook hookKey={`entity:${action}:main:top`} entity={entity} schema={schema} />
446
+ <InfoBoxes id={entity.id} schema={schema} />
443
447
  <Tabs
444
448
  enabled={showPageBuilderTabs}
445
449
  onTabChange={tabId => {
@@ -461,6 +465,11 @@ const Entity = ({
461
465
  isNewEntity={isNewEntity}
462
466
  />
463
467
  </Tabs>
468
+ <RenderHook
469
+ hookKey={`entity:${action}:main:bottom`}
470
+ entity={entity}
471
+ schema={schema}
472
+ />
464
473
  </div>
465
474
  </div>
466
475
  </div>
@@ -0,0 +1,22 @@
1
+ import PropTypes from 'prop-types';
2
+ import React from 'react';
3
+ import useCustomSidebarData from '../hooks/useCustomSidebarData';
4
+ import CustomSidebarInfo from '../presentational/CustomSidebarInfo';
5
+
6
+ const CustomSibebarInfoContainer = ({ id, schema, displayProperties }) => {
7
+ const { data } = useCustomSidebarData({ id, schema, displayProperties });
8
+
9
+ if (!data || !Object.keys(data) || Object.keys(data).length === 0) return null;
10
+
11
+ const items = Object.values(data).flatMap(item => Object.values(item));
12
+
13
+ return <CustomSidebarInfo items={items} customSidebarInfoKey={displayProperties.key} />;
14
+ };
15
+
16
+ export default CustomSibebarInfoContainer;
17
+
18
+ CustomSibebarInfoContainer.propTypes = {
19
+ id: PropTypes.string.isRequired,
20
+ displayProperties: PropTypes.object.isRequired,
21
+ schema: PropTypes.object.isRequired
22
+ };
@@ -0,0 +1,33 @@
1
+ import { gql } from '@apollo/client';
2
+ import { BlazeError } from '@blaze-cms/core-errors';
3
+
4
+ export default function buildDynamicQuery({ id, schema, displayProperties }) {
5
+ if (!schema || !schema.actions || !schema.actions.get || !schema.properties) {
6
+ throw new BlazeError(
7
+ 'DataEntity query requires get action, properties and fields from entity schema'
8
+ );
9
+ }
10
+
11
+ if (
12
+ displayProperties.adminMainInfoProperty &&
13
+ Array.isArray(displayProperties.adminMainInfoProperty)
14
+ ) {
15
+ const fields = displayProperties.adminMainInfoProperty.map(
16
+ infoProperty =>
17
+ `${infoProperty} {
18
+ label
19
+ value
20
+ }`
21
+ );
22
+
23
+ return gql`query getInfoBoxData($id: String!){
24
+ ${schema.actions.get}( id: $id ) {
25
+ id
26
+ ${fields.map(field => field)}
27
+ __typename
28
+ }
29
+ }`;
30
+ }
31
+
32
+ return null;
33
+ }
@@ -0,0 +1,28 @@
1
+ import ProptTypes from 'prop-types';
2
+ import { useQuery, gql } from '@apollo/client';
3
+ import buildDynamicQuery from '../helpers/build-dynamic-query';
4
+
5
+ const useCustomSidebarData = ({ id, schema, displayProperties }) => {
6
+ const query = buildDynamicQuery({ id, schema, displayProperties });
7
+
8
+ const customSidebarInfoQuery =
9
+ query ||
10
+ gql`
11
+ query {
12
+ __typename
13
+ }
14
+ `;
15
+
16
+ const { data = {}, loading, error } = useQuery(customSidebarInfoQuery, {
17
+ variables: { id },
18
+ skip: !query
19
+ });
20
+
21
+ return { data: data.__typename !== 'Query' ? data : null, loading, error };
22
+ };
23
+
24
+ export default useCustomSidebarData;
25
+
26
+ useCustomSidebarData.propTypes = {
27
+ displayProperties: ProptTypes.object.isRequired
28
+ };