@blaze-cms/plugin-data-ui 0.146.0-rc-eagle.0 → 0.146.0-rc-eagle-3.2

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 (183) hide show
  1. package/README.md +9 -2
  2. package/lib/components/EntityManager/Entity/Entity.js +1 -1
  3. package/lib/components/EntityManager/Entity/Entity.js.map +1 -1
  4. package/lib/components/EntityManager/Entity/actions-handlers/create/submit.js +4 -15
  5. package/lib/components/EntityManager/Entity/actions-handlers/create/submit.js.map +1 -1
  6. package/lib/components/EntityManager/utils/entity.js +2 -3
  7. package/lib/components/EntityManager/utils/entity.js.map +1 -1
  8. package/lib/components/ListingTable/SearchFilter/RelationMultiSelectFilter.js +181 -0
  9. package/lib/components/ListingTable/SearchFilter/RelationMultiSelectFilter.js.map +1 -0
  10. package/lib/components/ListingTable/SearchFilter/SearchContainer.js +348 -52
  11. package/lib/components/ListingTable/SearchFilter/SearchContainer.js.map +1 -1
  12. package/lib/components/ListingTable/SearchFilter/SearchFilter.js +15 -3
  13. package/lib/components/ListingTable/SearchFilter/SearchFilter.js.map +1 -1
  14. package/lib/components/ListingTable/SearchFilter/helpers.js +41 -8
  15. package/lib/components/ListingTable/SearchFilter/helpers.js.map +1 -1
  16. package/lib/index.js +7 -0
  17. package/lib/index.js.map +1 -1
  18. package/lib/utils/build-create-entity-mutation.js +3 -19
  19. package/lib/utils/build-create-entity-mutation.js.map +1 -1
  20. package/lib/utils/get-default-query-params.js +17 -5
  21. package/lib/utils/get-default-query-params.js.map +1 -1
  22. package/lib-es/components/EntityDataListing/EntityDataListing.js +33 -0
  23. package/lib-es/components/EntityDataListing/EntityDataListing.js.map +1 -0
  24. package/lib-es/components/EntityDataListing/index.js +3 -0
  25. package/lib-es/components/EntityDataListing/index.js.map +1 -0
  26. package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +30 -0
  27. package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js.map +1 -0
  28. package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/index.js +3 -0
  29. package/lib-es/components/EntityManager/Entity/EntitiyNavLinks/index.js.map +1 -0
  30. package/lib-es/components/EntityManager/Entity/Entity.js +453 -0
  31. package/lib-es/components/EntityManager/Entity/Entity.js.map +1 -0
  32. package/lib-es/components/EntityManager/Entity/EntityHeader/EntityHeader.js +103 -0
  33. package/lib-es/components/EntityManager/Entity/EntityHeader/EntityHeader.js.map +1 -0
  34. package/lib-es/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js +47 -0
  35. package/lib-es/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js.map +1 -0
  36. package/lib-es/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/index.js +3 -0
  37. package/lib-es/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/index.js.map +1 -0
  38. package/lib-es/components/EntityManager/Entity/EntityHeader/index.js +3 -0
  39. package/lib-es/components/EntityManager/Entity/EntityHeader/index.js.map +1 -0
  40. package/lib-es/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +30 -0
  41. package/lib-es/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js.map +1 -0
  42. package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +29 -0
  43. package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +1 -0
  44. package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +49 -0
  45. package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +1 -0
  46. package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js +136 -0
  47. package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -0
  48. package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +36 -0
  49. package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +1 -0
  50. package/lib-es/components/EntityManager/Entity/actions-handlers/create/index.js +5 -0
  51. package/lib-es/components/EntityManager/Entity/actions-handlers/create/index.js.map +1 -0
  52. package/lib-es/components/EntityManager/Entity/actions-handlers/create/submit.js +36 -0
  53. package/lib-es/components/EntityManager/Entity/actions-handlers/create/submit.js.map +1 -0
  54. package/lib-es/components/EntityManager/Entity/actions-handlers/delete/delete.js +32 -0
  55. package/lib-es/components/EntityManager/Entity/actions-handlers/delete/delete.js.map +1 -0
  56. package/lib-es/components/EntityManager/Entity/actions-handlers/delete/index.js +5 -0
  57. package/lib-es/components/EntityManager/Entity/actions-handlers/delete/index.js.map +1 -0
  58. package/lib-es/components/EntityManager/Entity/actions-handlers/index.js +12 -0
  59. package/lib-es/components/EntityManager/Entity/actions-handlers/index.js.map +1 -0
  60. package/lib-es/components/EntityManager/Entity/actions-handlers/shared/index.js +5 -0
  61. package/lib-es/components/EntityManager/Entity/actions-handlers/shared/index.js.map +1 -0
  62. package/lib-es/components/EntityManager/Entity/actions-handlers/shared/publish.js +39 -0
  63. package/lib-es/components/EntityManager/Entity/actions-handlers/shared/publish.js.map +1 -0
  64. package/lib-es/components/EntityManager/Entity/actions-handlers/update/index.js +5 -0
  65. package/lib-es/components/EntityManager/Entity/actions-handlers/update/index.js.map +1 -0
  66. package/lib-es/components/EntityManager/Entity/actions-handlers/update/submit.js +53 -0
  67. package/lib-es/components/EntityManager/Entity/actions-handlers/update/submit.js.map +1 -0
  68. package/lib-es/components/EntityManager/Entity/index.js +3 -0
  69. package/lib-es/components/EntityManager/Entity/index.js.map +1 -0
  70. package/lib-es/components/EntityManager/EntityManager.js +133 -0
  71. package/lib-es/components/EntityManager/EntityManager.js.map +1 -0
  72. package/lib-es/components/EntityManager/index.js +3 -0
  73. package/lib-es/components/EntityManager/index.js.map +1 -0
  74. package/lib-es/components/EntityManager/utils/RecordEditContext/index.js +6 -0
  75. package/lib-es/components/EntityManager/utils/RecordEditContext/index.js.map +1 -0
  76. package/lib-es/components/EntityManager/utils/data-mappers.js +55 -0
  77. package/lib-es/components/EntityManager/utils/data-mappers.js.map +1 -0
  78. package/lib-es/components/EntityManager/utils/entity.js +69 -0
  79. package/lib-es/components/EntityManager/utils/entity.js.map +1 -0
  80. package/lib-es/components/EntityManager/utils/entityAvailableActions.js +56 -0
  81. package/lib-es/components/EntityManager/utils/entityAvailableActions.js.map +1 -0
  82. package/lib-es/components/EntityManager/utils/is-form-empty.js +9 -0
  83. package/lib-es/components/EntityManager/utils/is-form-empty.js.map +1 -0
  84. package/lib-es/components/EntityManager/utils/query.js +23 -0
  85. package/lib-es/components/EntityManager/utils/query.js.map +1 -0
  86. package/lib-es/components/InfoBoxes/InfoBoxTooltip.js +36 -0
  87. package/lib-es/components/InfoBoxes/InfoBoxTooltip.js.map +1 -0
  88. package/lib-es/components/InfoBoxes/InfoBoxes.js +28 -0
  89. package/lib-es/components/InfoBoxes/InfoBoxes.js.map +1 -0
  90. package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js +38 -0
  91. package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js.map +1 -0
  92. package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js +28 -0
  93. package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js.map +1 -0
  94. package/lib-es/components/InfoBoxes/hooks/useData.js +39 -0
  95. package/lib-es/components/InfoBoxes/hooks/useData.js.map +1 -0
  96. package/lib-es/components/InfoBoxes/hooks/useInfoBox.js +17 -0
  97. package/lib-es/components/InfoBoxes/hooks/useInfoBox.js.map +1 -0
  98. package/lib-es/components/InfoBoxes/index.js +3 -0
  99. package/lib-es/components/InfoBoxes/index.js.map +1 -0
  100. package/lib-es/components/InfoBoxes/presentational/InfoBox.js +40 -0
  101. package/lib-es/components/InfoBoxes/presentational/InfoBox.js.map +1 -0
  102. package/lib-es/components/InfoBoxes/presentational/InfoBoxLabel.js +12 -0
  103. package/lib-es/components/InfoBoxes/presentational/InfoBoxLabel.js.map +1 -0
  104. package/lib-es/components/InfoBoxes/presentational/InfoBoxValue.js +30 -0
  105. package/lib-es/components/InfoBoxes/presentational/InfoBoxValue.js.map +1 -0
  106. package/lib-es/components/ListingTable/ListingTable.js +208 -0
  107. package/lib-es/components/ListingTable/ListingTable.js.map +1 -0
  108. package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js +72 -0
  109. package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -0
  110. package/lib-es/components/ListingTable/ListingTableContent/index.js +3 -0
  111. package/lib-es/components/ListingTable/ListingTableContent/index.js.map +1 -0
  112. package/lib-es/components/ListingTable/SearchFilter/RelationMultiSelectFilter.js +173 -0
  113. package/lib-es/components/ListingTable/SearchFilter/RelationMultiSelectFilter.js.map +1 -0
  114. package/lib-es/components/ListingTable/SearchFilter/SearchContainer.js +503 -0
  115. package/lib-es/components/ListingTable/SearchFilter/SearchContainer.js.map +1 -0
  116. package/lib-es/components/ListingTable/SearchFilter/SearchFilter.js +52 -0
  117. package/lib-es/components/ListingTable/SearchFilter/SearchFilter.js.map +1 -0
  118. package/lib-es/components/ListingTable/SearchFilter/helpers.js +127 -0
  119. package/lib-es/components/ListingTable/SearchFilter/helpers.js.map +1 -0
  120. package/lib-es/components/ListingTable/SearchFilter/querys.js +8 -0
  121. package/lib-es/components/ListingTable/SearchFilter/querys.js.map +1 -0
  122. package/lib-es/components/ListingTable/TableActions/TableActions.js +34 -0
  123. package/lib-es/components/ListingTable/TableActions/TableActions.js.map +1 -0
  124. package/lib-es/components/ListingTable/TableActions/index.js +3 -0
  125. package/lib-es/components/ListingTable/TableActions/index.js.map +1 -0
  126. package/lib-es/components/ListingTable/index.js +3 -0
  127. package/lib-es/components/ListingTable/index.js.map +1 -0
  128. package/lib-es/components/ListingTable/mappers/populate-rows.js +140 -0
  129. package/lib-es/components/ListingTable/mappers/populate-rows.js.map +1 -0
  130. package/lib-es/components/ListingTable/service/index.js +87 -0
  131. package/lib-es/components/ListingTable/service/index.js.map +1 -0
  132. package/lib-es/components/Tabs/index.js +38 -0
  133. package/lib-es/components/Tabs/index.js.map +1 -0
  134. package/lib-es/components/hooks/useCallbackDebounce.js +12 -0
  135. package/lib-es/components/hooks/useCallbackDebounce.js.map +1 -0
  136. package/lib-es/constants.js +42 -0
  137. package/lib-es/constants.js.map +1 -0
  138. package/lib-es/icons/ContentIcon.js +80 -0
  139. package/lib-es/icons/ContentIcon.js.map +1 -0
  140. package/lib-es/icons/SettingsIcon.js +36 -0
  141. package/lib-es/icons/SettingsIcon.js.map +1 -0
  142. package/lib-es/icons/TaxonomyIcon.js +60 -0
  143. package/lib-es/icons/TaxonomyIcon.js.map +1 -0
  144. package/lib-es/icons/UsersIcon.js +33 -0
  145. package/lib-es/icons/UsersIcon.js.map +1 -0
  146. package/lib-es/icons/index.js +6 -0
  147. package/lib-es/icons/index.js.map +1 -0
  148. package/lib-es/index.js +93 -0
  149. package/lib-es/index.js.map +1 -0
  150. package/lib-es/utils/add-content-menu-items.js +72 -0
  151. package/lib-es/utils/add-content-menu-items.js.map +1 -0
  152. package/lib-es/utils/build-create-entity-mutation.js +7 -0
  153. package/lib-es/utils/build-create-entity-mutation.js.map +1 -0
  154. package/lib-es/utils/build-delete-entity-mutation.js +18 -0
  155. package/lib-es/utils/build-delete-entity-mutation.js.map +1 -0
  156. package/lib-es/utils/build-listing-query.js +28 -0
  157. package/lib-es/utils/build-listing-query.js.map +1 -0
  158. package/lib-es/utils/build-update-data-query.js +24 -0
  159. package/lib-es/utils/build-update-data-query.js.map +1 -0
  160. package/lib-es/utils/build-update-publish-unpublish-mutation.js +22 -0
  161. package/lib-es/utils/build-update-publish-unpublish-mutation.js.map +1 -0
  162. package/lib-es/utils/get-default-query-params.js +29 -0
  163. package/lib-es/utils/get-default-query-params.js.map +1 -0
  164. package/lib-es/utils/hoc/withContext.js +8 -0
  165. package/lib-es/utils/hoc/withContext.js.map +1 -0
  166. package/lib-es/utils/hooks/useToggle.js +8 -0
  167. package/lib-es/utils/hooks/useToggle.js.map +1 -0
  168. package/lib-es/utils/index.js +3 -0
  169. package/lib-es/utils/index.js.map +1 -0
  170. package/package.json +16 -12
  171. package/src/components/EntityManager/Entity/Entity.js +1 -1
  172. package/src/components/EntityManager/Entity/actions-handlers/create/submit.js +4 -11
  173. package/src/components/EntityManager/utils/entity.js +4 -10
  174. package/src/components/ListingTable/SearchFilter/RelationMultiSelectFilter.js +160 -0
  175. package/src/components/ListingTable/SearchFilter/SearchContainer.js +407 -74
  176. package/src/components/ListingTable/SearchFilter/SearchFilter.js +14 -3
  177. package/src/components/ListingTable/SearchFilter/helpers.js +55 -8
  178. package/src/index.js +2 -0
  179. package/src/utils/build-create-entity-mutation.js +5 -28
  180. package/src/utils/get-default-query-params.js +21 -9
  181. package/CHANGELOG.md +0 -1932
  182. package/babel.config.js +0 -3
  183. package/jest.config.js +0 -5
