@blaze-cms/plugin-data-ui 0.131.0-project-admin-customisations.0 → 0.131.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 +2 -37
  2. package/README.md +0 -42
  3. package/lib/components/EntityDataListing/EntityDataListing.js +24 -3
  4. package/lib/components/EntityDataListing/EntityDataListing.js.map +1 -1
  5. package/lib/components/EntityManager/Entity/Entity.js +17 -32
  6. package/lib/components/EntityManager/Entity/Entity.js.map +1 -1
  7. package/lib/components/EntityManager/Entity/SideBarRelations/index.js +7 -23
  8. package/lib/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
  9. package/lib/components/ListingTable/ListingTable.js +33 -19
  10. package/lib/components/ListingTable/ListingTable.js.map +1 -1
  11. package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js +14 -9
  12. package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
  13. package/lib/components/ListingTable/mappers/populate-rows.js +26 -92
  14. package/lib/components/ListingTable/mappers/populate-rows.js.map +1 -1
  15. package/lib/index.js +11 -3
  16. package/lib/index.js.map +1 -1
  17. package/lib/utils/add-content-menu-items.js +13 -64
  18. package/lib/utils/add-content-menu-items.js.map +1 -1
  19. package/lib-es/components/EntityDataListing/EntityDataListing.js +14 -3
  20. package/lib-es/components/EntityDataListing/EntityDataListing.js.map +1 -1
  21. package/lib-es/components/EntityManager/Entity/Entity.js +17 -32
  22. package/lib-es/components/EntityManager/Entity/Entity.js.map +1 -1
  23. package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js +8 -24
  24. package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
  25. package/lib-es/components/ListingTable/ListingTable.js +32 -19
  26. package/lib-es/components/ListingTable/ListingTable.js.map +1 -1
  27. package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js +15 -12
  28. package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
  29. package/lib-es/components/ListingTable/mappers/populate-rows.js +24 -76
  30. package/lib-es/components/ListingTable/mappers/populate-rows.js.map +1 -1
  31. package/lib-es/index.js +9 -1
  32. package/lib-es/index.js.map +1 -1
  33. package/lib-es/utils/add-content-menu-items.js +5 -49
  34. package/lib-es/utils/add-content-menu-items.js.map +1 -1
  35. package/package.json +9 -10
  36. package/src/components/EntityDataListing/EntityDataListing.js +12 -3
  37. package/src/components/EntityManager/Entity/Entity.js +57 -68
  38. package/src/components/EntityManager/Entity/SideBarRelations/index.js +19 -51
  39. package/src/components/ListingTable/ListingTable.js +22 -23
  40. package/src/components/ListingTable/ListingTableContent/ListingTableContent.js +18 -9
  41. package/src/components/ListingTable/mappers/populate-rows.js +18 -83
  42. package/src/index.js +8 -1
  43. package/src/utils/add-content-menu-items.js +3 -45
  44. package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +0 -39
  45. package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js.map +0 -1
  46. package/lib/components/EntityManager/Entity/EntitiyNavLinks/index.js +0 -12
  47. package/lib/components/EntityManager/Entity/EntitiyNavLinks/index.js.map +0 -1
  48. package/lib/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +0 -44
  49. package/lib/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js.map +0 -1
  50. package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +0 -32
  51. package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +0 -1
  52. package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +0 -45
  53. package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +0 -1
  54. package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +0 -38
  55. package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +0 -1
  56. package/lib/components/InfoBoxes/InfoBoxes.js +0 -36
  57. package/lib/components/InfoBoxes/InfoBoxes.js.map +0 -1
  58. package/lib/components/InfoBoxes/container/InfoBoxContainer.js +0 -44
  59. package/lib/components/InfoBoxes/container/InfoBoxContainer.js.map +0 -1
  60. package/lib/components/InfoBoxes/helpers/build-dynamic-query.js +0 -25
  61. package/lib/components/InfoBoxes/helpers/build-dynamic-query.js.map +0 -1
  62. package/lib/components/InfoBoxes/hooks/useData.js +0 -42
  63. package/lib/components/InfoBoxes/hooks/useData.js.map +0 -1
  64. package/lib/components/InfoBoxes/hooks/useInfoBox.js +0 -26
  65. package/lib/components/InfoBoxes/hooks/useInfoBox.js.map +0 -1
  66. package/lib/components/InfoBoxes/index.js +0 -12
  67. package/lib/components/InfoBoxes/index.js.map +0 -1
  68. package/lib/components/InfoBoxes/presentational/InfoBox.js +0 -46
  69. package/lib/components/InfoBoxes/presentational/InfoBox.js.map +0 -1
  70. package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +0 -30
  71. package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js.map +0 -1
  72. package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/index.js +0 -3
  73. package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/index.js.map +0 -1
  74. package/lib-es/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +0 -30
  75. package/lib-es/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js.map +0 -1
  76. package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +0 -26
  77. package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +0 -1
  78. package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +0 -39
  79. package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +0 -1
  80. package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +0 -24
  81. package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +0 -1
  82. package/lib-es/components/InfoBoxes/InfoBoxes.js +0 -28
  83. package/lib-es/components/InfoBoxes/InfoBoxes.js.map +0 -1
  84. package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js +0 -30
  85. package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js.map +0 -1
  86. package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js +0 -25
  87. package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js.map +0 -1
  88. package/lib-es/components/InfoBoxes/hooks/useData.js +0 -37
  89. package/lib-es/components/InfoBoxes/hooks/useData.js.map +0 -1
  90. package/lib-es/components/InfoBoxes/hooks/useInfoBox.js +0 -19
  91. package/lib-es/components/InfoBoxes/hooks/useInfoBox.js.map +0 -1
  92. package/lib-es/components/InfoBoxes/index.js +0 -3
  93. package/lib-es/components/InfoBoxes/index.js.map +0 -1
  94. package/lib-es/components/InfoBoxes/presentational/InfoBox.js +0 -31
  95. package/lib-es/components/InfoBoxes/presentational/InfoBox.js.map +0 -1
  96. package/src/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +0 -26
  97. package/src/components/EntityManager/Entity/EntitiyNavLinks/index.js +0 -3
  98. package/src/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +0 -22
  99. package/src/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +0 -33
  100. package/src/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +0 -28
  101. package/src/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +0 -33
  102. package/src/components/InfoBoxes/InfoBoxes.js +0 -24
  103. package/src/components/InfoBoxes/container/InfoBoxContainer.js +0 -22
  104. package/src/components/InfoBoxes/helpers/build-dynamic-query.js +0 -25
  105. package/src/components/InfoBoxes/hooks/useData.js +0 -20
  106. package/src/components/InfoBoxes/hooks/useInfoBox.js +0 -13
  107. package/src/components/InfoBoxes/index.js +0 -3
  108. package/src/components/InfoBoxes/presentational/InfoBox.js +0 -34
