@blaze-cms/plugin-data-ui 0.139.0-alpha.3 → 0.139.0-alpha.6

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 (217) hide show
  1. package/CHANGELOG.md +56 -0
  2. package/README.md +42 -0
  3. package/lib/components/EntityDataListing/EntityDataListing.js +4 -26
  4. package/lib/components/EntityDataListing/EntityDataListing.js.map +1 -1
  5. package/lib/components/EntityDataListing/index.js +1 -2
  6. package/lib/components/EntityDataListing/index.js.map +1 -1
  7. package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +38 -0
  8. package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js.map +1 -0
  9. package/lib/components/EntityManager/Entity/EntitiyNavLinks/index.js +11 -0
  10. package/lib/components/EntityManager/Entity/EntitiyNavLinks/index.js.map +1 -0
  11. package/lib/components/EntityManager/Entity/Entity.js +19 -7
  12. package/lib/components/EntityManager/Entity/Entity.js.map +1 -1
  13. package/lib/components/EntityManager/Entity/EntityHeader/EntityHeader.js +1 -2
  14. package/lib/components/EntityManager/Entity/EntityHeader/EntityHeader.js.map +1 -1
  15. package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js +1 -2
  16. package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js.map +1 -1
  17. package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/index.js +1 -2
  18. package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/index.js.map +1 -1
  19. package/lib/components/EntityManager/Entity/EntityHeader/index.js +1 -2
  20. package/lib/components/EntityManager/Entity/EntityHeader/index.js.map +1 -1
  21. package/lib/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +43 -0
  22. package/lib/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js.map +1 -0
  23. package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +32 -0
  24. package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +1 -0
  25. package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +44 -0
  26. package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +1 -0
  27. package/lib/components/EntityManager/Entity/SideBarRelations/index.js +15 -6
  28. package/lib/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
  29. package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +37 -0
  30. package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +1 -0
  31. package/lib/components/EntityManager/Entity/actions-handlers/create/index.js +1 -2
  32. package/lib/components/EntityManager/Entity/actions-handlers/create/index.js.map +1 -1
  33. package/lib/components/EntityManager/Entity/actions-handlers/create/submit.js +1 -2
  34. package/lib/components/EntityManager/Entity/actions-handlers/create/submit.js.map +1 -1
  35. package/lib/components/EntityManager/Entity/actions-handlers/delete/delete.js +1 -2
  36. package/lib/components/EntityManager/Entity/actions-handlers/delete/delete.js.map +1 -1
  37. package/lib/components/EntityManager/Entity/actions-handlers/delete/index.js +1 -2
  38. package/lib/components/EntityManager/Entity/actions-handlers/delete/index.js.map +1 -1
  39. package/lib/components/EntityManager/Entity/actions-handlers/index.js +1 -2
  40. package/lib/components/EntityManager/Entity/actions-handlers/index.js.map +1 -1
  41. package/lib/components/EntityManager/Entity/actions-handlers/shared/index.js +1 -2
  42. package/lib/components/EntityManager/Entity/actions-handlers/shared/index.js.map +1 -1
  43. package/lib/components/EntityManager/Entity/actions-handlers/shared/publish.js +1 -2
  44. package/lib/components/EntityManager/Entity/actions-handlers/shared/publish.js.map +1 -1
  45. package/lib/components/EntityManager/Entity/actions-handlers/update/index.js +1 -2
  46. package/lib/components/EntityManager/Entity/actions-handlers/update/index.js.map +1 -1
  47. package/lib/components/EntityManager/Entity/actions-handlers/update/submit.js +1 -2
  48. package/lib/components/EntityManager/Entity/actions-handlers/update/submit.js.map +1 -1
  49. package/lib/components/EntityManager/Entity/index.js +1 -2
  50. package/lib/components/EntityManager/Entity/index.js.map +1 -1
  51. package/lib/components/EntityManager/EntityManager.js +3 -4
  52. package/lib/components/EntityManager/EntityManager.js.map +1 -1
  53. package/lib/components/EntityManager/index.js +1 -2
  54. package/lib/components/EntityManager/index.js.map +1 -1
  55. package/lib/components/EntityManager/utils/data-mappers.js +4 -8
  56. package/lib/components/EntityManager/utils/data-mappers.js.map +1 -1
  57. package/lib/components/EntityManager/utils/entityAvailableActions.js +1 -2
  58. package/lib/components/EntityManager/utils/entityAvailableActions.js.map +1 -1
  59. package/lib/components/EntityManager/utils/is-form-empty.js +1 -2
  60. package/lib/components/EntityManager/utils/is-form-empty.js.map +1 -1
  61. package/lib/components/EntityManager/utils/query.js +1 -2
  62. package/lib/components/EntityManager/utils/query.js.map +1 -1
  63. package/lib/components/InfoBoxes/InfoBoxes.js +35 -0
  64. package/lib/components/InfoBoxes/InfoBoxes.js.map +1 -0
  65. package/lib/components/InfoBoxes/container/InfoBoxContainer.js +43 -0
  66. package/lib/components/InfoBoxes/container/InfoBoxContainer.js.map +1 -0
  67. package/lib/components/InfoBoxes/helpers/build-dynamic-query.js +25 -0
  68. package/lib/components/InfoBoxes/helpers/build-dynamic-query.js.map +1 -0
  69. package/lib/components/InfoBoxes/hooks/useData.js +41 -0
  70. package/lib/components/InfoBoxes/hooks/useData.js.map +1 -0
  71. package/lib/components/InfoBoxes/hooks/useInfoBox.js +25 -0
  72. package/lib/components/InfoBoxes/hooks/useInfoBox.js.map +1 -0
  73. package/lib/components/InfoBoxes/index.js +11 -0
  74. package/lib/components/InfoBoxes/index.js.map +1 -0
  75. package/lib/components/InfoBoxes/presentational/InfoBox.js +45 -0
  76. package/lib/components/InfoBoxes/presentational/InfoBox.js.map +1 -0
  77. package/lib/components/ListingTable/ListingTable.js +127 -84
  78. package/lib/components/ListingTable/ListingTable.js.map +1 -1
  79. package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js +9 -22
  80. package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
  81. package/lib/components/ListingTable/ListingTableContent/index.js +1 -2
  82. package/lib/components/ListingTable/ListingTableContent/index.js.map +1 -1
  83. package/lib/components/ListingTable/TableActions/TableActions.js +1 -2
  84. package/lib/components/ListingTable/TableActions/TableActions.js.map +1 -1
  85. package/lib/components/ListingTable/TableActions/index.js +1 -2
  86. package/lib/components/ListingTable/TableActions/index.js.map +1 -1
  87. package/lib/components/ListingTable/index.js +1 -2
  88. package/lib/components/ListingTable/index.js.map +1 -1
  89. package/lib/components/ListingTable/mappers/populate-rows.js +92 -29
  90. package/lib/components/ListingTable/mappers/populate-rows.js.map +1 -1
  91. package/lib/components/ListingTable/service/index.js +74 -13
  92. package/lib/components/ListingTable/service/index.js.map +1 -1
  93. package/lib/components/Tabs/index.js +3 -4
  94. package/lib/components/Tabs/index.js.map +1 -1
  95. package/lib/constants.js +33 -49
  96. package/lib/constants.js.map +1 -1
  97. package/lib/icons/ContentIcon.js +90 -0
  98. package/lib/icons/ContentIcon.js.map +1 -0
  99. package/lib/icons/SettingsIcon.js +46 -0
  100. package/lib/icons/SettingsIcon.js.map +1 -0
  101. package/lib/icons/TaxonomyIcon.js +70 -0
  102. package/lib/icons/TaxonomyIcon.js.map +1 -0
  103. package/lib/icons/UsersIcon.js +43 -0
  104. package/lib/icons/UsersIcon.js.map +1 -0
  105. package/lib/icons/index.js +36 -0
  106. package/lib/icons/index.js.map +1 -0
  107. package/lib/index.js +40 -13
  108. package/lib/index.js.map +1 -1
  109. package/lib/utils/add-content-menu-items.js +62 -15
  110. package/lib/utils/add-content-menu-items.js.map +1 -1
  111. package/lib/utils/build-create-entity-mutation.js +1 -2
  112. package/lib/utils/build-create-entity-mutation.js.map +1 -1
  113. package/lib/utils/build-delete-entity-mutation.js +1 -2
  114. package/lib/utils/build-delete-entity-mutation.js.map +1 -1
  115. package/lib/utils/build-listing-query.js +12 -4
  116. package/lib/utils/build-listing-query.js.map +1 -1
  117. package/lib/utils/build-update-data-query.js +1 -2
  118. package/lib/utils/build-update-data-query.js.map +1 -1
  119. package/lib/utils/build-update-publish-unpublish-mutation.js +1 -2
  120. package/lib/utils/build-update-publish-unpublish-mutation.js.map +1 -1
  121. package/lib/utils/get-default-query-params.js +3 -5
  122. package/lib/utils/get-default-query-params.js.map +1 -1
  123. package/lib/utils/hoc/withContext.js +1 -2
  124. package/lib/utils/hoc/withContext.js.map +1 -1
  125. package/lib/utils/hooks/useToggle.js +1 -2
  126. package/lib/utils/hooks/useToggle.js.map +1 -1
  127. package/lib-es/components/EntityDataListing/EntityDataListing.js +3 -14
  128. package/lib-es/components/EntityDataListing/EntityDataListing.js.map +1 -1
  129. package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +30 -0
  130. package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js.map +1 -0
  131. package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/index.js +3 -0
  132. package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/index.js.map +1 -0
  133. package/lib-es/components/EntityManager/Entity/Entity.js +16 -3
  134. package/lib-es/components/EntityManager/Entity/Entity.js.map +1 -1
  135. package/lib-es/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +30 -0
  136. package/lib-es/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js.map +1 -0
  137. package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +26 -0
  138. package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +1 -0
  139. package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +39 -0
  140. package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +1 -0
  141. package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js +12 -2
  142. package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
  143. package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +24 -0
  144. package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +1 -0
  145. package/lib-es/components/InfoBoxes/InfoBoxes.js +28 -0
  146. package/lib-es/components/InfoBoxes/InfoBoxes.js.map +1 -0
  147. package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js +30 -0
  148. package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js.map +1 -0
  149. package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js +25 -0
  150. package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js.map +1 -0
  151. package/lib-es/components/InfoBoxes/hooks/useData.js +37 -0
  152. package/lib-es/components/InfoBoxes/hooks/useData.js.map +1 -0
  153. package/lib-es/components/InfoBoxes/hooks/useInfoBox.js +19 -0
  154. package/lib-es/components/InfoBoxes/hooks/useInfoBox.js.map +1 -0
  155. package/lib-es/components/InfoBoxes/index.js +3 -0
  156. package/lib-es/components/InfoBoxes/index.js.map +1 -0
  157. package/lib-es/components/InfoBoxes/presentational/InfoBox.js +31 -0
  158. package/lib-es/components/InfoBoxes/presentational/InfoBox.js.map +1 -0
  159. package/lib-es/components/ListingTable/ListingTable.js +56 -51
  160. package/lib-es/components/ListingTable/ListingTable.js.map +1 -1
  161. package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js +11 -19
  162. package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
  163. package/lib-es/components/ListingTable/mappers/populate-rows.js +76 -24
  164. package/lib-es/components/ListingTable/mappers/populate-rows.js.map +1 -1
  165. package/lib-es/components/ListingTable/service/index.js +65 -7
  166. package/lib-es/components/ListingTable/service/index.js.map +1 -1
  167. package/lib-es/constants.js +9 -1
  168. package/lib-es/constants.js.map +1 -1
  169. package/lib-es/icons/ContentIcon.js +80 -0
  170. package/lib-es/icons/ContentIcon.js.map +1 -0
  171. package/lib-es/icons/SettingsIcon.js +36 -0
  172. package/lib-es/icons/SettingsIcon.js.map +1 -0
  173. package/lib-es/icons/TaxonomyIcon.js +60 -0
  174. package/lib-es/icons/TaxonomyIcon.js.map +1 -0
  175. package/lib-es/icons/UsersIcon.js +33 -0
  176. package/lib-es/icons/UsersIcon.js.map +1 -0
  177. package/lib-es/icons/index.js +6 -0
  178. package/lib-es/icons/index.js.map +1 -0
  179. package/lib-es/index.js +37 -9
  180. package/lib-es/index.js.map +1 -1
  181. package/lib-es/utils/add-content-menu-items.js +46 -5
  182. package/lib-es/utils/add-content-menu-items.js.map +1 -1
  183. package/lib-es/utils/build-listing-query.js +10 -1
  184. package/lib-es/utils/build-listing-query.js.map +1 -1
  185. package/lib-es/utils/get-default-query-params.js +1 -3
  186. package/lib-es/utils/get-default-query-params.js.map +1 -1
  187. package/package.json +6 -5
  188. package/src/components/EntityDataListing/EntityDataListing.js +3 -12
  189. package/src/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +26 -0
  190. package/src/components/EntityManager/Entity/EntitiyNavLinks/index.js +3 -0
  191. package/src/components/EntityManager/Entity/Entity.js +10 -1
  192. package/src/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +22 -0
  193. package/src/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +33 -0
  194. package/src/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +28 -0
  195. package/src/components/EntityManager/Entity/SideBarRelations/index.js +34 -16
  196. package/src/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +33 -0
  197. package/src/components/InfoBoxes/InfoBoxes.js +24 -0
  198. package/src/components/InfoBoxes/container/InfoBoxContainer.js +22 -0
  199. package/src/components/InfoBoxes/helpers/build-dynamic-query.js +25 -0
  200. package/src/components/InfoBoxes/hooks/useData.js +20 -0
  201. package/src/components/InfoBoxes/hooks/useInfoBox.js +13 -0
  202. package/src/components/InfoBoxes/index.js +3 -0
  203. package/src/components/InfoBoxes/presentational/InfoBox.js +34 -0
  204. package/src/components/ListingTable/ListingTable.js +73 -39
  205. package/src/components/ListingTable/ListingTableContent/ListingTableContent.js +8 -22
  206. package/src/components/ListingTable/mappers/populate-rows.js +83 -18
  207. package/src/components/ListingTable/service/index.js +42 -5
  208. package/src/constants.js +13 -1
  209. package/src/icons/ContentIcon.js +83 -0
  210. package/src/icons/SettingsIcon.js +41 -0
  211. package/src/icons/TaxonomyIcon.js +62 -0
  212. package/src/icons/UsersIcon.js +37 -0
  213. package/src/icons/index.js +6 -0
  214. package/src/index.js +36 -8
  215. package/src/utils/add-content-menu-items.js +42 -3
  216. package/src/utils/build-listing-query.js +11 -1
  217. package/src/utils/get-default-query-params.js +1 -1