@@ -0,0 +1,53 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ import buildUpdateDataQuery from '../../../../../utils/build-update-data-query';
5
+ import { ERROR, SUCCESS, SAVE_BUTTON_TEXTS } from '../../../../../constants';
6
+ const submit = async ({
7
+ entitySchema,
8
+ entityData,
9
+ parsedFormValues,
10
+ client,
11
+ setIsSaveButtonAvailable,
12
+ setSaveButtonText,
13
+ setNewUpdatedDate,
14
+ newUpdatedDate,
15
+ handleUpdateFormData
16
+ }, addToast) => {
17
+ const mutation = buildUpdateDataQuery(entitySchema);
18
+ try {
19
+ setIsSaveButtonAvailable(false);
20
+ setSaveButtonText(SAVE_BUTTON_TEXTS.saving);
21
+ const {
22
+ data
23
+ } = await client.mutate({
24
+ mutation,
25
+ variables: {
26
+ input: _objectSpread(_objectSpread({
27
+ id: entityData.id
28
+ }, parsedFormValues), {}, {
29
+ updated: newUpdatedDate || entityData.updated
30
+ })
31
+ }
32
+ });
33
+ setSaveButtonText(SAVE_BUTTON_TEXTS.saved);
34
+ const updatedDate = data && data.updateEntity && data.updateEntity.result && data.updateEntity.result.updated;
35
+ setNewUpdatedDate(updatedDate);
36
+ addToast('Updated', {
37
+ appearance: SUCCESS,
38
+ autoDismiss: true
39
+ });
40
+ handleUpdateFormData();
41
+ return SUCCESS;
42
+ } catch (error) {
43
+ setIsSaveButtonAvailable(true);
44
+ setSaveButtonText(SAVE_BUTTON_TEXTS.save);
45
+ addToast(error.message, {
46
+ appearance: ERROR,
47
+ autoDismiss: true
48
+ });
49
+ return ERROR;
50
+ }
51
+ };
52
+ export { submit };
53
+ //# sourceMappingURL=submit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"submit.js","names":["buildUpdateDataQuery","ERROR","SUCCESS","SAVE_BUTTON_TEXTS","submit","entitySchema","entityData","parsedFormValues","client","setIsSaveButtonAvailable","setSaveButtonText","setNewUpdatedDate","newUpdatedDate","handleUpdateFormData","addToast","mutation","saving","data","mutate","variables","input","_objectSpread","id","updated","saved","updatedDate","updateEntity","result","appearance","autoDismiss","error","save","message"],"sources":["../../../../../../src/components/EntityManager/Entity/actions-handlers/update/submit.js"],"sourcesContent":["import buildUpdateDataQuery from '../../../../../utils/build-update-data-query';\nimport { ERROR, SUCCESS, SAVE_BUTTON_TEXTS } from '../../../../../constants';\n\nconst submit = async (\n {\n entitySchema,\n entityData,\n parsedFormValues,\n client,\n setIsSaveButtonAvailable,\n setSaveButtonText,\n setNewUpdatedDate,\n newUpdatedDate,\n handleUpdateFormData\n },\n addToast\n) => {\n const mutation = buildUpdateDataQuery(entitySchema);\n\n try {\n setIsSaveButtonAvailable(false);\n setSaveButtonText(SAVE_BUTTON_TEXTS.saving);\n const { data } = await client.mutate({\n mutation,\n variables: {\n input: {\n id: entityData.id,\n ...parsedFormValues,\n updated: newUpdatedDate || entityData.updated\n }\n }\n });\n setSaveButtonText(SAVE_BUTTON_TEXTS.saved);\n const updatedDate =\n data && data.updateEntity && data.updateEntity.result && data.updateEntity.result.updated;\n\n setNewUpdatedDate(updatedDate);\n\n addToast('Updated', {\n appearance: SUCCESS,\n autoDismiss: true\n });\n handleUpdateFormData();\n return SUCCESS;\n } catch (error) {\n setIsSaveButtonAvailable(true);\n setSaveButtonText(SAVE_BUTTON_TEXTS.save);\n addToast(error.message, {\n appearance: ERROR,\n autoDismiss: true\n });\n return ERROR;\n }\n};\n\nexport { submit };\n"],"mappings":";;;AAAA,OAAOA,oBAAoB,MAAM,8CAA8C;AAC/E,SAASC,KAAK,EAAEC,OAAO,EAAEC,iBAAiB,QAAQ,0BAA0B;AAE5E,MAAMC,MAAM,GAAG,MAAAA,CACb;EACEC,YAAY;EACZC,UAAU;EACVC,gBAAgB;EAChBC,MAAM;EACNC,wBAAwB;EACxBC,iBAAiB;EACjBC,iBAAiB;EACjBC,cAAc;EACdC;AACF,CAAC,EACDC,QAAQ,KACL;EACH,MAAMC,QAAQ,GAAGf,oBAAoB,CAACK,YAAY,CAAC;EAEnD,IAAI;IACFI,wBAAwB,CAAC,KAAK,CAAC;IAC/BC,iBAAiB,CAACP,iBAAiB,CAACa,MAAM,CAAC;IAC3C,MAAM;MAAEC;IAAK,CAAC,GAAG,MAAMT,MAAM,CAACU,MAAM,CAAC;MACnCH,QAAQ;MACRI,SAAS,EAAE;QACTC,KAAK,EAAAC,aAAA,CAAAA,aAAA;UACHC,EAAE,EAAEhB,UAAU,CAACgB;QAAE,GACdf,gBAAgB;UACnBgB,OAAO,EAAEX,cAAc,IAAIN,UAAU,CAACiB;QAAO;MAEjD;IACF,CAAC,CAAC;IACFb,iBAAiB,CAACP,iBAAiB,CAACqB,KAAK,CAAC;IAC1C,MAAMC,WAAW,GACfR,IAAI,IAAIA,IAAI,CAACS,YAAY,IAAIT,IAAI,CAACS,YAAY,CAACC,MAAM,IAAIV,IAAI,CAACS,YAAY,CAACC,MAAM,CAACJ,OAAO;IAE3FZ,iBAAiB,CAACc,WAAW,CAAC;IAE9BX,QAAQ,CAAC,SAAS,EAAE;MAClBc,UAAU,EAAE1B,OAAO;MACnB2B,WAAW,EAAE;IACf,CAAC,CAAC;IACFhB,oBAAoB,CAAC,CAAC;IACtB,OAAOX,OAAO;EAChB,CAAC,CAAC,OAAO4B,KAAK,EAAE;IACdrB,wBAAwB,CAAC,IAAI,CAAC;IAC9BC,iBAAiB,CAACP,iBAAiB,CAAC4B,IAAI,CAAC;IACzCjB,QAAQ,CAACgB,KAAK,CAACE,OAAO,EAAE;MACtBJ,UAAU,EAAE3B,KAAK;MACjB4B,WAAW,EAAE;IACf,CAAC,CAAC;IACF,OAAO5B,KAAK;EACd;AACF,CAAC;AAED,SAASG,MAAM","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import Entity from './Entity';
2
+ export default Entity;
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["Entity"],"sources":["../../../../src/components/EntityManager/Entity/index.js"],"sourcesContent":["import Entity from './Entity';\n\nexport default Entity;\n"],"mappings":"AAAA,OAAOA,MAAM,MAAM,UAAU;AAE7B,eAAeA,MAAM","ignoreList":[]}
@@ -0,0 +1,133 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ import React, { useEffect, useState } from 'react';
5
+ import { withRouter } from 'react-router-dom';
6
+ import { useApolloClient } from '@apollo/client';
7
+ import PropTypes from 'prop-types';
8
+ import { useToasts } from '@blaze-react/toaster';
9
+ import entityAvailableActions from './utils/entityAvailableActions';
10
+ import Entity from './Entity';
11
+ import { getAction } from './utils/query';
12
+ import { ERROR, PAGE_NOT_FOUND } from '../../constants';
13
+ const EntityManager = ({
14
+ match,
15
+ history
16
+ }) => {
17
+ const [formData, setFormData] = useState(null);
18
+ const [entity, setEntity] = useState(null);
19
+ const [schema, setSchema] = useState({
20
+ id: null
21
+ });
22
+ const [previousQuery, setPreviousQuery] = useState(null);
23
+ const [shouldRefetch, setShouldRefetch] = useState(false);
24
+ const client = useApolloClient();
25
+ const {
26
+ addToast
27
+ } = useToasts();
28
+ const {
29
+ action,
30
+ entityIdentifier,
31
+ id = null,
32
+ onViewUrl
33
+ } = match.params;
34
+ useEffect(() => {
35
+ (async () => {
36
+ try {
37
+ const [entitySchema, data = {}, requestedQuery] = await entityAvailableActions[action]({
38
+ client,
39
+ identifier: entityIdentifier,
40
+ id
41
+ });
42
+ if (!data) {
43
+ addToast(PAGE_NOT_FOUND, {
44
+ appearance: ERROR,
45
+ autoDismiss: true
46
+ });
47
+ history.push(`/data-listing/${entityIdentifier}`);
48
+ }
49
+ let localData = data;
50
+ if (isPageBuilderTemplateSet(data)) {
51
+ const pageBuilderComponents = await getPageBuilderComponents({
52
+ entitySchema,
53
+ client,
54
+ id
55
+ });
56
+ localData = _objectSpread(_objectSpread({}, localData), {}, {
57
+ pageBuilder: pageBuilderComponents || localData.pageBuilder
58
+ });
59
+ }
60
+ setFormData({
61
+ values: localData
62
+ });
63
+ setEntity(data);
64
+ setSchema(entitySchema);
65
+ setPreviousQuery(requestedQuery);
66
+ setShouldRefetch(false);
67
+ } catch (error) {
68
+ addToast(error.message, {
69
+ appearance: ERROR,
70
+ autoDismiss: true
71
+ });
72
+ history.push(`/data-listing/${entityIdentifier}`);
73
+ }
74
+ })();
75
+ }, [action, addToast, client, entityIdentifier, history, history.push, id, schema, shouldRefetch]);
76
+ const updateFormData = (updatedFormData, shouldRefresh) => {
77
+ if (shouldRefresh) setShouldRefetch(true);
78
+ setFormData(updatedFormData);
79
+ };
80
+
81
+ // Reset when entity/record changes
82
+ if (!formData || !schema.id || recordHasChanged(entity, id, schema.id, entityIdentifier)) {
83
+ return null;
84
+ }
85
+ return /*#__PURE__*/React.createElement(Entity, {
86
+ action: match.params.action,
87
+ formData: formData,
88
+ updateFormData: updateFormData,
89
+ entity: entity,
90
+ schema: schema,
91
+ previousQuery: previousQuery,
92
+ onViewUrl: onViewUrl,
93
+ refetchRecord: setShouldRefetch
94
+ });
95
+ };
96
+ EntityManager.propTypes = {
97
+ match: PropTypes.shape({
98
+ params: PropTypes.shape({
99
+ action: PropTypes.string,
100
+ entityIdentifier: PropTypes.string,
101
+ id: PropTypes.string,
102
+ onViewUrl: PropTypes.func
103
+ })
104
+ }).isRequired,
105
+ history: PropTypes.object.isRequired
106
+ };
107
+ export default withRouter(EntityManager);
108
+ async function getPageBuilderComponents({
109
+ entitySchema,
110
+ client,
111
+ id
112
+ }) {
113
+ const actionName = entitySchema && entitySchema.actions.getAll || 'get';
114
+ const {
115
+ data: pageBuilderData = {}
116
+ } = await client.query({
117
+ query: getAction(actionName, 'pageBuilderComponents'),
118
+ variables: {
119
+ where: {
120
+ id
121
+ }
122
+ },
123
+ fetchPolicy: 'network-only'
124
+ });
125
+ return pageBuilderData[actionName] && pageBuilderData[actionName].length ? pageBuilderData[actionName][0].pageBuilderComponents : null;
126
+ }
127
+ function isPageBuilderTemplateSet(data) {
128
+ return data && data.pageBuilderTemplateId && data.pageBuilderTemplateId !== '';
129
+ }
130
+ function recordHasChanged(entity, id, currentEntityIdentifier, entityIdentifier) {
131
+ return entity && entity.id && entity.id !== id || currentEntityIdentifier && currentEntityIdentifier !== entityIdentifier;
132
+ }
133
+ //# sourceMappingURL=EntityManager.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EntityManager.js","names":["React","useEffect","useState","withRouter","useApolloClient","PropTypes","useToasts","entityAvailableActions","Entity","getAction","ERROR","PAGE_NOT_FOUND","EntityManager","match","history","formData","setFormData","entity","setEntity","schema","setSchema","id","previousQuery","setPreviousQuery","shouldRefetch","setShouldRefetch","client","addToast","action","entityIdentifier","onViewUrl","params","entitySchema","data","requestedQuery","identifier","appearance","autoDismiss","push","localData","isPageBuilderTemplateSet","pageBuilderComponents","getPageBuilderComponents","_objectSpread","pageBuilder","values","error","message","updateFormData","updatedFormData","shouldRefresh","recordHasChanged","createElement","refetchRecord","propTypes","shape","string","func","isRequired","object","actionName","actions","getAll","pageBuilderData","query","variables","where","fetchPolicy","length","pageBuilderTemplateId","currentEntityIdentifier"],"sources":["../../../src/components/EntityManager/EntityManager.js"],"sourcesContent":["import React, { useEffect, useState } from 'react';\nimport { withRouter } from 'react-router-dom';\nimport { useApolloClient } from '@apollo/client';\nimport PropTypes from 'prop-types';\nimport { useToasts } from '@blaze-react/toaster';\nimport entityAvailableActions from './utils/entityAvailableActions';\nimport Entity from './Entity';\nimport { getAction } from './utils/query';\nimport { ERROR, PAGE_NOT_FOUND } from '../../constants';\n\nconst EntityManager = ({ match, history }) => {\n const [formData, setFormData] = useState(null);\n const [entity, setEntity] = useState(null);\n const [schema, setSchema] = useState({ id: null });\n const [previousQuery, setPreviousQuery] = useState(null);\n const [shouldRefetch, setShouldRefetch] = useState(false);\n const client = useApolloClient();\n const { addToast } = useToasts();\n\n const { action, entityIdentifier, id = null, onViewUrl } = match.params;\n\n useEffect(() => {\n (async () => {\n try {\n const [entitySchema, data = {}, requestedQuery] = await entityAvailableActions[action]({\n client,\n identifier: entityIdentifier,\n id\n });\n\n if (!data) {\n addToast(PAGE_NOT_FOUND, {\n appearance: ERROR,\n autoDismiss: true\n });\n\n history.push(`/data-listing/${entityIdentifier}`);\n }\n\n let localData = data;\n\n if (isPageBuilderTemplateSet(data)) {\n const pageBuilderComponents = await getPageBuilderComponents({\n entitySchema,\n client,\n id\n });\n\n localData = {\n ...localData,\n pageBuilder: pageBuilderComponents || localData.pageBuilder\n };\n }\n\n setFormData({ values: localData });\n setEntity(data);\n setSchema(entitySchema);\n setPreviousQuery(requestedQuery);\n setShouldRefetch(false);\n } catch (error) {\n addToast(error.message, {\n appearance: ERROR,\n autoDismiss: true\n });\n history.push(`/data-listing/${entityIdentifier}`);\n }\n })();\n }, [\n action,\n addToast,\n client,\n entityIdentifier,\n history,\n history.push,\n id,\n schema,\n shouldRefetch\n ]);\n\n const updateFormData = (updatedFormData, shouldRefresh) => {\n if (shouldRefresh) setShouldRefetch(true);\n setFormData(updatedFormData);\n };\n\n // Reset when entity/record changes\n if (!formData || !schema.id || recordHasChanged(entity, id, schema.id, entityIdentifier)) {\n return null;\n }\n\n return (\n <Entity\n action={match.params.action}\n formData={formData}\n updateFormData={updateFormData}\n entity={entity}\n schema={schema}\n previousQuery={previousQuery}\n onViewUrl={onViewUrl}\n refetchRecord={setShouldRefetch}\n />\n );\n};\n\nEntityManager.propTypes = {\n match: PropTypes.shape({\n params: PropTypes.shape({\n action: PropTypes.string,\n entityIdentifier: PropTypes.string,\n id: PropTypes.string,\n onViewUrl: PropTypes.func\n })\n }).isRequired,\n history: PropTypes.object.isRequired\n};\n\nexport default withRouter(EntityManager);\n\nasync function getPageBuilderComponents({ entitySchema, client, id }) {\n const actionName = (entitySchema && entitySchema.actions.getAll) || 'get';\n const { data: pageBuilderData = {} } = await client.query({\n query: getAction(actionName, 'pageBuilderComponents'),\n variables: {\n where: {\n id\n }\n },\n fetchPolicy: 'network-only'\n });\n\n return pageBuilderData[actionName] && pageBuilderData[actionName].length\n ? pageBuilderData[actionName][0].pageBuilderComponents\n : null;\n}\n\nfunction isPageBuilderTemplateSet(data) {\n return data && data.pageBuilderTemplateId && data.pageBuilderTemplateId !== '';\n}\n\nfunction recordHasChanged(entity, id, currentEntityIdentifier, entityIdentifier) {\n return (\n (entity && entity.id && entity.id !== id) ||\n (currentEntityIdentifier && currentEntityIdentifier !== entityIdentifier)\n );\n}\n"],"mappings":";;;AAAA,OAAOA,KAAK,IAAIC,SAAS,EAAEC,QAAQ,QAAQ,OAAO;AAClD,SAASC,UAAU,QAAQ,kBAAkB;AAC7C,SAASC,eAAe,QAAQ,gBAAgB;AAChD,OAAOC,SAAS,MAAM,YAAY;AAClC,SAASC,SAAS,QAAQ,sBAAsB;AAChD,OAAOC,sBAAsB,MAAM,gCAAgC;AACnE,OAAOC,MAAM,MAAM,UAAU;AAC7B,SAASC,SAAS,QAAQ,eAAe;AACzC,SAASC,KAAK,EAAEC,cAAc,QAAQ,iBAAiB;AAEvD,MAAMC,aAAa,GAAGA,CAAC;EAAEC,KAAK;EAAEC;AAAQ,CAAC,KAAK;EAC5C,MAAM,CAACC,QAAQ,EAAEC,WAAW,CAAC,GAAGd,QAAQ,CAAC,IAAI,CAAC;EAC9C,MAAM,CAACe,MAAM,EAAEC,SAAS,CAAC,GAAGhB,QAAQ,CAAC,IAAI,CAAC;EAC1C,MAAM,CAACiB,MAAM,EAAEC,SAAS,CAAC,GAAGlB,QAAQ,CAAC;IAAEmB,EAAE,EAAE;EAAK,CAAC,CAAC;EAClD,MAAM,CAACC,aAAa,EAAEC,gBAAgB,CAAC,GAAGrB,QAAQ,CAAC,IAAI,CAAC;EACxD,MAAM,CAACsB,aAAa,EAAEC,gBAAgB,CAAC,GAAGvB,QAAQ,CAAC,KAAK,CAAC;EACzD,MAAMwB,MAAM,GAAGtB,eAAe,CAAC,CAAC;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ACH,CAAC,CAAC,CAACC,UAAU;EACb5C,OAAO,EAAET,SAAS,CAACsD,MAAM,CAACD;AAC5B,CAAC;AAED,eAAevD,UAAU,CAACS,aAAa,CAAC;AAExC,eAAe8B,wBAAwBA,CAAC;EAAEV,YAAY;EAAEN,MAAM;EAAEL;AAAG,CAAC,EAAE;EACpE,MAAMuC,UAAU,GAAI5B,YAAY,IAAIA,YAAY,CAAC6B,OAAO,CAACC,MAAM,IAAK,KAAK;EACzE,MAAM;IAAE7B,IAAI,EAAE8B,eAAe,GAAG,CAAC;EAAE,CAAC,GAAG,MAAMrC,MAAM,CAACsC,KAAK,CAAC;IACxDA,KAAK,EAAEvD,SAAS,CAACmD,UAAU,EAAE,uBAAuB,CAAC;IACrDK,SAAS,EAAE;MACTC,KAAK,EAAE;QACL7C;MACF;IACF,CAAC;IACD8C,WAAW,EAAE;EACf,CAAC,CAAC;EAEF,OAAOJ,eAAe,CAACH,UAAU,CAAC,IAAIG,eAAe,CAACH,UAAU,CAAC,CAACQ,MAAM,GACpEL,eAAe,CAACH,UAAU,CAAC,CAAC,CAAC,CAAC,CAACnB,qBAAqB,GACpD,IAAI;AACV;AAEA,SAASD,wBAAwBA,CAACP,IAAI,EAAE;EACtC,OAAOA,IAAI,IAAIA,IAAI,CAACoC,qBAAqB,IAAIpC,IAAI,CAACoC,qBAAqB,KAAK,EAAE;AAChF;AAEA,SAASlB,gBAAgBA,CAAClC,MAAM,EAAEI,EAAE,EAAEiD,uBAAuB,EAAEzC,gBAAgB,EAAE;EAC/E,OACGZ,MAAM,IAAIA,MAAM,CAACI,EAAE,IAAIJ,MAAM,CAACI,EAAE,KAAKA,EAAE,IACvCiD,uBAAuB,IAAIA,uBAAuB,KAAKzC,gBAAiB;AAE7E","ignoreList":[]}
@@ -0,0 +1,3 @@
1
+ import EntityManager from './EntityManager';
2
+ export default EntityManager;
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["EntityManager"],"sources":["../../../src/components/EntityManager/index.js"],"sourcesContent":["import EntityManager from './EntityManager';\n\nexport default EntityManager;\n"],"mappings":"AAAA,OAAOA,aAAa,MAAM,iBAAiB;AAE3C,eAAeA,aAAa","ignoreList":[]}
@@ -0,0 +1,6 @@
1
+ import React from 'react';
2
+ const RecordEditContext = React.createContext();
3
+ const RecordEditContextProvider = RecordEditContext.Provider;
4
+ const RecordEditContextConsumer = RecordEditContext.Consumer;
5
+ export { RecordEditContext, RecordEditContextProvider, RecordEditContextConsumer };
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","names":["React","RecordEditContext","createContext","RecordEditContextProvider","Provider","RecordEditContextConsumer","Consumer"],"sources":["../../../../../src/components/EntityManager/utils/RecordEditContext/index.js"],"sourcesContent":["import React from 'react';\n\nconst RecordEditContext = React.createContext();\nconst RecordEditContextProvider = RecordEditContext.Provider;\nconst RecordEditContextConsumer = RecordEditContext.Consumer;\n\nexport { RecordEditContext, RecordEditContextProvider, RecordEditContextConsumer };\n"],"mappings":"AAAA,OAAOA,KAAK,MAAM,OAAO;AAEzB,MAAMC,iBAAiB,GAAGD,KAAK,CAACE,aAAa,CAAC,CAAC;AAC/C,MAAMC,yBAAyB,GAAGF,iBAAiB,CAACG,QAAQ;AAC5D,MAAMC,yBAAyB,GAAGJ,iBAAiB,CAACK,QAAQ;AAE5D,SAASL,iBAAiB,EAAEE,yBAAyB,EAAEE,yBAAyB","ignoreList":[]}
@@ -0,0 +1,55 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ import { BlazeError } from '@blaze-cms/core-errors';
5
+ const getPageName = (displayProperties = {}, entity = {}) => {
6
+ if (!displayProperties || !displayProperties.adminHeader) {
7
+ const {
8
+ name,
9
+ id: fieldId
10
+ } = entity;
11
+ return name || fieldId || '';
12
+ }
13
+ const {
14
+ adminHeader
15
+ } = displayProperties;
16
+ return adminHeader.reduce((acc, headerProperty) => {
17
+ const item = entity[headerProperty];
18
+ if (item) acc.push(item);
19
+ return acc;
20
+ }, []).join(' ');
21
+ };
22
+ const createNewListItem = ({
23
+ listingData,
24
+ result
25
+ }) => [...listingData, result];
26
+ const updateListItems = ({
27
+ listingData,
28
+ result,
29
+ id
30
+ } = {}) => {
31
+ if (!listingData || !result || !id) throw new BlazeError('Expected object with: listingData, result, id');
32
+ return listingData.map(item => {
33
+ const mapperResult = _objectSpread({}, item);
34
+ if (item.id === id) {
35
+ Object.keys(item).forEach(key => {
36
+ if (result[key] && key !== 'id') {
37
+ mapperResult[key] = result[key];
38
+ }
39
+ });
40
+ return mapperResult;
41
+ }
42
+ return mapperResult;
43
+ });
44
+ };
45
+ const deleteFromListItems = ({
46
+ listingData,
47
+ id
48
+ } = {}) => {
49
+ if (!listingData || !id) throw new BlazeError('Expected object with: listingData, id');
50
+ return listingData.filter(({
51
+ id: itemId
52
+ }) => itemId !== id);
53
+ };
54
+ export { getPageName, createNewListItem, updateListItems, deleteFromListItems };
55
+ //# sourceMappingURL=data-mappers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"data-mappers.js","names":["BlazeError","getPageName","displayProperties","entity","adminHeader","name","id","fieldId","reduce","acc","headerProperty","item","push","join","createNewListItem","listingData","result","updateListItems","map","mapperResult","_objectSpread","Object","keys","forEach","key","deleteFromListItems","filter","itemId"],"sources":["../../../../src/components/EntityManager/utils/data-mappers.js"],"sourcesContent":["import { BlazeError } from '@blaze-cms/core-errors';\n\nconst getPageName = (displayProperties = {}, entity = {}) => {\n if (!displayProperties || !displayProperties.adminHeader) {\n const { name, id: fieldId } = entity;\n return name || fieldId || '';\n }\n\n const { adminHeader } = displayProperties;\n return adminHeader\n .reduce((acc, headerProperty) => {\n const item = entity[headerProperty];\n if (item) acc.push(item);\n return acc;\n }, [])\n .join(' ');\n};\n\nconst createNewListItem = ({ listingData, result }) => [...listingData, result];\n\nconst updateListItems = ({ listingData, result, id } = {}) => {\n if (!listingData || !result || !id)\n throw new BlazeError('Expected object with: listingData, result, id');\n return listingData.map(item => {\n const mapperResult = { ...item };\n if (item.id === id) {\n Object.keys(item).forEach(key => {\n if (result[key] && key !== 'id') {\n mapperResult[key] = result[key];\n }\n });\n return mapperResult;\n }\n return mapperResult;\n });\n};\n\nconst deleteFromListItems = ({ listingData, id } = {}) => {\n if (!listingData || !id) throw new BlazeError('Expected object with: listingData, id');\n return listingData.filter(({ id: itemId }) => itemId !== id);\n};\n\nexport { getPageName, createNewListItem, updateListItems, deleteFromListItems };\n"],"mappings":";;;AAAA,SAASA,UAAU,QAAQ,wBAAwB;AAEnD,MAAMC,WAAW,GAAGA,CAACC,iBAAiB,GAAG,CAAC,CAAC,EAAEC,MAAM,GAAG,CAAC,CAAC,KAAK;EAC3D,IAAI,CAACD,iBAAiB,IAAI,CAACA,iBAAiB,CAACE,WAAW,EAAE;IACxD,MAAM;MAAEC,IAAI;MAAEC,EAAE,EAAEC;IAAQ,CAAC,GAAGJ,MAAM;IACpC,OAAOE,IAAI,IAAIE,OAAO,IAAI,EAAE;EAC9B;EAEA,MAAM;IAAEH;EAAY,CAAC,GAAGF,iBAAiB;EACzC,OAAOE,WAAW,CACfI,MAAM,CAAC,CAACC,GAAG,EAAEC,cAAc,KAAK;IAC/B,MAAMC,IAAI,GAAGR,MAAM,CAACO,cAAc,CAAC;IACnC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ED,SAASL,WAAW,EAAEa,iBAAiB,EAAEG,eAAe,EAAEQ,mBAAmB","ignoreList":[]}
@@ -0,0 +1,69 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
+ import { DEBUG_PARAM, ENTITY_PUBLISHED, SELECT_DEFAULT_VALUE } from '../../../constants';
5
+ function canViewPage(entity, schema, entityIsPublished) {
6
+ return entity && entity.id && schema && schema.id && entityIsPublished === ENTITY_PUBLISHED && schema.properties.slug;
7
+ }
8
+ function validateSideBarRelations(updatedFormValues, requiredChildField) {
9
+ if (!requiredChildField) return true;
10
+ const parentEntityField = updatedFormValues.find(({
11
+ id
12
+ }) => id === 'parentEntity');
13
+ const parentIdField = updatedFormValues.find(({
14
+ id
15
+ }) => id === 'parentId');
16
+ const parentEntityFieldHasValue = parentEntityField && parentEntityField.value && parentEntityField.value !== SELECT_DEFAULT_VALUE;
17
+ const parentIdFieldHasValue = parentIdField && parentIdField.value;
18
+ return !!(!parentEntityFieldHasValue || parentEntityFieldHasValue && parentIdFieldHasValue);
19
+ }
20
+ async function onViewUrlClick(getFullUrl) {
21
+ const fullUrl = await getFullUrl();
22
+ if (fullUrl) {
23
+ const delimiter = fullUrl.includes('?') ? '&' : '?';
24
+ const debugParam = process.env.BLAZE_DISABLE_URL_DEBUG_PARAM ? '' : `${delimiter}${DEBUG_PARAM}`;
25
+ window.open(`${fullUrl}${debugParam}`, '_blank');
26
+ }
27
+ }
28
+ function getUpdatedFormValues({
29
+ id,
30
+ value,
31
+ requiredChildField,
32
+ formValues
33
+ }) {
34
+ const updatedFormValues = formValues ? formValues.slice() : [];
35
+ const fieldIndex = updatedFormValues.findIndex(({
36
+ id: _id
37
+ }) => _id === id);
38
+ if (fieldIndex > -1) {
39
+ updatedFormValues[fieldIndex] = _objectSpread(_objectSpread({}, updatedFormValues[fieldIndex]), {}, {
40
+ value
41
+ });
42
+ } else {
43
+ updatedFormValues.push({
44
+ id,
45
+ value
46
+ });
47
+ }
48
+ if (requiredChildField && requiredChildField.id) {
49
+ const requiredChildFieldIndex = updatedFormValues.findIndex(({
50
+ id: _id
51
+ }) => _id === requiredChildField.id);
52
+ if (requiredChildFieldIndex > -1) {
53
+ updatedFormValues[requiredChildFieldIndex] = _objectSpread(_objectSpread({}, updatedFormValues[requiredChildFieldIndex]), {}, {
54
+ value: requiredChildField.value
55
+ });
56
+ } else {
57
+ updatedFormValues.push({
58
+ id: requiredChildField.id,
59
+ value: requiredChildField.value
60
+ });
61
+ }
62
+ }
63
+ return updatedFormValues;
64
+ }
65
+ function checkFulfilConditions(...args) {
66
+ return args.every(param => param);
67
+ }
68
+ export { canViewPage, validateSideBarRelations, onViewUrlClick, getUpdatedFormValues, checkFulfilConditions };
69
+ //# sourceMappingURL=entity.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entity.js","names":["DEBUG_PARAM","ENTITY_PUBLISHED","SELECT_DEFAULT_VALUE","canViewPage","entity","schema","entityIsPublished","id","properties","slug","validateSideBarRelations","updatedFormValues","requiredChildField","parentEntityField","find","parentIdField","parentEntityFieldHasValue","value","parentIdFieldHasValue","onViewUrlClick","getFullUrl","fullUrl","delimiter","includes","debugParam","process","env","BLAZE_DISABLE_URL_DEBUG_PARAM","window","open","getUpdatedFormValues","formValues","slice","fieldIndex","findIndex","_id","_objectSpread","push","requiredChildFieldIndex","checkFulfilConditions","args","every","param"],"sources":["../../../../src/components/EntityManager/utils/entity.js"],"sourcesContent":["import { DEBUG_PARAM, ENTITY_PUBLISHED, SELECT_DEFAULT_VALUE } from '../../../constants';\n\nfunction canViewPage(entity, schema, entityIsPublished) {\n return (\n entity &&\n entity.id &&\n schema &&\n schema.id &&\n entityIsPublished === ENTITY_PUBLISHED &&\n schema.properties.slug\n );\n}\n\nfunction validateSideBarRelations(updatedFormValues, requiredChildField) {\n if (!requiredChildField) return true;\n const parentEntityField = updatedFormValues.find(({ id }) => id === 'parentEntity');\n const parentIdField = updatedFormValues.find(({ id }) => id === 'parentId');\n\n const parentEntityFieldHasValue =\n parentEntityField &&\n parentEntityField.value &&\n parentEntityField.value !== SELECT_DEFAULT_VALUE;\n const parentIdFieldHasValue = parentIdField && parentIdField.value;\n\n return !!(!parentEntityFieldHasValue || (parentEntityFieldHasValue && parentIdFieldHasValue));\n}\n\nasync function onViewUrlClick(getFullUrl) {\n const fullUrl = await getFullUrl();\n if (fullUrl) {\n const delimiter = fullUrl.includes('?') ? '&' : '?';\n const debugParam = process.env.BLAZE_DISABLE_URL_DEBUG_PARAM\n ? ''\n : `${delimiter}${DEBUG_PARAM}`;\n window.open(`${fullUrl}${debugParam}`, '_blank');\n }\n}\n\nfunction getUpdatedFormValues({ id, value, requiredChildField, formValues }) {\n const updatedFormValues = formValues ? formValues.slice() : [];\n const fieldIndex = updatedFormValues.findIndex(({ id: _id }) => _id === id);\n\n if (fieldIndex > -1) {\n updatedFormValues[fieldIndex] = { ...updatedFormValues[fieldIndex], value };\n } else {\n updatedFormValues.push({ id, value });\n }\n\n if (requiredChildField && requiredChildField.id) {\n const requiredChildFieldIndex = updatedFormValues.findIndex(\n ({ id: _id }) => _id === requiredChildField.id\n );\n if (requiredChildFieldIndex > -1) {\n updatedFormValues[requiredChildFieldIndex] = {\n ...updatedFormValues[requiredChildFieldIndex],\n value: requiredChildField.value\n };\n } else {\n updatedFormValues.push({\n id: requiredChildField.id,\n value: requiredChildField.value\n });\n }\n }\n\n return updatedFormValues;\n}\n\nfunction checkFulfilConditions(...args) {\n return args.every(param => param);\n}\n\nexport {\n canViewPage,\n validateSideBarRelations,\n onViewUrlClick,\n getUpdatedFormValues,\n checkFulfilConditions\n};\n"],"mappings":";;;AAAA,SAASA,WAAW,EAAEC,gBAAgB,EAAEC,oBAAoB,QAAQ,oBAAoB;AAExF,SAASC,WAAWA,CAACC,MAAM,EAAEC,MAAM,EAAEC,iBAAiB,EAAE;EACtD,OACEF,MAAM,IACNA,MAAM,CAACG,EAAE,IACTF,MAAM,IACNA,MAAM,CAACE,EAAE,IACTD,iBAAiB,KAAKL,gBAAgB,IACtCI,MAAM,CAACG,UAAU,CAACC,IAAI;AAE1B;AAEA,SAASC,wBAAwBA,CAACC,iBAAiB,EAAEC,kBAAkB,EAAE;EACvE,IAAI,CAACA,kBAAkB,EAAE,OAAO,IAAI;EACpC,MAAMC,iBAAiB,GAAGF,iBAAiB,CAACG,IAAI,CAAC,CAAC;IAAEP;EAAG,CAAC,KAAKA,EAAE,KAAK,cAAc,CAAC;EACnF,MAAMQ,aAAa,GAAGJ,iBAAiB,CAACG,IAAI,CAAC,CAAC;IAAEP;EAAG,CAAC,KAAKA,EAAE,KAAK,UAAU,CAAC;EAE3E,MAAMS,yBAAyB,GAC7BH,iBAAiB,IACjBA,iBAAiB,CAACI,KAAK,IACvBJ,iBAAiB,CAACI,KAAK,KAAKf,oBAAoB;EAClD,MAAMgB,qBAAqB,GAAGH,aAAa,IAAIA,aAAa,CAACE,KAAK;EAElE,OAAO,CAAC,EAAE,CAACD,yBAAyB,IAAKA,yBAAyB,IAAIE,qBAAsB,CAAC;AAC/F;AAEA,eAAeC,cAAcA,CAACC,UAAU,EAAE;EACxC,MAAMC,OAAO,GAAG,MAAMD,UAAU,CAAC,CAAC;EAClC,IAAIC,OAAO,EAAE;IACX,MAAMC,SAAS,GAAGD,OAAO,CAACE,QAAQ,CAAC,GAAG,CAAC,G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MACLN,iBAAiB,CAAC0B,IAAI,CAAC;QACrB9B,EAAE,EAAEK,kBAAkB,CAACL,EAAE;QACzBU,KAAK,EAAEL,kBAAkB,CAACK;MAC5B,CAAC,CAAC;IACJ;EACF;EAEA,OAAON,iBAAiB;AAC1B;AAEA,SAAS4B,qBAAqBA,CAAC,GAAGC,IAAI,EAAE;EACtC,OAAOA,IAAI,CAACC,KAAK,CAACC,KAAK,IAAIA,KAAK,CAAC;AACnC;AAEA,SACEvC,WAAW,EACXO,wBAAwB,EACxBS,cAAc,EACdW,oBAAoB,EACpBS,qBAAqB","ignoreList":[]}
@@ -0,0 +1,56 @@
1
+ import { getQuery, getDynamicQuery } from '@blaze-cms/admin-ui-utils';
2
+ import { BlazeError } from '@blaze-cms/core-errors';
3
+ const entityAvailableActions = {
4
+ create: async ({
5
+ client,
6
+ identifier
7
+ } = {
8
+ client: null,
9
+ identifier: null
10
+ }) => {
11
+ if (!client && !identifier) {
12
+ throw new BlazeError('Expected params client or identifier not found');
13
+ }
14
+ const query = getQuery('GET_ENTITY_SCHEMA');
15
+ const {
16
+ data: {
17
+ getEntitySchemas: [schema]
18
+ }
19
+ } = await client.query({
20
+ query,
21
+ variables: {
22
+ identifier
23
+ }
24
+ });
25
+ return [schema];
26
+ },
27
+ update: async ({
28
+ client,
29
+ identifier,
30
+ id
31
+ } = {
32
+ client: null,
33
+ identifier: null,
34
+ id: null
35
+ }) => {
36
+ if (!client && !identifier && !id) {
37
+ throw new BlazeError('Expected params client, identifier or id not found');
38
+ }
39
+ const [schema] = await entityAvailableActions.create({
40
+ client,
41
+ identifier
42
+ });
43
+ const formDataQuery = getDynamicQuery('DATA_QUERY')(schema, id);
44
+ const {
45
+ data: {
46
+ entityData
47
+ }
48
+ } = await client.query({
49
+ query: formDataQuery,
50
+ fetchPolicy: 'network-only'
51
+ });
52
+ return [schema, entityData, formDataQuery];
53
+ }
54
+ };
55
+ export default entityAvailableActions;
56
+ //# sourceMappingURL=entityAvailableActions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"entityAvailableActions.js","names":["getQuery","getDynamicQuery","BlazeError","entityAvailableActions","create","client","identifier","query","data","getEntitySchemas","schema","variables","update","id","formDataQuery","entityData","fetchPolicy"],"sources":["../../../../src/components/EntityManager/utils/entityAvailableActions.js"],"sourcesContent":["import { getQuery, getDynamicQuery } from '@blaze-cms/admin-ui-utils';\nimport { BlazeError } from '@blaze-cms/core-errors';\n\nconst entityAvailableActions = {\n create: async ({ client, identifier } = { client: null, identifier: null }) => {\n if (!client && !identifier) {\n throw new BlazeError('Expected params client or identifier not found');\n }\n const query = getQuery('GET_ENTITY_SCHEMA');\n const {\n data: {\n getEntitySchemas: [schema]\n }\n } = await client.query({ query, variables: { identifier } });\n return [schema];\n },\n update: async ({ client, identifier, id } = { client: null, identifier: null, id: null }) => {\n if (!client && !identifier && !id) {\n throw new BlazeError('Expected params client, identifier or id not found');\n }\n const [schema] = await entityAvailableActions.create({ client, identifier });\n const formDataQuery = getDynamicQuery('DATA_QUERY')(schema, id);\n const {\n data: { entityData }\n } = await client.query({ query: formDataQuery, fetchPolicy: 'network-only' });\n return [schema, entityData, formDataQuery];\n }\n};\n\nexport default entityAvailableActions;\n"],"mappings":"AAAA,SAASA,QAAQ,EAAEC,eAAe,QAAQ,2BAA2B;AACrE,SAASC,UAAU,QAAQ,wBAAwB;AAEnD,MAAMC,sBAAsB,GAAG;EAC7BC,MAAM,EAAE,MAAAA,CAAO;IAAEC,MAAM;IAAEC;EAAW,CAAC,GAAG;IAAED,MAAM,EAAE,IAAI;IAAEC,UAAU,EAAE;EAAK,CAAC,KAAK;IAC7E,IAAI,CAACD,MAAM,IAAI,CAACC,UAAU,EAAE;MAC1B,MAAM,IAAIJ,UAAU,CAAC,gDAAgD,CAAC;IACxE;IACA,MAAMK,KAAK,GAAGP,QAAQ,CAAC,mBAAmB,CAAC;IAC3C,MAAM;MACJQ,IAAI,EAAE;QACJC,gBAAgB,EAAE,CAACC,MAAM;MAC3B;IACF,CAAC,GAAG,MAAML,MAAM,CAACE,KAAK,CAAC;MAAEA,KAAK;MAAEI,SAAS,EAAE;QAAEL;MAAW;IAAE,CAAC,CAAC;IAC5D,OAAO,CAACI,MAAM,CAAC;EACjB,CAAC;EACDE,MAAM,EAAE,MAAAA,CAAO;IAAEP,MAAM;IAAEC,UAAU;IAAEO;EAAG,CAAC,GAAG;IAAER,MAAM,EAAE,IAAI;IAAEC,UAAU,EAAE,IAAI;IAAEO,EAAE,EAAE;EAAK,CAAC,KAAK;IAC3F,IAAI,CAACR,MAAM,IAAI,CAACC,UAAU,IAAI,CAACO,EAAE,EAAE;MACjC,MAAM,IAAIX,UAAU,CAAC,oDAAoD,CAAC;IAC5E;IACA,MAAM,CAACQ,MAAM,CAAC,GAAG,MAAMP,sBAAsB,CAACC,MAAM,CAAC;MAAEC,MAAM;MAAEC;IAAW,CAAC,CAAC;IAC5E,MAAMQ,aAAa,GAAGb,eAAe,CAAC,YAAY,CAAC,CAACS,MAAM,EAAEG,EAAE,CAAC;IAC/D,MAAM;MACJL,IAAI,EAAE;QAAEO;MAAW;IACrB,CAAC,GAAG,MAAMV,MAAM,CAACE,KAAK,CAAC;MAAEA,KAAK,EAAEO,aAAa;MAAEE,WAAW,EAAE;IAAe,CAAC,CAAC;IAC7E,OAAO,CAACN,MAAM,EAAEK,UAAU,EAAED,aAAa,CAAC;EAC5C;AACF,CAAC;AAED,eAAeX,sBAAsB","ignoreList":[]}
@@ -0,0 +1,9 @@
1
+ import isEmpty from 'lodash.isempty';
2
+ const isFormEmpty = formValues => {
3
+ if (!formValues) return false;
4
+ return !formValues.some(({
5
+ value
6
+ }) => typeof value === 'boolean' ? value : !isEmpty(value));
7
+ };
8
+ export default isFormEmpty;
9
+ //# sourceMappingURL=is-form-empty.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"is-form-empty.js","names":["isEmpty","isFormEmpty","formValues","some","value"],"sources":["../../../../src/components/EntityManager/utils/is-form-empty.js"],"sourcesContent":["import isEmpty from 'lodash.isempty';\n\nconst isFormEmpty = formValues => {\n if (!formValues) return false;\n return !formValues.some(({ value }) => (typeof value === 'boolean' ? value : !isEmpty(value)));\n};\n\nexport default isFormEmpty;\n"],"mappings":"AAAA,OAAOA,OAAO,MAAM,gBAAgB;AAEpC,MAAMC,WAAW,GAAGC,UAAU,IAAI;EAChC,IAAI,CAACA,UAAU,EAAE,OAAO,KAAK;EAC7B,OAAO,CAACA,UAAU,CAACC,IAAI,CAAC,CAAC;IAAEC;EAAM,CAAC,KAAM,OAAOA,KAAK,KAAK,SAAS,GAAGA,KAAK,GAAG,CAACJ,OAAO,CAACI,KAAK,CAAE,CAAC;AAChG,CAAC;AAED,eAAeH,WAAW","ignoreList":[]}
@@ -0,0 +1,23 @@
1
+ import { gql } from '@apollo/client';
2
+ import upperFirst from 'lodash.upperfirst';
3
+ const generateQuery = (action, props) => `
4
+ query getEntityData(
5
+ $where: JSON
6
+ $limit: Int
7
+ $offset: Int
8
+ $sort: [${upperFirst(action)}SortItem]){
9
+ ${action} (where: $where, limit: $limit, offset: $offset, sort: $sort){
10
+ ${props}
11
+ }
12
+ }
13
+ `;
14
+
15
+ // TODO: extend function to handle properties and make them dynamic with a config schema for each entity.
16
+ const getAction = (action, props) => {
17
+ const query = generateQuery(action, props);
18
+ return gql`
19
+ ${query}
20
+ `;
21
+ };
22
+ export { getAction };
23
+ //# sourceMappingURL=query.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query.js","names":["gql","upperFirst","generateQuery","action","props","getAction","query"],"sources":["../../../../src/components/EntityManager/utils/query.js"],"sourcesContent":["import { gql } from '@apollo/client';\nimport upperFirst from 'lodash.upperfirst';\n\nconst generateQuery = (action, props) => `\n query getEntityData(\n $where: JSON\n $limit: Int\n $offset: Int\n $sort: [${upperFirst(action)}SortItem]){\n ${action} (where: $where, limit: $limit, offset: $offset, sort: $sort){\n ${props}\n }\n }\n `;\n\n// TODO: extend function to handle properties and make them dynamic with a config schema for each entity.\nconst getAction = (action, props) => {\n const query = generateQuery(action, props);\n return gql`\n ${query}\n `;\n};\n\nexport { getAction };\n"],"mappings":"AAAA,SAASA,GAAG,QAAQ,gBAAgB;AACpC,OAAOC,UAAU,MAAM,mBAAmB;AAE1C,MAAMC,aAAa,GAAGA,CAACC,MAAM,EAAEC,KAAK,KAAK;AACzC;AACA;AACA;AACA;AACA,cAAcH,UAAU,CAACE,MAAM,CAAC;AAChC,MAAMA,MAAM;AACZ,QAAQC,KAAK;AACb;AACA;AACA,GAAG;;AAEH;AACA,MAAMC,SAAS,GAAGA,CAACF,MAAM,EAAEC,KAAK,KAAK;EACnC,MAAME,KAAK,GAAGJ,aAAa,CAACC,MAAM,EAAEC,KAAK,CAAC;EAC1C,OAAOJ,GAAG;AACZ,MAAMM,KAAK;AACX,GAAG;AACH,CAAC;AAED,SAASD,SAAS","ignoreList":[]}
@@ -0,0 +1,36 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ const _excluded = ["info"];
4
+ import React from 'react';
5
+ import PropTypes from 'prop-types';
6
+ import Tooltip from '@blaze-react/tooltip';
7
+ const InfoBoxTooltip = _ref => {
8
+ let {
9
+ info
10
+ } = _ref,
11
+ tooltipProps = _objectWithoutProperties(_ref, _excluded);
12
+ const {
13
+ tooltipContent,
14
+ tooltipIcon
15
+ } = info;
16
+ if (!tooltipContent) return null;
17
+ const renderTooltipIcon = icon => {
18
+ if (!icon) return null;
19
+ return /*#__PURE__*/React.createElement("i", {
20
+ className: `${icon} info-box--icon`
21
+ });
22
+ };
23
+ return /*#__PURE__*/React.createElement(Tooltip, _extends({
24
+ tooltipContent: tooltipContent,
25
+ trigger: "click",
26
+ className: "info-box--tooltip"
27
+ }, tooltipProps), renderTooltipIcon(tooltipIcon));
28
+ };
29
+ InfoBoxTooltip.propTypes = {
30
+ info: PropTypes.shape({
31
+ tooltipContent: PropTypes.node,
32
+ tooltipIcon: PropTypes.string
33
+ }).isRequired
34
+ };
35
+ export default InfoBoxTooltip;
36
+ //# sourceMappingURL=InfoBoxTooltip.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InfoBoxTooltip.js","names":["React","PropTypes","Tooltip","InfoBoxTooltip","_ref","info","tooltipProps","_objectWithoutProperties","_excluded","tooltipContent","tooltipIcon","renderTooltipIcon","icon","createElement","className","_extends","trigger","propTypes","shape","node","string","isRequired"],"sources":["../../../src/components/InfoBoxes/InfoBoxTooltip.js"],"sourcesContent":["import React from 'react';\nimport PropTypes from 'prop-types';\nimport Tooltip from '@blaze-react/tooltip';\n\nconst InfoBoxTooltip = ({ info, ...tooltipProps }) => {\n const { tooltipContent, tooltipIcon } = info;\n if (!tooltipContent) return null;\n\n const renderTooltipIcon = icon => {\n if (!icon) return null;\n return <i className={`${icon} info-box--icon`} />;\n };\n\n return (\n <Tooltip\n tooltipContent={tooltipContent}\n trigger=\"click\"\n className=\"info-box--tooltip\"\n {...tooltipProps}>\n {renderTooltipIcon(tooltipIcon)}\n </Tooltip>\n );\n};\n\nInfoBoxTooltip.propTypes = {\n info: PropTypes.shape({\n tooltipContent: PropTypes.node,\n tooltipIcon: PropTypes.string\n }).isRequired\n};\n\nexport default InfoBoxTooltip;\n"],"mappings":";;;AAAA,OAAOA,KAAK,MAAM,OAAO;AACzB,OAAOC,SAAS,MAAM,YAAY;AAClC,OAAOC,OAAO,MAAM,sBAAsB;AAE1C,MAAMC,cAAc,GAAGC,IAAA,IAA+B;EAAA,IAA9B;MAAEC;IAAsB,CAAC,GAAAD,IAAA;IAAdE,YAAY,GAAAC,wBAAA,CAAAH,IAAA,EAAAI,SAAA;EAC7C,MAAM;IAAEC,cAAc;IAAEC;EAAY,CAAC,GAAGL,IAAI;EAC5C,IAAI,CAACI,cAAc,EAAE,OAAO,IAAI;EAEhC,MAAME,iBAAiB,GAAGC,IAAI,IAAI;IAChC,IAAI,CAACA,IAAI,EAAE,OAAO,IAAI;IACtB,oBAAOZ,KAAA,CAAAa,aAAA;MAAGC,SAAS,EAAE,GAAGF,IAAI;IAAkB,CAAE,CAAC;EACnD,CAAC;EAED,oBACEZ,KAAA,CAAAa,aAAA,CAACX,OAAO,EAAAa,QAAA;IACNN,cAAc,EAAEA,cAAe;IAC/BO,OAAO,EAAC,OAAO;IACfF,SAAS,EAAC;EAAmB,GACzBR,YAAY,GACfK,iBAAiB,CAACD,WAAW,CACvB,CAAC;AAEd,CAAC;AAEDP,cAAc,CAACc,SAAS,GAAG;EACzBZ,IAAI,EAAEJ,SAAS,CAACiB,KAAK,CAAC;IACpBT,cAAc,EAAER,SAAS,CAACkB,IAAI;IAC9BT,WAAW,EAAET,SAAS,CAACmB;EACzB,CAAC,CAAC,CAACC;AACL,CAAC;AAED,eAAelB,cAAc","ignoreList":[]}
@@ -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","ignoreList":[]}
@@ -0,0 +1,38 @@
1
+ import PropTypes from 'prop-types';
2
+ import React, { useContext, useEffect } from 'react';
3
+ import useData from '../hooks/useData';
4
+ import InfoBox from '../presentational/InfoBox';
5
+ import { RecordEditContext } from '../../EntityManager/utils/RecordEditContext';
6
+ const InfoBoxContainer = ({
7
+ id,
8
+ schema,
9
+ infoBox
10
+ }) => {
11
+ const {
12
+ externalUpdateTime
13
+ } = useContext(RecordEditContext);
14
+ const {
15
+ data,
16
+ refetch
17
+ } = useData({
18
+ id,
19
+ schema,
20
+ infoBox
21
+ });
22
+ useEffect(() => {
23
+ refetch();
24
+ }, [externalUpdateTime, refetch]);
25
+ if (!data || !Object.keys(data) || Object.keys(data).length === 0) return null;
26
+ const items = Object.values(data).flatMap(item => Object.values(item));
27
+ return /*#__PURE__*/React.createElement(InfoBox, {
28
+ items: items,
29
+ infoBoxKey: infoBox.key
30
+ });
31
+ };
32
+ export default InfoBoxContainer;
33
+ InfoBoxContainer.propTypes = {
34
+ id: PropTypes.string.isRequired,
35
+ infoBox: PropTypes.object.isRequired,
36
+ schema: PropTypes.object.isRequired
37
+ };
38
+ //# sourceMappingURL=InfoBoxContainer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InfoBoxContainer.js","names":["PropTypes","React","useContext","useEffect","useData","InfoBox","RecordEditContext","InfoBoxContainer","id","schema","infoBox","externalUpdateTime","data","refetch","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, { useContext, useEffect } from 'react';\nimport useData from '../hooks/useData';\nimport InfoBox from '../presentational/InfoBox';\nimport { RecordEditContext } from '../../EntityManager/utils/RecordEditContext';\n\nconst InfoBoxContainer = ({ id, schema, infoBox }) => {\n const { externalUpdateTime } = useContext(RecordEditContext);\n\n const { data, refetch } = useData({ id, schema, infoBox });\n\n useEffect(() => {\n refetch();\n }, [externalUpdateTime, refetch]);\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.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