@@ -6,18 +6,19 @@ import React, { useEffect, useState, Fragment } from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import { withRouter, Link } from 'react-router-dom';
8
8
  import More from '@blaze-react/more';
9
+ import { MainContext, useMainContext } from '@blaze-cms/admin-ui-utils';
9
10
  import { PageHeader, DeleteAction } from '@blaze-cms/admin';
10
11
  import { useToasts } from '@blaze-react/toaster';
11
- import { RenderHook } from '@blaze-cms/plugin-render-hooks-ui';
12
12
  import ListingTableContent from './ListingTableContent';
13
13
  import availableActions from '../EntityManager/Entity/actions-handlers';
14
14
  import { fetchData } from './service';
15
- import { populateRows, formatRows, getParsedRowData } from './mappers/populate-rows';
15
+ import { populateRows, formatRows } from './mappers/populate-rows';
16
16
  import { getDefaultQueryParams } from '../../utils/get-default-query-params';
17
17
  const OVER_SCAN_BUFFER = 10;
18
18
  const ListingTable = ({
19
19
  match,
20
- entitySchema
20
+ entitySchema,
21
+ selectedMenuItem
21
22
  }) => {
22
23
  const [tableData, setTableData] = useState({});
23
24
  const [modalStatus, setModalStatus] = useState(false);
@@ -31,6 +32,10 @@ const ListingTable = ({
31
32
  schema: entitySchema
32
33
  });
33
34
  const [queryParams, setQueryParams] = useState(queryParamsDefault);
35
+ const {
36
+ menuItems,
37
+ setMenuItems
38
+ } = useMainContext(MainContext);
34
39
  const client = useApolloClient();
35
40
  const {
36
41
  addToast
@@ -60,7 +65,20 @@ const ListingTable = ({
60
65
  }, [client, entitySchema, match.url, previousSchema.id, queryParams] // eslint-disable-line react-hooks/exhaustive-deps
61
66
  );
62
67
 
63
- const onCloseCardPrompt = () => null;
68
+ const onCloseCardPrompt = () => {
69
+ const updatedSelectedMenuItem = _objectSpread(_objectSpread({}, selectedMenuItem), {}, {
70
+ isDisplayedPrompt: false
71
+ });
72
+ const [{
73
+ header,
74
+ items
75
+ }] = menuItems;
76
+ const updatedItems = items.map(item => item.name === selectedMenuItem.name ? updatedSelectedMenuItem : item);
77
+ setMenuItems([{
78
+ header,
79
+ items: updatedItems
80
+ }]);
81
+ };
64
82
  const toggleModal = item => {
65
83
  setModalStatus(!!item);
66
84
  setItemToDelete(item || {});
@@ -100,8 +118,7 @@ const ListingTable = ({
100
118
  }
101
119
  });
102
120
  const {
103
- columns,
104
- isEnquiry
121
+ columns
105
122
  } = tableData;
106
123
  const [firstColumn] = columns;
107
124
  setTableData(_objectSpread(_objectSpread({}, tableData), {}, {
@@ -109,11 +126,10 @@ const ListingTable = ({
109
126
  [property]: direction
110
127
  },
111
128
  rows: formatRows({
112
- rows: getParsedRowData(data),
129
+ rows: data,
113
130
  url: match.url,
114
131
  toggleModal,
115
- firstColumn,
116
- isEnquiry
132
+ firstColumn
117
133
  })
118
134
  }));
119
135
  };
@@ -135,10 +151,9 @@ const ListingTable = ({
135
151
  }
136
152
  });
137
153
  const updatedRows = [...tableData.rows, ...formatRows({
138
- rows: getParsedRowData(data),
154
+ rows: data,
139
155
  url: match.url,
140
- toggleModal,
141
- isEnquiry: tableData.isEnquiry
156
+ toggleModal
142
157
  })];
143
158
  setVerifiedRanges([...verifiedRanges, loadIndex]);
144
159
  setQueryParams(updatedQueryParams);
@@ -149,7 +164,6 @@ const ListingTable = ({
149
164
  }
150
165
  };
151
166
  if (!tableData || !tableData.rows) return 'loading';
152
- const showAddButton = !!tableData.rows.length && !tableData.isEnquiry;
153
167
  return /*#__PURE__*/React.createElement("div", {
154
168
  className: "page"
155
169
  }, modalStatus && /*#__PURE__*/React.createElement(DeleteAction, {
@@ -159,7 +173,7 @@ const ListingTable = ({
159
173
  }), /*#__PURE__*/React.createElement(PageHeader, {
160
174
  title: entitySchema.displayName,
161
175
  subtitle: ""
162
- }, showAddButton && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Link, {
176
+ }, (!selectedMenuItem.isDisplayedPrompt || !!tableData.rows.length) && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Link, {
163
177
  "data-testid": "addEntity",
164
178
  className: "button button--small",
165
179
  to: `${match.url}/create`
@@ -169,21 +183,20 @@ const ListingTable = ({
169
183
  className: "material-icons"
170
184
  }, "more_vert")), /*#__PURE__*/React.createElement(More.Content, {
171
185
  isMoreMenu: true
172
- }))))), /*#__PURE__*/React.createElement(RenderHook, {
173
- hookKey: "entity:listing:main:top",
174
- schema: entitySchema
175
- }), /*#__PURE__*/React.createElement(ListingTableContent, {
186
+ }))))), /*#__PURE__*/React.createElement(ListingTableContent, {
176
187
  overScanBuffer: OVER_SCAN_BUFFER,
177
188
  onSort: handleSort,
178
189
  onRenderItems: handleRenderedItems,
179
190
  tableData: tableData,
180
191
  onCloseCardPrompt: onCloseCardPrompt,
192
+ selectedMenuItem: selectedMenuItem,
181
193
  scrollToIndex: scrollToIndex
182
194
  }));