@@ -0,0 +1,39 @@
1
+ import ProptTypes from 'prop-types';
2
+ import { useQuery, gql } from '@apollo/client';
3
+ import buildDynamicQuery from '../helpers/build-dynamic-query';
4
+ const useCustomSidebarData = ({
5
+ id,
6
+ schema,
7
+ displayProperties
8
+ }) => {
9
+ const query = buildDynamicQuery({
10
+ id,
11
+ schema,
12
+ displayProperties
13
+ });
14
+ const customSidebarInfoQuery = query || gql`
15
+ query {
16
+ __typename
17
+ }
18
+ `;
19
+ const {
20
+ data = {},
21
+ loading,
22
+ error
23
+ } = useQuery(customSidebarInfoQuery, {
24
+ variables: {
25
+ id
26
+ },
27
+ skip: !query
28
+ });
29
+ return {
30
+ data: data.__typename !== 'Query' ? data : null,
31
+ loading,
32
+ error
33
+ };
34
+ };
35
+ export default useCustomSidebarData;
36
+ useCustomSidebarData.propTypes = {
37
+ displayProperties: ProptTypes.object.isRequired
38
+ };
39
+ //# sourceMappingURL=useCustomSidebarData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useCustomSidebarData.js","names":["ProptTypes","useQuery","gql","buildDynamicQuery","useCustomSidebarData","id","schema","displayProperties","query","customSidebarInfoQuery","data","loading","error","variables","skip","__typename","propTypes","object","isRequired"],"sources":["../../../../../../src/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js"],"sourcesContent":["import ProptTypes from 'prop-types';\nimport { useQuery, gql } from '@apollo/client';\nimport buildDynamicQuery from '../helpers/build-dynamic-query';\n\nconst useCustomSidebarData = ({ id, schema, displayProperties }) => {\n const query = buildDynamicQuery({ id, schema, displayProperties });\n\n const customSidebarInfoQuery =\n query ||\n gql`\n query {\n __typename\n }\n `;\n\n const { data = {}, loading, error } = useQuery(customSidebarInfoQuery, {\n variables: { id },\n skip: !query\n });\n\n return { data: data.__typename !== 'Query' ? data : null, loading, error };\n};\n\nexport default useCustomSidebarData;\n\nuseCustomSidebarData.propTypes = {\n displayProperties: ProptTypes.object.isRequired\n};\n"],"mappings":"AAAA,OAAOA,UAAU,MAAM,YAAY;AACnC,SAASC,QAAQ,EAAEC,GAAG,QAAQ,gBAAgB;AAC9C,OAAOC,iBAAiB,MAAM,gCAAgC;AAE9D,MAAMC,oBAAoB,GAAGA,CAAC;EAAEC,EAAE;EAAEC,MAAM;EAAEC;AAAkB,CAAC,KAAK;EAClE,MAAMC,KAAK,GAAGL,iBAAiB,CAAC;IAAEE,EAAE;IAAEC,MAAM;IAAEC;EAAkB,CAAC,CAAC;EAElE,MAAME,sBAAsB,GAC1BD,KAAK,IACLN,GAAI;AACR;AACA;AACA;AACA,KAAK;EAEH,MAAM;IAAEQ,IAAI,GAAG,CAAC,CAAC;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGX,QAAQ,CAACQ,sBAAsB,EAAE;IACrEI,SAAS,EAAE;MAAER;IAAG,CAAC;IACjBS,IAAI,EAAE,CAACN;EACT,CAAC,CAAC;EAEF,OAAO;IAAEE,IAAI,EAAEA,IAAI,CAACK,UAAU,KAAK,OAAO,GAAGL,IAAI,GAAG,IAAI;IAAEC,OAAO;IAAEC;EAAM,CAAC;AAC5E,CAAC;AAED,eAAeR,oBAAoB;AAEnCA,oBAAoB,CAACY,SAAS,GAAG;EAC/BT,iBAAiB,EAAEP,UAAU,CAACiB,MAAM,CAACC;AACvC,CAAC"}
@@ -7,6 +7,8 @@ import { formFieldTypes } from '@blaze-cms/react-form-builder';
7
7
  import classnames from 'classnames';