183
195
  };
184
196
  ListingTable.propTypes = {
185
197
  entitySchema: PropTypes.object.isRequired,
186
- match: PropTypes.object.isRequired
198
+ match: PropTypes.object.isRequired,
199
+ selectedMenuItem: PropTypes.object.isRequired
187
200
  };
188
201
  export default withRouter(ListingTable);
189
202
  //# sourceMappingURL=ListingTable.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ListingTable.js","names":["useApolloClient","React","useEffect","useState","Fragment","PropTypes","withRouter","Link","More","PageHeader","DeleteAction","useToasts","RenderHook","ListingTableContent","availableActions","fetchData","populateRows","formatRows","getParsedRowData","getDefaultQueryParams","OVER_SCAN_BUFFER","ListingTable","match","entitySchema","tableData","setTableData","modalStatus","setModalStatus","itemToDelete","setItemToDelete","previousSchema","setPreviousSchema","id","scrollToIndex","setScrollToIndex","verifiedRanges","setVerifiedRanges","queryParamsDefault","schema","queryParams","setQueryParams","client","addToast","data","querySettings","populatedTable","toggleModal","url","rows","onCloseCardPrompt","item","deleteAction","delete","submit","parsedFormValues","updatedTableData","_objectSpread","filter","handleSort","event","property","direction","Object","entries","sortQueryParams","sort","columns","isEnquiry","firstColumn","appliedSort","handleRenderedItems","params","startIndex","rowsLength","length","loadIndex","Math","floor","includes","updatedQueryParams","offset","updatedRows","showAddButton","createElement","className","onClose","itemName","name","title","displayName","subtitle","to","Actions","Avatar","isMoreMenu","Content","hookKey","overScanBuffer","onSort","onRenderItems","propTypes","object","isRequired"],"sources":["../../../src/components/ListingTable/ListingTable.js"],"sourcesContent":["import { useApolloClient } from '@apollo/client';\nimport React, { useEffect, useState, Fragment } from 'react';\nimport PropTypes from 'prop-types';\nimport { withRouter, Link } from 'react-router-dom';\nimport More from '@blaze-react/more';\nimport { PageHeader, DeleteAction } from '@blaze-cms/admin';\nimport { useToasts } from '@blaze-react/toaster';\nimport { RenderHook } from '@blaze-cms/plugin-render-hooks-ui';\nimport ListingTableContent from './ListingTableContent';\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 OVER_SCAN_BUFFER = 10;\n\nconst ListingTable = ({ match, entitySchema }) => {\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 [scrollToIndex, setScrollToIndex] = useState(0);\n const [verifiedRanges, setVerifiedRanges] = useState([]);\n const queryParamsDefault = getDefaultQueryParams({ schema: entitySchema });\n const [queryParams, setQueryParams] = useState(queryParamsDefault);\n const client = useApolloClient();\n const { addToast } = useToasts();\n\n useEffect(\n () => {\n (async () => {\n if (\n entitySchema.id !== previousSchema.id ||\n (previousSchema.id === null && entitySchema.id)\n ) {\n const data = await fetchData({\n client,\n querySettings: {\n entitySchema,\n queryParams: queryParamsDefault\n }\n });\n const populatedTable = populateRows({\n toggleModal,\n url: match.url,\n entitySchema,\n rows: data\n });\n\n setTableData(populatedTable);\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 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 setScrollToIndex(0);\n setVerifiedRanges([]);\n setQueryParams(sortQueryParams);\n\n const data = await fetchData({\n client,\n querySettings: {\n entitySchema,\n queryParams: sortQueryParams\n }\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(data),\n url: match.url,\n toggleModal,\n firstColumn,\n isEnquiry\n })\n });\n };\n\n const handleRenderedItems = async params => {\n const { startIndex } = params;\n const rowsLength = tableData.rows.length;\n const loadIndex = Math.floor(rowsLength / 3) - OVER_SCAN_BUFFER;\n if (loadIndex > 0 && loadIndex < startIndex && !verifiedRanges.includes(loadIndex)) {\n const updatedQueryParams = {\n ...queryParams,\n offset: rowsLength\n };\n const data = await fetchData({\n client,\n querySettings: {\n entitySchema,\n queryParams: updatedQueryParams\n }\n });\n const updatedRows = [\n ...tableData.rows,\n ...formatRows({\n rows: getParsedRowData(data),\n url: match.url,\n toggleModal,\n isEnquiry: tableData.isEnquiry\n })\n ];\n\n setVerifiedRanges([...verifiedRanges, loadIndex]);\n setQueryParams(updatedQueryParams);\n setTableData({\n ...tableData,\n rows: updatedRows\n });\n setScrollToIndex(startIndex + OVER_SCAN_BUFFER);\n }\n };\n\n if (!tableData || !tableData.rows) return 'loading';\n const showAddButton = !!tableData.rows.length && !tableData.isEnquiry;\n\n return (\n <div className=\"page\">\n {modalStatus && (\n <DeleteAction\n onClose={toggleModal}\n deleteAction={deleteAction}\n itemName={itemToDelete.name}\n />\n )}\n <PageHeader title={entitySchema.displayName} subtitle=\"\">\n {showAddButton && (\n <Fragment>\n <Link\n data-testid=\"addEntity\"\n className=\"button button--small\"\n to={`${match.url}/create`}>\n Add\n </Link>\n <PageHeader.Actions>\n <More>\n <More.Avatar isMoreMenu>\n <span className=\"material-icons\">more_vert</span>\n </More.Avatar>\n <More.Content isMoreMenu />\n </More>\n </PageHeader.Actions>\n </Fragment>\n )}\n </PageHeader>\n <RenderHook hookKey=\"entity:listing:main:top\" schema={entitySchema} />\n <ListingTableContent\n overScanBuffer={OVER_SCAN_BUFFER}\n onSort={handleSort}\n onRenderItems={handleRenderedItems}\n tableData={tableData}\n onCloseCardPrompt={onCloseCardPrompt}\n scrollToIndex={scrollToIndex}\n />\n </div>\n );\n};\nListingTable.propTypes = {\n entitySchema: PropTypes.object.isRequired,\n match: PropTypes.object.isRequired\n};\n\nexport default withRouter(ListingTable);\n"],"mappings":";;;AAAA,SAASA,eAAe,QAAQ,gBAAgB;AAChD,OAAOC,KAAK,IAAIC,SAAS,EAAEC,QAAQ,EAAEC,QAAQ,QAAQ,OAAO;AAC5D,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,UAAU,EAAEC,IAAI,QAAQ,kBAAkB;AACnD,OAAOC,IAAI,MAAM,mBAAmB;AACpC,SAASC,UAAU,EAAEC,YAAY,QAAQ,kBAAkB;AAC3D,SAASC,SAAS,QAAQ,sBAAsB;AAChD,SAASC,UAAU,QAAQ,mCAAmC;AAC9D,OAAOC,mBAAmB,MAAM,uBAAuB;AACvD,OAAOC,gBAAgB,MAAM,0CAA0C;AACvE,SAASC,SAAS,QAAQ,WAAW;AACrC,SAASC,YAAY,EAAEC,UAAU,EAAEC,gBAAgB,QAAQ,yBAAyB;AACpF,SAASC,qBAAqB,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,qBACPH,KAAA,CAAAkF,aAAA,CAAC5E,IAAI;IACH,eAAY,WAAW;IACvB6E,SAAS,EAAC,sBAAsB;IAChCO,EAAE,EAAG,GAAErE,KAAK,CAACyB,GAAI;EAAS,GAAC,KAEvB,CAAC,eACP9C,KAAA,CAAAkF,aAAA,CAAC1E,UAAU,CAACmF,OAAO,qBACjB3F,KAAA,CAAAkF,aAAA,CAAC3E,IAAI,qBACHP,KAAA,CAAAkF,aAAA,CAAC3E,IAAI,CAACqF,MAAM;IAACC,UAAU;EAAA,gBACrB7F,KAAA,CAAAkF,aAAA;IAAMC,SAAS,EAAC;EAAgB,GAAC,WAAe,CACrC,CAAC,eACdnF,KAAA,CAAAkF,aAAA,CAAC3E,IAAI,CAACuF,OAAO;IAACD,UAAU;EAAA,CAAE,CACtB,CACY,CACZ,CAEF,CAAC,eACb7F,KAAA,CAAAkF,aAAA,CAACvE,UAAU;IAACoF,OAAO,EAAC,yBAAyB;IAAC1D,MAAM,EAAEf;EAAa,CAAE,CAAC,eACtEtB,KAAA,CAAAkF,aAAA,CAACtE,mBAAmB;IAClBoF,cAAc,EAAE7E,gBAAiB;IACjC8E,MAAM,EAAExC,UAAW;IACnByC,aAAa,EAAE7B,mBAAoB;IACnC9C,SAAS,EAAEA,SAAU;IACrByB,iBAAiB,EAAEA,iBAAkB;IACrChB,aAAa,EAAEA;EAAc,CAC9B,CACE,CAAC;AAEV,CAAC;AACDZ,YAAY,CAAC+E,SAAS,GAAG;EACvB7E,YAAY,EAAElB,SAAS,CAACgG,MAAM,CAACC,UAAU;EACzChF,KAAK,EAAEjB,SAAS,CAACgG,MAAM,CAACC;AAC1B,CAAC;AAED,eAAehG,UAAU,CAACe,YAAY,CAAC"}
1
+ {"version":3,"file":"ListingTable.js","names":["useApolloClient","React","useEffect","useState","Fragment","PropTypes","withRouter","Link","More","MainContext","useMainContext","PageHeader","DeleteAction","useToasts","ListingTableContent","availableActions","fetchData","populateRows","formatRows","getDefaultQueryParams","OVER_SCAN_BUFFER","ListingTable","match","entitySchema","selectedMenuItem","tableData","setTableData","modalStatus","setModalStatus","itemToDelete","setItemToDelete","previousSchema","setPreviousSchema","id","scrollToIndex","setScrollToIndex","verifiedRanges","setVerifiedRanges","queryParamsDefault","schema","queryParams","setQueryParams","menuItems","setMenuItems","client","addToast","data","querySettings","populatedTable","toggleModal","url","rows","onCloseCardPrompt","updatedSelectedMenuItem","_objectSpread","isDisplayedPrompt","header","items","updatedItems","map","item","name","deleteAction","delete","submit","parsedFormValues","updatedTableData","filter","handleSort","event","property","direction","Object","entries","sortQueryParams","sort","columns","firstColumn","appliedSort","handleRenderedItems","params","startIndex","rowsLength","length","loadIndex","Math","floor","includes","updatedQueryParams","offset","updatedRows","createElement","className","onClose","itemName","title","displayName","subtitle","to","Actions","Avatar","isMoreMenu","Content","overScanBuffer","onSort","onRenderItems","propTypes","object","isRequired"],"sources":["../../../src/components/ListingTable/ListingTable.js"],"sourcesContent":["import { useApolloClient } from '@apollo/client';\nimport React, { useEffect, useState, Fragment } from 'react';\nimport PropTypes from 'prop-types';\nimport { withRouter, Link } from 'react-router-dom';\nimport More from '@blaze-react/more';\nimport { MainContext, useMainContext } from '@blaze-cms/admin-ui-utils';\nimport { PageHeader, DeleteAction } from '@blaze-cms/admin';\nimport { useToasts } from '@blaze-react/toaster';\nimport ListingTableContent from './ListingTableContent';\nimport availableActions from '../EntityManager/Entity/actions-handlers';\nimport { fetchData } from './service';\nimport { populateRows, formatRows } from './mappers/populate-rows';\nimport { getDefaultQueryParams } from '../../utils/get-default-query-params';\n\nconst OVER_SCAN_BUFFER = 10;\n\nconst ListingTable = ({ match, entitySchema, selectedMenuItem }) => {\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 [scrollToIndex, setScrollToIndex] = useState(0);\n const [verifiedRanges, setVerifiedRanges] = useState([]);\n const queryParamsDefault = getDefaultQueryParams({ schema: entitySchema });\n const [queryParams, setQueryParams] = useState(queryParamsDefault);\n const { menuItems, setMenuItems } = useMainContext(MainContext);\n const client = useApolloClient();\n const { addToast } = useToasts();\n\n useEffect(\n () => {\n (async () => {\n if (\n entitySchema.id !== previousSchema.id ||\n (previousSchema.id === null && entitySchema.id)\n ) {\n const data = await fetchData({\n client,\n querySettings: {\n entitySchema,\n queryParams: queryParamsDefault\n }\n });\n const populatedTable = populateRows({\n toggleModal,\n url: match.url,\n entitySchema,\n rows: data\n });\n setTableData(populatedTable);\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 onCloseCardPrompt = () => {\n const updatedSelectedMenuItem = {\n ...selectedMenuItem,\n isDisplayedPrompt: false\n };\n const [{ header, items }] = menuItems;\n const updatedItems = items.map(\n item => (item.name === selectedMenuItem.name ? updatedSelectedMenuItem : item)\n );\n setMenuItems([{ header, items: updatedItems }]);\n };\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 setScrollToIndex(0);\n setVerifiedRanges([]);\n setQueryParams(sortQueryParams);\n\n const data = await fetchData({\n client,\n querySettings: {\n entitySchema,\n queryParams: sortQueryParams\n }\n });\n const { columns } = tableData;\n const [firstColumn] = columns;\n\n setTableData({\n ...tableData,\n appliedSort: { [property]: direction },\n rows: formatRows({ rows: data, url: match.url, toggleModal, firstColumn })\n });\n };\n\n const handleRenderedItems = async params => {\n const { startIndex } = params;\n const rowsLength = tableData.rows.length;\n const loadIndex = Math.floor(rowsLength / 3) - OVER_SCAN_BUFFER;\n if (loadIndex > 0 && loadIndex < startIndex && !verifiedRanges.includes(loadIndex)) {\n const updatedQueryParams = {\n ...queryParams,\n offset: rowsLength\n };\n const data = await fetchData({\n client,\n querySettings: {\n entitySchema,\n queryParams: updatedQueryParams\n }\n });\n const updatedRows = [\n ...tableData.rows,\n ...formatRows({ rows: data, url: match.url, toggleModal })\n ];\n\n setVerifiedRanges([...verifiedRanges, loadIndex]);\n setQueryParams(updatedQueryParams);\n setTableData({\n ...tableData,\n rows: updatedRows\n });\n setScrollToIndex(startIndex + OVER_SCAN_BUFFER);\n }\n };\n\n if (!tableData || !tableData.rows) return 'loading';\n\n return (\n <div className=\"page\">\n {modalStatus && (\n <DeleteAction\n onClose={toggleModal}\n deleteAction={deleteAction}\n itemName={itemToDelete.name}\n />\n )}\n <PageHeader title={entitySchema.displayName} subtitle=\"\">\n {(!selectedMenuItem.isDisplayedPrompt || !!tableData.rows.length) && (\n <Fragment>\n <Link\n data-testid=\"addEntity\"\n className=\"button button--small\"\n to={`${match.url}/create`}>\n Add\n </Link>\n <PageHeader.Actions>\n <More>\n <More.Avatar isMoreMenu>\n <span className=\"material-icons\">more_vert</span>\n </More.Avatar>\n <More.Content isMoreMenu />\n </More>\n </PageHeader.Actions>\n </Fragment>\n )}\n </PageHeader>\n <ListingTableContent\n overScanBuffer={OVER_SCAN_BUFFER}\n onSort={handleSort}\n onRenderItems={handleRenderedItems}\n tableData={tableData}\n onCloseCardPrompt={onCloseCardPrompt}\n selectedMenuItem={selectedMenuItem}\n scrollToIndex={scrollToIndex}\n />\n </div>\n );\n};\nListingTable.propTypes = {\n entitySchema: PropTypes.object.isRequired,\n match: PropTypes.object.isRequired,\n selectedMenuItem: PropTypes.object.isRequired\n};\n\nexport default withRouter(ListingTable);\n"],"mappings":";;;AAAA,SAASA,eAAe,QAAQ,gBAAgB;AAChD,OAAOC,K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AS,EAAC;EAAgB,GAAC,WAAe,CACrC,CAAC,eACd3F,KAAA,CAAA0F,aAAA,CAACnF,IAAI,CAAC8F,OAAO;IAACD,UAAU;EAAA,CAAE,CACtB,CACY,CACZ,CAEF,CAAC,eACbpG,KAAA,CAAA0F,aAAA,CAAC7E,mBAAmB;IAClByF,cAAc,EAAEnF,gBAAiB;IACjCoF,MAAM,EAAEpC,UAAW;IACnBqC,aAAa,EAAE1B,mBAAoB;IACnCtD,SAAS,EAAEA,SAAU;IACrB2B,iBAAiB,EAAEA,iBAAkB;IACrC5B,gBAAgB,EAAEA,gBAAiB;IACnCU,aAAa,EAAEA;EAAc,CAC9B,CACE,CAAC;AAEV,CAAC;AACDb,YAAY,CAACqF,SAAS,GAAG;EACvBnF,YAAY,EAAElB,SAAS,CAACsG,MAAM,CAACC,UAAU;EACzCtF,KAAK,EAAEjB,SAAS,CAACsG,MAAM,CAACC,UAAU;EAClCpF,gBAAgB,EAAEnB,SAAS,CAACsG,MAAM,CAACC;AACrC,CAAC;AAED,eAAetG,UAAU,CAACe,YAAY,CAAC"}
@@ -1,7 +1,8 @@
1
1
  import React from 'react';