8
8
  import { VersionsList } from '@blaze-cms/versioning-ui';
9
9
  import { PUBLISHED, UNPUBLISHED } from '../../../../constants';
10
+ import CustomSidebarInfoContainer from './container/CustomSidebarInfoContainer';
11
+ import EntityNavLinks from '../EntitiyNavLinks';
10
12
  const SideBarRelations = ({
11
13
  schema,
12
14
  onChange,
@@ -72,16 +74,24 @@ const SideBarRelations = ({
72
74
  "data-testid": "sideBarRelations-main-div"
73
75
  }, /*#__PURE__*/React.createElement("div", {
74
76
  className: "sidebar__content"
75
- }, formattedCreated && /*#__PURE__*/React.createElement("div", {
77
+ }, /*#__PURE__*/React.createElement("div", {
76
78
  className: "sidebar__status"
79
+ }, formattedCreated && /*#__PURE__*/React.createElement("div", {
80
+ className: "sidebar__top"
77
81
  }, /*#__PURE__*/React.createElement("div", {
78
82
  className: "sidebar__status__wrapper"
79
83
  }, /*#__PURE__*/React.createElement("b", null, "Status"), /*#__PURE__*/React.createElement("span", {
80
84
  className: statusClassName
81
- }, formattedStatus)), formattedStatus === PUBLISHED && /*#__PURE__*/React.createElement("p", null, formattedStatus, " on: ", /*#__PURE__*/React.createElement("span", null, " ", formattedPublished)), /*#__PURE__*/React.createElement("p", null, "Created: ", /*#__PURE__*/React.createElement("span", null, formattedCreated)), /*#__PURE__*/React.createElement("p", null, "Updated: ", /*#__PURE__*/React.createElement("span", null, formattedUpdated))), /*#__PURE__*/React.createElement(VersionsList, {
85
+ }, formattedStatus)), formattedStatus === PUBLISHED && /*#__PURE__*/React.createElement("p", null, formattedStatus, " on: ", /*#__PURE__*/React.createElement("span", null, " ", formattedPublished))), !schema.displayProperties.adminMainInfoProperty && /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("p", null, "Created: ", /*#__PURE__*/React.createElement("span", null, formattedCreated)), /*#__PURE__*/React.createElement("p", null, "Updated: ", /*#__PURE__*/React.createElement("span", null, formattedUpdated))), /*#__PURE__*/React.createElement(CustomSidebarInfoContainer, {
86
+ id: itemId,
87
+ schema: schema,
88
+ displayProperties: schema.displayProperties
89
+ })), /*#__PURE__*/React.createElement(VersionsList, {
82
90
  itemEntity: itemEntity,
83
91
  itemId: itemId,
84
92
  interfaces: interfaces
93
+ }), /*#__PURE__*/React.createElement(EntityNavLinks, {
94
+ schema: schema
85
95
  }), relationsComponents && relationsComponents.map(({
86
96
  id,
87
97
  staticData,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","names":["React","useState","useEffect","PropTypes","uuidv1","useApolloClient","getQuery","formFieldTypes","classnames","VersionsList","PUBLISHED","UNPUBLISHED","SideBarRelations","schema","onChange","formData","entity","relation","RelationComponent","formattedStatus","formattedUpdated","formattedCreated","formattedPublished","status","client","relationsComponents","setRelationsComponents","fetchRelationSchema","entityIdentifier","data","getEntitySchemas","relationSchema","query","variables","identifier","allRelationComponents","Promise","all","relations","filter","showInForm","foreignKey","properties","map","id","staticData","itemId","itemEntity","interfaces","statusClassName","createElement","className","entitySchema","key","onSelect","propTypes","object","isRequired","func","defaultProps"],"sources":["../../../../../src/components/EntityManager/Entity/SideBarRelations/index.js"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport uuidv1 from 'uuid/v1';\nimport { useApolloClient } from '@apollo/client';\nimport { getQuery } from '@blaze-cms/admin-ui-utils';\nimport { formFieldTypes } from '@blaze-cms/react-form-builder';\nimport classnames from 'classnames';\nimport { VersionsList } from '@blaze-cms/versioning-ui';\nimport { PUBLISHED, UNPUBLISHED } from '../../../../constants';\n\nconst SideBarRelations = ({ schema, onChange, formData, entity }) => {\n const { relation: RelationComponent } = formFieldTypes;\n const {\n formattedStatus,\n formattedUpdated,\n formattedCreated,\n formattedPublished,\n status\n } = formData;\n const client = useApolloClient();\n const [relationsComponents, setRelationsComponents] = useState(null);\n useEffect(\n () => {\n (async () => {\n const fetchRelationSchema = async ({ entityIdentifier }) => {\n if (!entityIdentifier) return null;\n\n const {\n data: {\n getEntitySchemas: [relationSchema]\n }\n } = await client.query({\n query: getQuery('GET_ENTITY_SCHEMA'),\n variables: { identifier: entityIdentifier }\n });\n return relationSchema;\n };\n\n if (!relationsComponents && schema) {\n const allRelationComponents = await Promise.all(\n schema.relations\n .filter(({ showInForm, foreignKey }) => showInForm && schema.properties[foreignKey])\n .map(async relation => ({\n id: uuidv1(),\n staticData: relation,\n schema: await fetchRelationSchema(relation)\n }))\n );\n\n setRelationsComponents(allRelationComponents);\n }\n })();\n },\n [client, relationsComponents, schema, schema.relations]\n );\n const { id: itemId } = entity;\n const { identifier: itemEntity, interfaces } = schema;\n\n const statusClassName = classnames('sidebar__status__badge', {\n 'sidebar__status__badge--published': status === PUBLISHED,\n 'sidebar__status__badge--unpublished': status === UNPUBLISHED\n });\n\n return (\n <div className=\"sidebar\" data-testid=\"sideBarRelations-main-div\">\n <div className=\"sidebar__content\">\n {formattedCreated && (\n <div className=\"sidebar__status\">\n <div className=\"sidebar__status__wrapper\">\n <b>Status</b>\n <span className={statusClassName}>{formattedStatus}</span>\n </div>\n {formattedStatus === PUBLISHED && (\n <p>\n {formattedStatus} on: <span> {formattedPublished}</span>\n </p>\n )}\n\n <p>\n Created: <span>{formattedCreated}</span>\n </p>\n <p>\n Updated: <span>{formattedUpdated}</span>\n </p>\n </div>\n )}\n\n <VersionsList itemEntity={itemEntity} itemId={itemId} interfaces={interfaces} />\n {relationsComponents &&\n relationsComponents.map(({ id, staticData, schema: entitySchema }) => (\n <RelationComponent\n formData={formData}\n schema={entitySchema}\n key={id}\n staticData={staticData}\n onSelect={onChange}\n />\n ))}\n </div>\n </div>\n );\n};\n\nSideBarRelations.propTypes = {\n schema: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired,\n formData: PropTypes.object.isRequired,\n entity: PropTypes.object\n};\n\nSideBarRelations.defaultProps = {\n entity: {}\n};\n\nexport default SideBarRelations;\n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T,SAAS,iBAC5BV,KAAA,CAAAkD,aAAA,YACG/B,eAAe,EAAC,OAAK,eAAAnB,KAAA,CAAAkD,aAAA,eAAM,GAAC,EAAC5B,kBAAyB,CACtD,CACJ,eAEDtB,KAAA,CAAAkD,aAAA,YAAG,WACQ,eAAAlD,KAAA,CAAAkD,aAAA,eAAO7B,gBAAuB,CACtC,CAAC,eACJrB,KAAA,CAAAkD,aAAA,YAAG,WACQ,eAAAlD,KAAA,CAAAkD,aAAA,eAAO9B,gBAAuB,CACtC,CACA,CACN,eAEDpB,KAAA,CAAAkD,aAAA,CAACzC,YAAY;IAACsC,UAAU,EAAEA,UAAW;IAACD,MAAM,EAAEA,MAAO;IAACE,UAAU,EAAEA;EAAW,CAAE,CAAC,EAC/EvB,mBAAmB,IAClBA,mBAAmB,CAACkB,GAAG,CAAC,CAAC;IAAEC,EAAE;IAAEC,UAAU;IAAEhC,MAAM,EAAEuC;EAAa,CAAC,kBAC/DpD,KAAA,CAAAkD,aAAA,CAAChC,iBAAiB;IAChBH,QAAQ,EAAEA,QAAS;IACnBF,MAAM,EAAEuC,YAAa;IACrBC,GAAG,EAAET,EAAG;IACRC,UAAU,EAAEA,UAAW;IACvBS,QAAQ,EAAExC;EAAS,CACpB,CACF,CACA,CACF,CAAC;AAEV,CAAC;AAEDF,gBAAgB,CAAC2C,SAAS,GAAG;EAC3B1C,MAAM,EAAEV,SAAS,CAACqD,MAAM,CAACC,UAAU;EACnC3C,QAAQ,EAAEX,SAAS,CAACuD,IAAI,CAACD,UAAU;EACnC1C,QAAQ,EAAEZ,SAAS,CAACqD,MAAM,CAACC,UAAU;EACrCzC,MAAM,EAAEb,SAAS,CAACqD;AACpB,CAAC;AAED5C,gBAAgB,CAAC+C,YAAY,GAAG;EAC9B3C,MAAM,EAAE,CAAC;AACX,CAAC;AAED,eAAeJ,gBAAgB"}
1
+ {"version":3,"file":"index.js","names":["React","useState","useEffect","PropTypes","uuidv1","useApolloClient","getQuery","formFieldTypes","classnames","VersionsList","PUBLISHED","UNPUBLISHED","CustomSidebarInfoContainer","EntityNavLinks","SideBarRelations","schema","onChange","formData","entity","relation","RelationComponent","formattedStatus","formattedUpdated","formattedCreated","formattedPublished","status","client","relationsComponents","setRelationsComponents","fetchRelationSchema","entityIdentifier","data","getEntitySchemas","relationSchema","query","variables","identifier","allRelationComponents","Promise","all","relations","filter","showInForm","foreignKey","properties","map","id","staticData","itemId","itemEntity","interfaces","statusClassName","createElement","className","displayProperties","adminMainInfoProperty","Fragment","entitySchema","key","onSelect","propTypes","object","isRequired","func","defaultProps"],"sources":["../../../../../src/components/EntityManager/Entity/SideBarRelations/index.js"],"sourcesContent":["import React, { useState, useEffect } from 'react';\nimport PropTypes from 'prop-types';\nimport uuidv1 from 'uuid/v1';\nimport { useApolloClient } from '@apollo/client';\nimport { getQuery } from '@blaze-cms/admin-ui-utils';\nimport { formFieldTypes } from '@blaze-cms/react-form-builder';\nimport classnames from 'classnames';\nimport { VersionsList } from '@blaze-cms/versioning-ui';\nimport { PUBLISHED, UNPUBLISHED } from '../../../../constants';\nimport CustomSidebarInfoContainer from './container/CustomSidebarInfoContainer';\nimport EntityNavLinks from '../EntitiyNavLinks';\n\nconst SideBarRelations = ({ schema, onChange, formData, entity }) => {\n const { relation: RelationComponent } = formFieldTypes;\n const {\n formattedStatus,\n formattedUpdated,\n formattedCreated,\n formattedPublished,\n status\n } = formData;\n const client = useApolloClient();\n\n const [relationsComponents, setRelationsComponents] = useState(null);\n\n useEffect(\n () => {\n (async () => {\n const fetchRelationSchema = async ({ entityIdentifier }) => {\n if (!entityIdentifier) return null;\n\n const {\n data: {\n getEntitySchemas: [relationSchema]\n }\n } = await client.query({\n query: getQuery('GET_ENTITY_SCHEMA'),\n variables: { identifier: entityIdentifier }\n });\n return relationSchema;\n };\n\n if (!relationsComponents && schema) {\n const allRelationComponents = await Promise.all(\n schema.relations\n .filter(({ showInForm, foreignKey }) => showInForm && schema.properties[foreignKey])\n .map(async relation => ({\n id: uuidv1(),\n staticData: relation,\n schema: await fetchRelationSchema(relation)\n }))\n );\n\n setRelationsComponents(allRelationComponents);\n }\n })();\n },\n [client, relationsComponents, schema, schema.relations]\n );\n const { id: itemId } = entity;\n const { identifier: itemEntity, interfaces } = schema;\n\n const statusClassName = classnames('sidebar__status__badge', {\n 'sidebar__status__badge--published': status === PUBLISHED,\n 'sidebar__status__badge--unpublished': status === UNPUBLISHED\n });\n\n return (\n <div className=\"sidebar\" data-testid=\"sideBarRelations-main-div\">\n <div className=\"sidebar__content\">\n <div className=\"sidebar__status\">\n {formattedCreated && (\n <div className=\"sidebar__top\">\n <div className=\"sidebar__status__wrapper\">\n <b>Status</b>\n <span className={statusClassName}>{formattedStatus}</span>\n </div>\n {formattedStatus === PUBLISHED && (\n <p>\n {formattedStatus} on: <span> {formattedPublished}</span>\n </p>\n )}\n </div>\n )}\n\n {!schema.displayProperties.adminMainInfoProperty && (\n <>\n <p>\n Created: <span>{formattedCreated}</span>\n </p>\n <p>\n Updated: <span>{formattedUpdated}</span>\n </p>\n </>\n )}\n\n <CustomSidebarInfoContainer\n id={itemId}\n schema={schema}\n displayProperties={schema.displayProperties}\n />\n </div>\n\n <VersionsList itemEntity={itemEntity} itemId={itemId} interfaces={interfaces} />\n <EntityNavLinks schema={schema} />\n\n {relationsComponents &&\n relationsComponents.map(({ id, staticData, schema: entitySchema }) => (\n <RelationComponent\n formData={formData}\n schema={entitySchema}\n key={id}\n staticData={staticData}\n onSelect={onChange}\n />\n ))}\n </div>\n </div>\n );\n};\n\nSideBarRelations.propTypes = {\n schema: PropTypes.object.isRequired,\n onChange: PropTypes.func.isRequired,\n formData: PropTypes.object.isRequired,\n entity: PropTypes.object\n};\n\nSideBarRelations.defaultProps = {\n entity: {}\n};\n\nexport default SideBarRelations;\n"],"mappings":"AAAA,OAAOA,KAAK,IAAIC,QAAQ,EAAEC,SAAS,QAAQ,OAAO;AAClD,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,MAAM,MAAM,SAAS;A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AM,CAACC,UAAU;EACnC9C,QAAQ,EAAEb,SAAS,CAAC4D,IAAI,CAACD,UAAU;EACnC7C,QAAQ,EAAEd,SAAS,CAAC0D,MAAM,CAACC,UAAU;EACrC5C,MAAM,EAAEf,SAAS,CAAC0D;AACpB,CAAC;AAED/C,gBAAgB,CAACkD,YAAY,GAAG;EAC9B9C,MAAM,EAAE,CAAC;AACX,CAAC;AAED,eAAeJ,gBAAgB"}
@@ -0,0 +1,24 @@
1
+ import PropTypes from 'prop-types';
2
+ import React from 'react';
3
+ const CustomSidebarInfo = ({
4
+ items,
5
+ customSidebarInfoKey
6
+ }) => {
7
+ if (!items) return null;
8
+ const customSidebarInfoItems = items.map(item => Object.values(item).map(info => {
9
+ if (!info.label || !info.value) return null;
10
+ return /*#__PURE__*/React.createElement("p", null, info.label, ": ", /*#__PURE__*/React.createElement("span", null, info.value));
11
+ }).filter(Boolean));
12
+ return /*#__PURE__*/React.createElement("div", {
13
+ className: "custom-sidebar-info",
14
+ key: customSidebarInfoKey
15
+ }, /*#__PURE__*/React.createElement("div", {
16
+ className: "custom-sidebar-info--container"
17
+ }, customSidebarInfoItems));
18
+ };
19
+ export default CustomSidebarInfo;
20
+ CustomSidebarInfo.propTypes = {
21
+ customSidebarInfoKey: PropTypes.string.isRequired,
22
+ items: PropTypes.array.isRequired
23
+ };
24
+ //# sourceMappingURL=CustomSidebarInfo.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CustomSidebarInfo.js","names":["PropTypes","React","CustomSidebarInfo","items","customSidebarInfoKey","customSidebarInfoItems","map","item","Object","values","info","label","value","createElement","filter","Boolean","className","key","propTypes","string","isRequired","array"],"sources":["../../../../../../src/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\n\nconst CustomSidebarInfo = ({ items, customSidebarInfoKey }) => {\n if (!items) return null;\n\n const customSidebarInfoItems = items.map(item =>\n Object.values(item)\n .map(info => {\n if (!info.label || !info.value) return null;\n\n return (\n <p>\n {info.label}: <span>{info.value}</span>\n </p>\n );\n })\n .filter(Boolean)\n );\n\n return (\n <div className=\"custom-sidebar-info\" key={customSidebarInfoKey}>\n <div className=\"custom-sidebar-info--container\">{customSidebarInfoItems}</div>\n </div>\n );\n};\n\nexport default CustomSidebarInfo;\n\nCustomSidebarInfo.propTypes = {\n customSidebarInfoKey: PropTypes.string.isRequired,\n items: PropTypes.array.isRequired\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,YAAY;AAClC,OAAOC,KAAK,MAAM,OAAO;AAEzB,MAAMC,iBAAiB,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAqB,CAAC,KAAK;EAC7D,IAAI,CAACD,KAAK,EAAE,OAAO,IAAI;EAEvB,MAAME,sBAAsB,GAAGF,KAAK,CAACG,GAAG,CAACC,IAAI,IAC3CC,MAAM,CAACC,MAAM,CAACF,IAAI,CAAC,CAChBD,GAAG,CAACI,IAAI,IAAI;IACX,IAAI,CAACA,IAAI,CAACC,KAAK,IAAI,CAACD,IAAI,CAACE,KAAK,EAAE,OAAO,IAAI;IAE3C,oBACEX,KAAA,CAAAY,aAAA,YACGH,IAAI,CAACC,KAAK,EAAC,IAAE,eAAAV,KAAA,CAAAY,aAAA,eAAOH,IAAI,CAACE,KAAY,CACrC,CAAC;EAER,CAAC,CAAC,CACDE,MAAM,CAACC,OAAO,CACnB,CAAC;EAED,oBACEd,KAAA,CAAAY,aAAA;IAAKG,SAAS,EAAC,qBAAqB;IAACC,GAAG,EAAEb;EAAqB,gBAC7DH,KAAA,CAAAY,aAAA;IAAKG,SAAS,EAAC;EAAgC,GAAEX,sBAA4B,CAC1E,CAAC;AAEV,CAAC;AAED,eAAeH,iBAAiB;AAEhCA,iBAAiB,CAACgB,SAAS,GAAG;EAC5Bd,oBAAoB,EAAEJ,SAAS,CAACmB,MAAM,CAACC,UAAU;EACjDjB,KAAK,EAAEH,SAAS,CAACqB,KAAK,CAACD;AACzB,CAAC"}
@@ -0,0 +1,28 @@
1
+ import PropTypes from 'prop-types';
2
+ import React from 'react';
3
+ import InfoBoxContainer from './container/InfoBoxContainer';
4
+ const InfoBoxes = ({
5
+ id,
6
+ schema
7
+ }) => {
8
+ const {
9
+ displayProperties: {
10
+ adminInfoBoxes = []
11
+ }
12
+ } = schema;
13
+ if (adminInfoBoxes.length <= 0) {
14
+ return null;
15
+ }
16
+ return adminInfoBoxes.map(infoBox => /*#__PURE__*/React.createElement(InfoBoxContainer, {
17
+ id: id,
18
+ schema: schema,
19
+ key: infoBox.key,
20
+ infoBox: infoBox
21
+ }));
22
+ };
23
+ export default InfoBoxes;
24
+ InfoBoxes.propTypes = {
25
+ id: PropTypes.string.isRequired,
26
+ schema: PropTypes.object.isRequired
27
+ };
28
+ //# sourceMappingURL=InfoBoxes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InfoBoxes.js","names":["PropTypes","React","InfoBoxContainer","InfoBoxes","id","schema","displayProperties","adminInfoBoxes","length","map","infoBox","createElement","key","propTypes","string","isRequired","object"],"sources":["../../../src/components/InfoBoxes/InfoBoxes.js"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\nimport InfoBoxContainer from './container/InfoBoxContainer';\n\nconst InfoBoxes = ({ id, schema }) => {\n const {\n displayProperties: { adminInfoBoxes = [] }\n } = schema;\n\n if (adminInfoBoxes.length <= 0) {\n return null;\n }\n\n return adminInfoBoxes.map(infoBox => (\n <InfoBoxContainer id={id} schema={schema} key={infoBox.key} infoBox={infoBox} />\n ));\n};\n\nexport default InfoBoxes;\n\nInfoBoxes.propTypes = {\n id: PropTypes.string.isRequired,\n schema: PropTypes.object.isRequired\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,YAAY;AAClC,OAAOC,KAAK,MAAM,OAAO;AACzB,OAAOC,gBAAgB,MAAM,8BAA8B;AAE3D,MAAMC,SAAS,GAAGA,CAAC;EAAEC,EAAE;EAAEC;AAAO,CAAC,KAAK;EACpC,MAAM;IACJC,iBAAiB,EAAE;MAAEC,cAAc,GAAG;IAAG;EAC3C,CAAC,GAAGF,MAAM;EAEV,IAAIE,cAAc,CAACC,MAAM,IAAI,CAAC,EAAE;IAC9B,OAAO,IAAI;EACb;EAEA,OAAOD,cAAc,CAACE,GAAG,CAACC,OAAO,iBAC/BT,KAAA,CAAAU,aAAA,CAACT,gBAAgB;IAACE,EAAE,EAAEA,EAAG;IAACC,MAAM,EAAEA,MAAO;IAACO,GAAG,EAAEF,OAAO,CAACE,GAAI;IAACF,OAAO,EAAEA;EAAQ,CAAE,CAChF,CAAC;AACJ,CAAC;AAED,eAAeP,SAAS;AAExBA,SAAS,CAACU,SAAS,GAAG;EACpBT,EAAE,EAAEJ,SAAS,CAACc,MAAM,CAACC,UAAU;EAC/BV,MAAM,EAAEL,SAAS,CAACgB,MAAM,CAACD;AAC3B,CAAC"}
@@ -0,0 +1,30 @@
1
+ import PropTypes from 'prop-types';
2
+ import React from 'react';
3
+ import useData from '../hooks/useData';
4
+ import InfoBox from '../presentational/InfoBox';
5
+ const InfoBoxContainer = ({
6
+ id,
7
+ schema,
8
+ infoBox
9
+ }) => {
10
+ const {
11
+ data
12
+ } = useData({
13
+ id,
14
+ schema,
15
+ infoBox
16
+ });
17
+ if (!data || !Object.keys(data) || Object.keys(data).length === 0) return null;
18
+ const items = Object.values(data).flatMap(item => Object.values(item));
19
+ return /*#__PURE__*/React.createElement(InfoBox, {
20
+ items: items,
21
+ infoBoxKey: infoBox.key
22
+ });
23
+ };
24
+ export default InfoBoxContainer;
25
+ InfoBoxContainer.propTypes = {
26
+ id: PropTypes.string.isRequired,
27
+ infoBox: PropTypes.object.isRequired,
28
+ schema: PropTypes.object.isRequired
29
+ };
30
+ //# sourceMappingURL=InfoBoxContainer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InfoBoxContainer.js","names":["PropTypes","React","useData","InfoBox","InfoBoxContainer","id","schema","infoBox","data","Object","keys","length","items","values","flatMap","item","createElement","infoBoxKey","key","propTypes","string","isRequired","object"],"sources":["../../../../src/components/InfoBoxes/container/InfoBoxContainer.js"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\nimport useData from '../hooks/useData';\nimport InfoBox from '../presentational/InfoBox';\n\nconst InfoBoxContainer = ({ id, schema, infoBox }) => {\n const { data } = useData({ id, schema, infoBox });\n\n if (!data || !Object.keys(data) || Object.keys(data).length === 0) return null;\n\n const items = Object.values(data).flatMap(item => Object.values(item));\n\n return <InfoBox items={items} infoBoxKey={infoBox.key} />;\n};\n\nexport default InfoBoxContainer;\n\nInfoBoxContainer.propTypes = {\n id: PropTypes.string.isRequired,\n infoBox: PropTypes.object.isRequired,\n schema: PropTypes.object.isRequired\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,YAAY;AAClC,OAAOC,KAAK,MAAM,OAAO;AACzB,OAAOC,OAAO,MAAM,kBAAkB;AACtC,OAAOC,OAAO,MAAM,2BAA2B;AAE/C,MAAMC,gBAAgB,GAAGA,CAAC;EAAEC,EAAE;EAAEC,MAAM;EAAEC;AAAQ,CAAC,KAAK;EACpD,MAAM;IAAEC;EAAK,CAAC,GAAGN,OAAO,CAAC;IAAEG,EAAE;IAAEC,MAAM;IAAEC;EAAQ,CAAC,CAAC;EAEjD,IAAI,CAACC,IAAI,IAAI,CAACC,MAAM,CAACC,IAAI,CAACF,IAAI,CAAC,IAAIC,MAAM,CAACC,IAAI,CAACF,IAAI,CAAC,CAACG,MAAM,KAAK,CAAC,EAAE,OAAO,IAAI;EAE9E,MAAMC,KAAK,GAAGH,MAAM,CAACI,MAAM,CAACL,IAAI,CAAC,CAACM,OAAO,CAACC,IAAI,IAAIN,MAAM,CAACI,MAAM,CAACE,IAAI,CAAC,CAAC;EAEtE,oBAAOd,KAAA,CAAAe,aAAA,CAACb,OAAO;IAACS,KAAK,EAAEA,KAAM;IAACK,UAAU,EAAEV,OAAO,CAACW;EAAI,CAAE,CAAC;AAC3D,CAAC;AAED,eAAed,gBAAgB;AAE/BA,gBAAgB,CAACe,SAAS,GAAG;EAC3Bd,EAAE,EAAEL,SAAS,CAACoB,MAAM,CAACC,UAAU;EAC/Bd,OAAO,EAAEP,SAAS,CAACsB,MAAM,CAACD,UAAU;EACpCf,MAAM,EAAEN,SAAS,CAACsB,MAAM,CAACD;AAC3B,CAAC"}
@@ -0,0 +1,25 @@
1
+ import { gql } from '@apollo/client';
2
+ import { BlazeError } from '@blaze-cms/core-errors';
3
+ export default function buildDynamicQuery({
4
+ id,
5
+ schema,
6
+ infoBox
7
+ }) {
8
+ if (!schema || !schema.actions || !schema.actions.get || !schema.properties) {
9
+ throw new BlazeError('DataEntity query requires get action, properties and fields from entity schema');
10
+ }
11
+ const fields = `${infoBox.property} {
12
+ label
13
+ value
14
+ }`;
15
+ return {
16
+ query: gql`query getInfoBoxData($id: String!){
17
+ ${schema.actions.get}( id: $id ) {
18
+ id
19
+ ${fields}
20
+ __typename
21
+ }
22
+ }`
23
+ };
24
+ }
25
+ //# sourceMappingURL=build-dynamic-query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"build-dynamic-query.js","names":["gql","BlazeError","buildDynamicQuery","id","schema","infoBox","actions","get","properties","fields","property","query"],"sources":["../../../../src/components/InfoBoxes/helpers/build-dynamic-query.js"],"sourcesContent":["import { gql } from '@apollo/client';\nimport { BlazeError } from '@blaze-cms/core-errors';\n\nexport default function buildDynamicQuery({ id, schema, infoBox }) {\n if (!schema || !schema.actions || !schema.actions.get || !schema.properties) {\n throw new BlazeError(\n 'DataEntity query requires get action, properties and fields from entity schema'\n );\n }\n\n const fields = `${infoBox.property} {\n label\n value\n }`;\n\n return {\n query: gql`query getInfoBoxData($id: String!){\n ${schema.actions.get}( id: $id ) {\n id\n ${fields}\n __typename\n }\n }`\n };\n}\n"],"mappings":"AAAA,SAASA,GAAG,QAAQ,gBAAgB;AACpC,SAASC,UAAU,QAAQ,wBAAwB;AAEnD,eAAe,SAASC,iBAAiBA,CAAC;EAAEC,EAAE;EAAEC,MAAM;EAAEC;AAAQ,CAAC,EAAE;EACjE,IAAI,CAACD,MAAM,IAAI,CAACA,MAAM,CAACE,OAAO,IAAI,CAACF,MAAM,CAACE,OAAO,CAACC,GAAG,IAAI,CAACH,MAAM,CAACI,UAAU,EAAE;IAC3E,MAAM,IAAIP,UAAU,CAClB,gFACF,CAAC;EACH;EAEA,MAAMQ,MAAM,GAAI,GAAEJ,OAAO,CAACK,QAAS;AACrC;AACA;AACA,MAAM;EAEJ,OAAO;IACLC,KAAK,EAAEX,GAAI;AACf,MAAMI,MAAM,CAACE,OAAO,CAACC,GAAI;AACzB;AACA,OAAOE,MAAO;AACd;AACA;AACA;EACE,CAAC;AACH"}
@@ -0,0 +1,37 @@
1
+ import { useQuery, gql } from '@apollo/client';
2
+ import useInfoBoxData from './useInfoBox';
3
+ function useData({
4
+ id,
5
+ schema,
6
+ infoBox
7
+ }) {
8
+ const {
9
+ query
10
+ } = useInfoBoxData({
11
+ id,
12
+ schema,
13
+ infoBox
14
+ });
15
+ const infoBoxQuery = query || gql`
16
+ query {
17
+ __typename
18
+ }
19
+ `;
20
+ const {
21
+ data = {},
22
+ loading,
23
+ error
24
+ } = useQuery(infoBoxQuery, {
25
+ variables: {
26
+ id
27
+ },
28
+ skip: !query
29
+ });
30
+ return {
31
+ data: data.__typename !== 'Query' ? data : null,
32
+ loading,
33
+ error
34
+ };
35
+ }
36
+ export default useData;
37
+ //# sourceMappingURL=useData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useData.js","names":["useQuery","gql","useInfoBoxData","useData","id","schema","infoBox","query","infoBoxQuery","data","loading","error","variables","skip","__typename"],"sources":["../../../../src/components/InfoBoxes/hooks/useData.js"],"sourcesContent":["import { useQuery, gql } from '@apollo/client';\nimport useInfoBoxData from './useInfoBox';\n\nfunction useData({ id, schema, infoBox }) {\n const { query } = useInfoBoxData({ id, schema, infoBox });\n\n const infoBoxQuery =\n query ||\n gql`\n query {\n __typename\n }\n `;\n\n const { data = {}, loading, error } = useQuery(infoBoxQuery, { variables: { id }, skip: !query });\n\n return { data: data.__typename !== 'Query' ? data : null, loading, error };\n}\n\nexport default useData;\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,GAAG,QAAQ,gBAAgB;AAC9C,OAAOC,cAAc,MAAM,cAAc;AAEzC,SAASC,OAAOA,CAAC;EAAEC,EAAE;EAAEC,MAAM;EAAEC;AAAQ,CAAC,EAAE;EACxC,MAAM;IAAEC;EAAM,CAAC,GAAGL,cAAc,CAAC;IAAEE,EAAE;IAAEC,MAAM;IAAEC;EAAQ,CAAC,CAAC;EAEzD,MAAME,YAAY,GAChBD,KAAK,IACLN,GAAI;AACR;AACA;AACA;AACA,KAAK;EAEH,MAAM;IAAEQ,IAAI,GAAG,CAAC,CAAC;IAAEC,OAAO;IAAEC;EAAM,CAAC,GAAGX,QAAQ,CAACQ,YAAY,EAAE;IAAEI,SAAS,EAAE;MAAER;IAAG,CAAC;IAAES,IAAI,EAAE,CAACN;EAAM,CAAC,CAAC;EAEjG,OAAO;IAAEE,IAAI,EAAEA,IAAI,CAACK,UAAU,KAAK,OAAO,GAAGL,IAAI,GAAG,IAAI;IAAEC,OAAO;IAAEC;EAAM,CAAC;AAC5E;AAEA,eAAeR,OAAO"}
@@ -0,0 +1,19 @@
1
+ import buildDynamicQuery from '../helpers/build-dynamic-query';
2
+ function useInfoBox({
3
+ id,
4
+ schema,
5
+ infoBox
6
+ }) {
7
+ const {
8
+ query
9
+ } = buildDynamicQuery({
10
+ id,
11
+ schema,
12
+ infoBox
13
+ });
14
+ return {
15
+ query: query || null
16
+ };
17
+ }
18
+ export default useInfoBox;
19
+ //# sourceMappingURL=useInfoBox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useInfoBox.js","names":["buildDynamicQuery","useInfoBox","id","schema","infoBox","query"],"sources":["../../../../src/components/InfoBoxes/hooks/useInfoBox.js"],"sourcesContent":["import buildDynamicQuery from '../helpers/build-dynamic-query';\n\nfunction useInfoBox({ id, schema, infoBox }) {\n const { query } = buildDynamicQuery({\n id,\n schema,\n infoBox\n });\n\n return { query: query || null };\n}\n\nexport default useInfoBox;\n"],"mappings":"AAAA,OAAOA,iBAAiB,MAAM,gCAAgC;AAE9D,SAASC,UAAUA,CAAC;EAAEC,EAAE;EAAEC,MAAM;EAAEC;AAAQ,CAAC,EAAE;EAC3C,MAAM;IAAEC;EAAM,CAAC,GAAGL,iBAAiB,CAAC;IAClCE,EAAE;IACFC,MAAM;IACNC;EACF,CAAC,CAAC;EAEF,OAAO;IAAEC,KAAK,EAAEA,KAAK,IAAI;EAAK,CAAC;AACjC;AAEA,eAAeJ,UAAU"}
@@ -0,0 +1,3 @@
1
+ import InfoBoxes from './InfoBoxes';
2
+ export default InfoBoxes;
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["InfoBoxes"],"sources":["../../../src/components/InfoBoxes/index.js"],"sourcesContent":["import InfoBoxes from './InfoBoxes';\n\nexport default InfoBoxes;\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,aAAa;AAEnC,eAAeA,SAAS"}
@@ -0,0 +1,31 @@
1
+ import PropTypes from 'prop-types';
2
+ import React from 'react';
3
+ const InfoBox = ({
4
+ items,
5
+ infoBoxKey
6
+ }) => {
7
+ if (!items) return null;
8
+ const infoBoxItems = items.map(item => Object.values(item).map(info => {
9
+ if (!info.label || !info.value) return null;
10
+ return /*#__PURE__*/React.createElement("div", {
11
+ className: "info-box--item",
12
+ key: `${infoBoxKey}-${info.label.toLowerCase()}`
13
+ }, /*#__PURE__*/React.createElement("div", {
14
+ className: "info-box--label"
15
+ }, info.label, ": "), /*#__PURE__*/React.createElement("div", {
16
+ className: "info-box--value"
17
+ }, info.value));
18
+ }).filter(Boolean));
19
+ return /*#__PURE__*/React.createElement("div", {
20
+ className: "info-box",
21
+ key: infoBoxKey
22
+ }, /*#__PURE__*/React.createElement("div", {
23
+ className: "info-box--container"
24
+ }, infoBoxItems));
25
+ };
26
+ export default InfoBox;
27
+ InfoBox.propTypes = {
28
+ infoBoxKey: PropTypes.string.isRequired,
29
+ items: PropTypes.array.isRequired
30
+ };
31
+ //# sourceMappingURL=InfoBox.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InfoBox.js","names":["PropTypes","React","InfoBox","items","infoBoxKey","infoBoxItems","map","item","Object","values","info","label","value","createElement","className","key","toLowerCase","filter","Boolean","propTypes","string","isRequired","array"],"sources":["../../../../src/components/InfoBoxes/presentational/InfoBox.js"],"sourcesContent":["import PropTypes from 'prop-types';\nimport React from 'react';\n\nconst InfoBox = ({ items, infoBoxKey }) => {\n if (!items) return null;\n\n const infoBoxItems = items.map(item =>\n Object.values(item)\n .map(info => {\n if (!info.label || !info.value) return null;\n\n return (\n <div className=\"info-box--item\" key={`${infoBoxKey}-${info.label.toLowerCase()}`}>\n <div className=\"info-box--label\">{info.label}: </div>\n <div className=\"info-box--value\">{info.value}</div>\n </div>\n );\n })\n .filter(Boolean)\n );\n\n return (\n <div className=\"info-box\" key={infoBoxKey}>\n <div className=\"info-box--container\">{infoBoxItems}</div>\n </div>\n );\n};\n\nexport default InfoBox;\n\nInfoBox.propTypes = {\n infoBoxKey: PropTypes.string.isRequired,\n items: PropTypes.array.isRequired\n};\n"],"mappings":"AAAA,OAAOA,SAAS,MAAM,YAAY;AAClC,OAAOC,KAAK,MAAM,OAAO;AAEzB,MAAMC,OAAO,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAW,CAAC,KAAK;EACzC,IAAI,CAACD,KAAK,EAAE,OAAO,IAAI;EAEvB,MAAME,YAAY,GAAGF,KAAK,CAACG,GAAG,CAACC,IAAI,IACjCC,MAAM,CAACC,MAAM,CAACF,IAAI,CAAC,CAChBD,GAAG,CAACI,IAAI,IAAI;IACX,IAAI,CAACA,IAAI,CAACC,KAAK,IAAI,CAACD,IAAI,CAACE,KAAK,EAAE,OAAO,IAAI;IAE3C,oBACEX,KAAA,CAAAY,aAAA;MAAKC,SAAS,EAAC,gBAAgB;MAACC,GAAG,EAAG,GAAEX,UAAW,IAAGM,IAAI,CAACC,KAAK,CAACK,WAAW,CAAC,CAAE;IAAE,gBAC/Ef,KAAA,CAAAY,aAAA;MAAKC,SAAS,EAAC;IAAiB,GAAEJ,IAAI,CAACC,KAAK,EAAC,IAAO,CAAC,eACrDV,KAAA,CAAAY,aAAA;MAAKC,SAAS,EAAC;IAAiB,GAAEJ,IAAI,CAACE,KAAW,CAC/C,CAAC;EAEV,CAAC,CAAC,CACDK,MAAM,CAACC,OAAO,CACnB,CAAC;EAED,oBACEjB,KAAA,CAAAY,aAAA;IAAKC,SAAS,EAAC,UAAU;IAACC,GAAG,EAAEX;EAAW,gBACxCH,KAAA,CAAAY,aAAA;IAAKC,SAAS,EAAC;EAAqB,GAAET,YAAkB,CACrD,CAAC;AAEV,CAAC;AAED,eAAeH,OAAO;AAEtBA,OAAO,CAACiB,SAAS,GAAG;EAClBf,UAAU,EAAEJ,SAAS,CAACoB,MAAM,CAACC,UAAU;EACvClB,KAAK,EAAEH,SAAS,CAACsB,KAAK,CAACD;AACzB,CAAC"}
@@ -6,19 +6,18 @@ 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';
10
- import { PageHeader, DeleteAction } from '@blaze-cms/admin';
9
+ import { PageHeader, DeleteAction, CardPrompt } from '@blaze-cms/admin';
11
10
  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 } from './mappers/populate-rows';
15
+ import { populateRows, formatRows, getParsedRowData } 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,
21
- selectedMenuItem
20
+ entitySchema
22
21
  }) => {
23
22
  const [tableData, setTableData] = useState({});
24
23
  const [modalStatus, setModalStatus] = useState(false);
@@ -28,14 +27,10 @@ const ListingTable = ({
28
27
  });
29
28
  const [scrollToIndex, setScrollToIndex] = useState(0);
30
29
  const [verifiedRanges, setVerifiedRanges] = useState([]);
31
- const queryParamsDefault = getDefaultQueryParams({
32
- schema: entitySchema
33
- });
30
+ const queryParamsDefault = getDefaultQueryParams(entitySchema);
34
31
  const [queryParams, setQueryParams] = useState(queryParamsDefault);
35
- const {
36
- menuItems,
37
- setMenuItems
38
- } = useMainContext(MainContext);
32
+ const [listFilters, setListFilters] = useState([]);
33
+ const [displayCardPrompt, setDisplayCardPrompt] = useState(true);
39
34
  const client = useApolloClient();
40
35
  const {
41
36
  addToast
@@ -43,20 +38,7 @@ const ListingTable = ({
43
38
  useEffect(() => {
44
39
  (async () => {
45
40
  if (entitySchema.id !== previousSchema.id || previousSchema.id === null && entitySchema.id) {
46
- const data = await fetchData({
47
- client,
48
- querySettings: {
49
- entitySchema,
50
- queryParams: queryParamsDefault
51
- }
52
- });
53
- const populatedTable = populateRows({
54
- toggleModal,
55
- url: match.url,
56
- entitySchema,
57
- rows: data
58
- });
59
- setTableData(populatedTable);
41
+ await doQuery();
60
42
  setPreviousSchema({
61
43
  id: entitySchema.id
62
44
  });
@@ -64,21 +46,28 @@ const ListingTable = ({
64
46
  })();
65
47
  }, [client, entitySchema, match.url, previousSchema.id, queryParams] // eslint-disable-line react-hooks/exhaustive-deps
66
48
  );
67
-
68
- const onCloseCardPrompt = () => {
69
- const updatedSelectedMenuItem = _objectSpread(_objectSpread({}, selectedMenuItem), {}, {
70
- isDisplayedPrompt: false
49
+ const doQuery = async (filters = listFilters) => {
50
+ const data = await fetchData({
51
+ client,
52
+ querySettings: {
53
+ entitySchema,
54
+ queryParams: queryParamsDefault
55
+ },
56
+ listFilters: filters
57
+ });
58
+ const populatedTable = populateRows({
59
+ toggleModal,
60
+ url: match.url,
61
+ entitySchema,
62
+ rows: data
71
63
  });
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
- }]);
64
+ setTableData(populatedTable);
65
+ };
66
+ const updateListingFilters = async filters => {
67
+ await doQuery(filters);
68
+ setListFilters(filters);
81
69
  };
70
+ const onCloseCardPrompt = () => null;
82
71
  const toggleModal = item => {
83
72
  setModalStatus(!!item);
84
73
  setItemToDelete(item || {});
@@ -115,10 +104,12 @@ const ListingTable = ({
115
104
  querySettings: {
116
105
  entitySchema,
117
106
  queryParams: sortQueryParams
118
- }
107
+ },
108
+ listFilters
119
109
  });
120
110
  const {
121
- columns
111
+ columns,
112
+ isEnquiry
122
113
  } = tableData;
123
114
  const [firstColumn] = columns;
124
115
  setTableData(_objectSpread(_objectSpread({}, tableData), {}, {
@@ -126,10 +117,11 @@ const ListingTable = ({
126
117
  [property]: direction
127
118
  },
128
119
  rows: formatRows({
129
- rows: data,
120
+ rows: getParsedRowData(data),
130
121
  url: match.url,
131
122
  toggleModal,
132
- firstColumn
123
+ firstColumn,
124
+ isEnquiry
133
125
  })
134
126
  }));
135
127
  };
@@ -148,12 +140,14 @@ const ListingTable = ({
148
140
  querySettings: {
149
141
  entitySchema,
150
142
  queryParams: updatedQueryParams
151
- }
143
+ },
144
+ listFilters
152
145
  });
153
146
  const updatedRows = [...tableData.rows, ...formatRows({
154
- rows: data,
147
+ rows: getParsedRowData(data),
155
148
  url: match.url,
156
- toggleModal
149
+ toggleModal,
150
+ isEnquiry: tableData.isEnquiry
157
151
  })];
158
152
  setVerifiedRanges([...verifiedRanges, loadIndex]);
159
153
  setQueryParams(updatedQueryParams);
@@ -164,6 +158,7 @@ const ListingTable = ({
164
158
  }
165
159
  };
166
160
  if (!tableData || !tableData.rows) return 'loading';
161
+ const showAddButton = !!tableData.rows.length && !tableData.isEnquiry;
167
162
  return /*#__PURE__*/React.createElement("div", {
168
163
  className: "page"
169
164
  }, modalStatus && /*#__PURE__*/React.createElement(DeleteAction, {
@@ -173,7 +168,7 @@ const ListingTable = ({
173
168
  }), /*#__PURE__*/React.createElement(PageHeader, {
174
169
  title: entitySchema.displayName,
175
170
  subtitle: ""
176
- }, (!selectedMenuItem.isDisplayedPrompt || !!tableData.rows.length) && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Link, {
171
+ }, showAddButton && /*#__PURE__*/React.createElement(Fragment, null, /*#__PURE__*/React.createElement(Link, {
177
172
  "data-testid": "addEntity",
178
173
  className: "button button--small",
179
174
  to: `${match.url}/create`
@@ -183,20 +178,30 @@ const ListingTable = ({
183
178
  className: "material-icons"
184
179
  }, "more_vert")), /*#__PURE__*/React.createElement(More.Content, {
185
180
  isMoreMenu: true
186
- }))))), /*#__PURE__*/React.createElement(ListingTableContent, {
181
+ }))))), displayCardPrompt && !showAddButton && /*#__PURE__*/React.createElement(CardPrompt, {
182
+ onClose: () => {
183
+ setDisplayCardPrompt(false);
184
+ }
185
+ }, /*#__PURE__*/React.createElement(Link, {
186
+ className: "button button--rounded button--cta",
187
+ to: `${match.url}/create`,
188
+ "data-testid": "add-button"
189
+ }, "Add")), /*#__PURE__*/React.createElement(RenderHook, {
190
+ hookKey: "entity:listing:main:top",
191
+ schema: entitySchema,
192
+ setListFilters: updateListingFilters
193
+ }), /*#__PURE__*/React.createElement(ListingTableContent, {
187
194
  overScanBuffer: OVER_SCAN_BUFFER,
188
195
  onSort: handleSort,
189
196
  onRenderItems: handleRenderedItems,
190
197
  tableData: tableData,
191
198
  onCloseCardPrompt: onCloseCardPrompt,
192
- selectedMenuItem: selectedMenuItem,
193
199
  scrollToIndex: scrollToIndex
194
200
  }));
195
201
  };
196
202
  ListingTable.propTypes = {
197
203
  entitySchema: PropTypes.object.isRequired,
198
- match: PropTypes.object.isRequired,
199
- selectedMenuItem: PropTypes.object.isRequired
204
+ match: PropTypes.object.isRequired
200
205
  };
201
206
  export default withRouter(ListingTable);
202
207
  //# sourceMappingURL=ListingTable.js.map