2
2
  import Table from '@blaze-react/table';
3
3
  import PropTypes from 'prop-types';
4
- import { withRouter } from 'react-router-dom';
4
+ import { CardPrompt } from '@blaze-cms/admin';
5
+ import { Link, withRouter } from 'react-router-dom';
5
6
  const ListingTableContent = ({
6
7
  tableData,
7
8
  handleSelect,
@@ -15,12 +16,8 @@ const ListingTableContent = ({
15
16
  scrollToIndex
16
17
  }) => {
17
18
  const displayTable = tableData && tableData.rows && !!tableData.rows.length;
18
- const {
19
- isEnquiry
20
- } = tableData;
21
- const className = `page__content${isEnquiry ? ' array-table' : ''}`;
22
- return /*#__PURE__*/React.createElement(React.Fragment, null, displayTable && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
23
- className: className
19
+ return /*#__PURE__*/React.createElement(React.Fragment, null, displayTable ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
20
+ className: "page__content"
24
21
  }, /*#__PURE__*/React.createElement(Table, {
25
22
  scrollToIndex: scrollToIndex,
26
23
  onSort: onSort,
@@ -28,15 +25,22 @@ const ListingTableContent = ({
28
25
  overScanBuffer: overScanBuffer,
29
26
  onRenderItems: onRenderItems,
30
27
  data: tableData,
31
- checkboxes: !isEnquiry,
28
+ checkboxes: true,
32
29
  onSelect: handleSelect,
33
30
  "data-testid": "listing-table-content"
34
- }))));
31
+ }))) : selectedMenuItem.isDisplayedPrompt && /*#__PURE__*/React.createElement(CardPrompt, {
32
+ onClose: onCloseCardPrompt,
33
+ "data-testid": "card-prompt"
34
+ }, /*#__PURE__*/React.createElement(Link, {
35
+ className: "button button--rounded button--cta",
36
+ to: `${match.url}/create`,
37
+ "data-testid": "add-button"
38
+ }, "Add")));
35
39
  };
36
40
  ListingTableContent.propTypes = {
37
41
  tableData: PropTypes.object.isRequired,
38
42
  onCloseCardPrompt: PropTypes.func.isRequired,
39
- selectedMenuItem: PropTypes.object,
43
+ selectedMenuItem: PropTypes.object.isRequired,
40
44
  match: PropTypes.shape({
41
45
  url: PropTypes.string
42
46
  }).isRequired,
@@ -53,8 +57,7 @@ ListingTableContent.defaultProps = {
53
57
  onClickRow: () => {},
54
58
  overScanBuffer: 0,
55
59
  scrollToIndex: 0,
56
- onRenderItems: () => {},
57
- selectedMenuItem: null
60
+ onRenderItems: () => {}
58
61
  };
59
62
  export default withRouter(ListingTableContent);
60
63
  //# sourceMappingURL=ListingTableContent.js.map
@@ -1 +1 @@
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,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,UAAU,QAAQ,kBAAkB;AAE7C,MAAMC,mBAAmB,GAAGA,CAAC;EAC3BC,SAAS;EACTC,YAAY;EACZC,iBAAiB;EACjBC,gBAAgB;EAChBC,KAAK;EACLC,MAAM;EACNC,UAAU;EACV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AS,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"}
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;IA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AG;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"}
@@ -10,22 +10,20 @@ const formatRows = ({
10
10
  url,
11
11
  toggleModal,
12
12
  label,
13
- firstColumn = 'name',
14
- isEnquiry
13
+ firstColumn = 'name'
15
14
  }) => rows.map(data => {
16
15
  const editUrl = `${url}/update/${data.id}`;
17
- const rowProps = _objectSpread(_objectSpread({}, data), {}, {
16
+ return _objectSpread(_objectSpread({}, data), {}, {
18
17
  [firstColumn]: /*#__PURE__*/React.createElement(Link, {
19
18
  to: editUrl,
20
19
  role: "button"
21
- }, data[firstColumn])
20
+ }, data[firstColumn]),
21
+ actions: /*#__PURE__*/React.createElement(TableActions, {
22
+ editUrl: editUrl,
23
+ data: data,
24
+ showDeleteModal: toggleModal
25
+ })
22
26
  });
23
- if (!isEnquiry) rowProps.actions = /*#__PURE__*/React.createElement(TableActions, {
24
- editUrl: editUrl,
25
- data: data,
26
- showDeleteModal: toggleModal
27
- });
28
- return rowProps;
29
27
  });
30
28
  const getSanitizedColumnLabel = columnProp => {
31
29
  let sanitizedChar = '';
@@ -34,57 +32,14 @@ const getSanitizedColumnLabel = columnProp => {
34
32
  }
35
33
  return sanitizedChar;
36
34
  };
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
- };
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
+ }, {});
88
43
  };
89
44
  const populateRows = ({
90
45
  toggleModal,
@@ -93,21 +48,16 @@ const populateRows = ({
93
48
  rows
94
49
  }) => {
95
50
  const {
96
- id: schemaId,
97
51
  listingProperties,
98
52
  properties,
99
53
  dynamicProperties = {},
100
54
  formProperties
101
55
  } = entitySchema;
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);
56
+ const columns = [...listingProperties, ACTIONS];
110
57
  const [firstColumn] = columns;
58
+ const labels = _objectSpread(_objectSpread({}, getColumnLabels(listingProperties, properties, dynamicProperties)), {}, {
59
+ [ACTIONS]: ACTIONS
60
+ });
111
61
  return {
112
62
  identification: 'id',
113
63
  sort: null,
@@ -116,13 +66,11 @@ const populateRows = ({
116
66
  orderBy: [...formProperties],
117
67
  rows: formatRows({
118
68
  firstColumn,
119
- rows: parsedRowData,
69
+ rows,
120
70
  url,
121
- toggleModal,
122
- isEnquiry
123
- }),
124
- isEnquiry
71
+ toggleModal
72
+ })
125
73
  };
126
74
  };
127
- export { populateRows, formatRows, getParsedRowData };
75
+ export { populateRows, formatRows };
128
76
  //# 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","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,oBAAoB;AAE5C,MAAMC,UAAU,GAAGA,CAAC;EAAEC,IAAI;EAAEC,GAAG;EAAEC,WAAW;EAAEC,KAAK;EAAEC,WAAW,GAAG,MAAM;EAAEC;AAAU,CAAC,KACpFL,IAAI,CAACM,GAAG,CAACC,IAAI,IAAI;EACf,MAAMC,OAAO,GAAI,GAAEP,GAAI,WAAUM,IAAI,CAACE,EAAG,EAAC;EAC1C,MAAMC,QAAQ,GAAAC,aAAA,CAAAA,aAAA,KACTJ,IAAI;IACP,CAACH,WAAW,gBACVT,KAAA,CAAAiB,aAAA,CAAChB,IAAI;MAACiB,EAAE,EAAEL,OAAQ;MAACM,IAAI,EAAC;IAAQ,GAC7BP,IAAI,CAACH,WAAW,CACb;EACP,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;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"}
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":";;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,SAASC,IAAI,QAAQ,kBAAkB;AACvC,OAAOC,YAAY,MAAM,iBAAiB;AAC1C,SAASC,OAAO,QAAQ,oBAAoB;AAE5C,MAAMC,UAAU,GAAGA,CAAC;EAAEC,IAAI;EAAEC,GAAG;EAAEC,WAAW;EAAEC,KAAK;EAAEC,WAAW,GAAG;AAAO,CAAC,KACzEJ,IAAI,CAACK,GAAG,CAACC,IAAI,IAAI;EACf,MAAMC,OAAO,GAAI,GAAEN,GAAI,WAAUK,IAAI,CAACE,EAAG,EAAC;EAC1C,OAAAC,aAAA,CAAAA,aAAA,KACKH,IAAI;IACP,CAACF,WAAW,gBACVT,KAAA,CAAAe,aAAA,CAACd,IAAI;MAACe,EAAE,EAAEJ,OAAQ;MAACK,IAAI,EAAC;IAAQ,GAC7BN,IAAI,CAACF,WAAW,CACb,CACP;IACDS,OAAO,eAAElB,KAAA,CAAAe,aAAA,CAACb,YAAY;MAACU,OAAO,EAAEA,OAAQ;MAACD,IAAI,EAAEA,IAAK;MAACQ,eAAe,EAAEZ;IAAY,CAAE;EAAC;AAEzF,CAAC,CAAC;AAEJ,MAAMa,uBAAuB,GAAGC,UAAU,IAAI;EAC5C,IAAIC,aAAa,GAAG,EAAE;EAEtB,KAAK,IAAIC,KAAK,GAAG,CAAC,EAAEA,KAA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BAAiB,CAAC;IACpE,CAAC3B,OAAO,GAAGA;EAAO,EACnB;EAED,OAAO;IACLqC,cAAc,EAAE,IAAI;IACpBC,IAAI,EAAE,IAAI;IACVH,OAAO;IACPC,MAAM;IACNG,OAAO,EAAE,CAAC,GAAGL,cAAc,CAAC;IAC5BhC,IAAI,EAAED,UAAU,CAAC;MAAEK,WAAW;MAAEJ,IAAI;MAAEC,GAAG;MAAEC;IAAY,CAAC;EAC1D,CAAC;AACH,CAAC;AAED,SAAS4B,YAAY,EAAE/B,UAAU"}
package/lib-es/index.js CHANGED
@@ -6,7 +6,15 @@ 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
- app.events.once('admin:menu:config:load', getAddContentMenuItems(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));
10
18
  app.events.once('load:custom:field:type', addFieldType => {
11
19
  Object.keys(formFieldTypes).forEach(type => {
12
20
  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","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,EAAC,uCAAwC,4BAA4B,CAC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EAAEvB,WAAW;IACjBwB,OAAO,EAAE1B,GAAG,CAAC0B;EACf,CAAC;AACH;AAEAnB,IAAI,CAACoB,UAAU,GAAGzB,WAAW"}
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"}
@@ -2,10 +2,8 @@ import { getQuery } from '@blaze-cms/admin-ui-utils';
2
2
  const {
3
3
  MENU_PERMISSIONS
4
4
  } = require('../constants');
5
- function getAddContentMenuItems(app) {
6
- return async ({
7
- addConfig
8
- }) => {
5
+ function getAddContentMenuItems(app, sectionKey) {
6
+ return async addItem => {
9
7
  const client = app.getClient();
10
8
  const {
11
9
  data: {
@@ -18,57 +16,15 @@ function getAddContentMenuItems(app) {
18
16
  canDoActions: MENU_PERMISSIONS
19
17
  }
20
18
  });
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
- });
62
19
  getEntitySchemas.forEach(({
63
20
  id,
64
21
  displayName
65
22
  }) => {
66
- menuItems[id] = {
67
- label: displayName,
23
+ addItem({
24
+ name: displayName,
68
25
  uri: `/data-listing/${id}`
69
- };
26
+ }, sectionKey);
70
27
  });
71
- addConfig(menuConfig);
72
28
  };
73
29
  }
74
30
  export default getAddContentMenuItems;
@@ -1 +1 @@
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] = {\n label: displayName,\n uri: `/data-listing/${id}`\n };\n });\n\n addConfig(menuConfig);\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,EAAE;EACnC,OAAO,OAAO;IAAEC;EAAU,CAAC,KAAK;IAC9B,MAAMC,MAAM,GAAGF,GAAG,CAACG,SAAS,CAAC,CAAC;IAC9B,MAAM;MACJC,IAAI,EAAE;QAAEC;MAAiB;IAC3B,CAAC,GAAG,MAAMH,MAAM,CAACI,KAAK,CAAC;MACrBA,KAAK,EAAEV,QAAQ,CAAC,4BAA4B,CAAC;MAC7CW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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"}
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"}