@blaze-cms/plugin-data-ui 0.146.0-translations.8 → 0.147.0-rc-eagle.4

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 (211) hide show
  1. package/lib/components/EntityDataListing/EntityDataListing.js +21 -19
  2. package/lib/components/EntityDataListing/EntityDataListing.js.map +1 -1
  3. package/lib/components/EntityDataListing/index.js +2 -3
  4. package/lib/components/EntityDataListing/index.js.map +1 -1
  5. package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js +18 -19
  6. package/lib/components/EntityManager/Entity/EntitiyNavLinks/EntityNavLinks.js.map +1 -1
  7. package/lib/components/EntityManager/Entity/EntitiyNavLinks/index.js +2 -3
  8. package/lib/components/EntityManager/Entity/EntitiyNavLinks/index.js.map +1 -1
  9. package/lib/components/EntityManager/Entity/Entity.js +284 -457
  10. package/lib/components/EntityManager/Entity/Entity.js.map +1 -1
  11. package/lib/components/EntityManager/Entity/EntityHeader/EntityHeader.js +62 -66
  12. package/lib/components/EntityManager/Entity/EntityHeader/EntityHeader.js.map +1 -1
  13. package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js +32 -56
  14. package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js.map +1 -1
  15. package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/index.js +2 -3
  16. package/lib/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/index.js.map +1 -1
  17. package/lib/components/EntityManager/Entity/EntityHeader/index.js +2 -3
  18. package/lib/components/EntityManager/Entity/EntityHeader/index.js.map +1 -1
  19. package/lib/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js +20 -26
  20. package/lib/components/EntityManager/Entity/SideBarRelations/container/CustomSidebarInfoContainer.js.map +1 -1
  21. package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js +20 -17
  22. package/lib/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +1 -1
  23. package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +34 -32
  24. package/lib/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +1 -1
  25. package/lib/components/EntityManager/Entity/SideBarRelations/index.js +95 -158
  26. package/lib/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
  27. package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js +23 -30
  28. package/lib/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +1 -1
  29. package/lib/components/EntityManager/Entity/actions-handlers/create/index.js +2 -3
  30. package/lib/components/EntityManager/Entity/actions-handlers/create/index.js.map +1 -1
  31. package/lib/components/EntityManager/Entity/actions-handlers/create/submit.js +42 -56
  32. package/lib/components/EntityManager/Entity/actions-handlers/create/submit.js.map +1 -1
  33. package/lib/components/EntityManager/Entity/actions-handlers/delete/delete.js +29 -45
  34. package/lib/components/EntityManager/Entity/actions-handlers/delete/delete.js.map +1 -1
  35. package/lib/components/EntityManager/Entity/actions-handlers/delete/index.js +2 -3
  36. package/lib/components/EntityManager/Entity/actions-handlers/delete/index.js.map +1 -1
  37. package/lib/components/EntityManager/Entity/actions-handlers/index.js +7 -8
  38. package/lib/components/EntityManager/Entity/actions-handlers/index.js.map +1 -1
  39. package/lib/components/EntityManager/Entity/actions-handlers/shared/index.js +2 -3
  40. package/lib/components/EntityManager/Entity/actions-handlers/shared/index.js.map +1 -1
  41. package/lib/components/EntityManager/Entity/actions-handlers/shared/publish.js +36 -57
  42. package/lib/components/EntityManager/Entity/actions-handlers/shared/publish.js.map +1 -1
  43. package/lib/components/EntityManager/Entity/actions-handlers/update/index.js +2 -3
  44. package/lib/components/EntityManager/Entity/actions-handlers/update/index.js.map +1 -1
  45. package/lib/components/EntityManager/Entity/actions-handlers/update/submit.js +47 -66
  46. package/lib/components/EntityManager/Entity/actions-handlers/update/submit.js.map +1 -1
  47. package/lib/components/EntityManager/Entity/index.js +2 -3
  48. package/lib/components/EntityManager/Entity/index.js.map +1 -1
  49. package/lib/components/EntityManager/EntityManager.js +91 -166
  50. package/lib/components/EntityManager/EntityManager.js.map +1 -1
  51. package/lib/components/EntityManager/index.js +2 -3
  52. package/lib/components/EntityManager/index.js.map +1 -1
  53. package/lib/components/EntityManager/utils/RecordEditContext/index.js +3 -4
  54. package/lib/components/EntityManager/utils/RecordEditContext/index.js.map +1 -1
  55. package/lib/components/EntityManager/utils/data-mappers.js +34 -46
  56. package/lib/components/EntityManager/utils/data-mappers.js.map +1 -1
  57. package/lib/components/EntityManager/utils/entity.js +35 -80
  58. package/lib/components/EntityManager/utils/entity.js.map +1 -1
  59. package/lib/components/EntityManager/utils/entityAvailableActions.js +51 -110
  60. package/lib/components/EntityManager/utils/entityAvailableActions.js.map +1 -1
  61. package/lib/components/EntityManager/utils/is-form-empty.js +6 -10
  62. package/lib/components/EntityManager/utils/is-form-empty.js.map +1 -1
  63. package/lib/components/EntityManager/utils/query.js +17 -10
  64. package/lib/components/EntityManager/utils/query.js.map +1 -1
  65. package/lib/components/InfoBoxes/InfoBoxTooltip.js +19 -16
  66. package/lib/components/InfoBoxes/InfoBoxTooltip.js.map +1 -1
  67. package/lib/components/InfoBoxes/InfoBoxes.js +19 -19
  68. package/lib/components/InfoBoxes/InfoBoxes.js.map +1 -1
  69. package/lib/components/InfoBoxes/container/InfoBoxContainer.js +26 -38
  70. package/lib/components/InfoBoxes/container/InfoBoxContainer.js.map +1 -1
  71. package/lib/components/InfoBoxes/helpers/build-dynamic-query.js +21 -16
  72. package/lib/components/InfoBoxes/helpers/build-dynamic-query.js.map +1 -1
  73. package/lib/components/InfoBoxes/hooks/useData.js +33 -30
  74. package/lib/components/InfoBoxes/hooks/useData.js.map +1 -1
  75. package/lib/components/InfoBoxes/hooks/useInfoBox.js +10 -10
  76. package/lib/components/InfoBoxes/hooks/useInfoBox.js.map +1 -1
  77. package/lib/components/InfoBoxes/index.js +2 -3
  78. package/lib/components/InfoBoxes/index.js.map +1 -1
  79. package/lib/components/InfoBoxes/presentational/InfoBox.js +27 -34
  80. package/lib/components/InfoBoxes/presentational/InfoBox.js.map +1 -1
  81. package/lib/components/InfoBoxes/presentational/InfoBoxLabel.js +11 -12
  82. package/lib/components/InfoBoxes/presentational/InfoBoxLabel.js.map +1 -1
  83. package/lib/components/InfoBoxes/presentational/InfoBoxValue.js +12 -12
  84. package/lib/components/InfoBoxes/presentational/InfoBoxValue.js.map +1 -1
  85. package/lib/components/ListingTable/ListingTable.js +155 -296
  86. package/lib/components/ListingTable/ListingTable.js.map +1 -1
  87. package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js +53 -58
  88. package/lib/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
  89. package/lib/components/ListingTable/ListingTableContent/index.js +2 -3
  90. package/lib/components/ListingTable/ListingTableContent/index.js.map +1 -1
  91. package/lib/components/ListingTable/SearchFilter/SearchContainer.js +436 -262
  92. package/lib/components/ListingTable/SearchFilter/SearchContainer.js.map +1 -1
  93. package/lib/components/ListingTable/SearchFilter/SearchFilter.js +30 -37
  94. package/lib/components/ListingTable/SearchFilter/SearchFilter.js.map +1 -1
  95. package/lib/components/ListingTable/SearchFilter/helpers.js +82 -71
  96. package/lib/components/ListingTable/SearchFilter/helpers.js.map +1 -1
  97. package/lib/components/ListingTable/SearchFilter/querys.js +5 -5
  98. package/lib/components/ListingTable/SearchFilter/querys.js.map +1 -1
  99. package/lib/components/ListingTable/TableActions/TableActions.js +27 -31
  100. package/lib/components/ListingTable/TableActions/TableActions.js.map +1 -1
  101. package/lib/components/ListingTable/TableActions/index.js +2 -3
  102. package/lib/components/ListingTable/TableActions/index.js.map +1 -1
  103. package/lib/components/ListingTable/index.js +2 -3
  104. package/lib/components/ListingTable/index.js.map +1 -1
  105. package/lib/components/ListingTable/mappers/populate-rows.js +103 -122
  106. package/lib/components/ListingTable/mappers/populate-rows.js.map +1 -1
  107. package/lib/components/ListingTable/service/index.js +66 -83
  108. package/lib/components/ListingTable/service/index.js.map +1 -1
  109. package/lib/components/Tabs/index.js +26 -42
  110. package/lib/components/Tabs/index.js.map +1 -1
  111. package/lib/components/hooks/useCallbackDebounce.js +5 -9
  112. package/lib/components/hooks/useCallbackDebounce.js.map +1 -1
  113. package/lib/constants.js +30 -31
  114. package/lib/constants.js.map +1 -1
  115. package/lib/icons/ContentIcon.js +17 -20
  116. package/lib/icons/ContentIcon.js.map +1 -1
  117. package/lib/icons/SettingsIcon.js +12 -15
  118. package/lib/icons/SettingsIcon.js.map +1 -1
  119. package/lib/icons/TaxonomyIcon.js +15 -18
  120. package/lib/icons/TaxonomyIcon.js.map +1 -1
  121. package/lib/icons/UsersIcon.js +11 -14
  122. package/lib/icons/UsersIcon.js.map +1 -1
  123. package/lib/icons/index.js +8 -9
  124. package/lib/icons/index.js.map +1 -1
  125. package/lib/index.js +88 -121
  126. package/lib/index.js.map +1 -1
  127. package/lib/utils/add-content-menu-items.js +67 -93
  128. package/lib/utils/add-content-menu-items.js.map +1 -1
  129. package/lib/utils/build-create-entity-mutation.js +12 -9
  130. package/lib/utils/build-create-entity-mutation.js.map +1 -1
  131. package/lib/utils/build-delete-entity-mutation.js +11 -8
  132. package/lib/utils/build-delete-entity-mutation.js.map +1 -1
  133. package/lib/utils/build-listing-query.js +17 -14
  134. package/lib/utils/build-listing-query.js.map +1 -1
  135. package/lib/utils/build-update-data-query.js +15 -9
  136. package/lib/utils/build-update-data-query.js.map +1 -1
  137. package/lib/utils/build-update-publish-unpublish-mutation.js +15 -8
  138. package/lib/utils/build-update-publish-unpublish-mutation.js.map +1 -1
  139. package/lib/utils/get-default-query-params.js +7 -6
  140. package/lib/utils/get-default-query-params.js.map +1 -1
  141. package/lib/utils/hoc/withContext.js +4 -6
  142. package/lib/utils/hoc/withContext.js.map +1 -1
  143. package/lib/utils/hooks/useToggle.js +4 -12
  144. package/lib/utils/hooks/useToggle.js.map +1 -1
  145. package/lib/utils/index.js +2 -3
  146. package/lib/utils/index.js.map +1 -1
  147. package/lib-es/components/EntityManager/Entity/Entity.js +8 -20
  148. package/lib-es/components/EntityManager/Entity/Entity.js.map +1 -1
  149. package/lib-es/components/EntityManager/Entity/EntityHeader/EntityHeader.js.map +1 -1
  150. package/lib-es/components/EntityManager/Entity/EntityHeader/HeaderPreviewButton/HeaderPreviewButton.js.map +1 -1
  151. package/lib-es/components/EntityManager/Entity/SideBarRelations/helpers/build-dynamic-query.js.map +1 -1
  152. package/lib-es/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js.map +1 -1
  153. package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js +6 -3
  154. package/lib-es/components/EntityManager/Entity/SideBarRelations/index.js.map +1 -1
  155. package/lib-es/components/EntityManager/Entity/SideBarRelations/presentational/CustomSidebarInfo.js.map +1 -1
  156. package/lib-es/components/EntityManager/Entity/actions-handlers/create/submit.js.map +1 -1
  157. package/lib-es/components/EntityManager/Entity/actions-handlers/shared/publish.js.map +1 -1
  158. package/lib-es/components/EntityManager/EntityManager.js.map +1 -1
  159. package/lib-es/components/EntityManager/utils/entity.js.map +1 -1
  160. package/lib-es/components/EntityManager/utils/query.js.map +1 -1
  161. package/lib-es/components/InfoBoxes/InfoBoxTooltip.js.map +1 -1
  162. package/lib-es/components/InfoBoxes/container/InfoBoxContainer.js.map +1 -1
  163. package/lib-es/components/InfoBoxes/helpers/build-dynamic-query.js.map +1 -1
  164. package/lib-es/components/InfoBoxes/hooks/useData.js.map +1 -1
  165. package/lib-es/components/InfoBoxes/presentational/InfoBox.js.map +1 -1
  166. package/lib-es/components/InfoBoxes/presentational/InfoBoxLabel.js.map +1 -1
  167. package/lib-es/components/ListingTable/ListingTable.js +2 -2
  168. package/lib-es/components/ListingTable/ListingTable.js.map +1 -1
  169. package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js +20 -17
  170. package/lib-es/components/ListingTable/ListingTableContent/ListingTableContent.js.map +1 -1
  171. package/lib-es/components/ListingTable/SearchFilter/SearchContainer.js +323 -51
  172. package/lib-es/components/ListingTable/SearchFilter/SearchContainer.js.map +1 -1
  173. package/lib-es/components/ListingTable/SearchFilter/SearchFilter.js +7 -3
  174. package/lib-es/components/ListingTable/SearchFilter/SearchFilter.js.map +1 -1
  175. package/lib-es/components/ListingTable/SearchFilter/helpers.js +39 -8
  176. package/lib-es/components/ListingTable/SearchFilter/helpers.js.map +1 -1
  177. package/lib-es/components/ListingTable/SearchFilter/querys.js.map +1 -1
  178. package/lib-es/components/ListingTable/mappers/populate-rows.js.map +1 -1
  179. package/lib-es/components/ListingTable/service/index.js.map +1 -1
  180. package/lib-es/components/Tabs/index.js +6 -7
  181. package/lib-es/components/Tabs/index.js.map +1 -1
  182. package/lib-es/index.js +12 -3
  183. package/lib-es/index.js.map +1 -1
  184. package/lib-es/utils/add-content-menu-items.js.map +1 -1
  185. package/lib-es/utils/build-create-entity-mutation.js.map +1 -1
  186. package/lib-es/utils/build-delete-entity-mutation.js.map +1 -1
  187. package/lib-es/utils/build-listing-query.js.map +1 -1
  188. package/lib-es/utils/build-update-data-query.js.map +1 -1
  189. package/lib-es/utils/build-update-publish-unpublish-mutation.js.map +1 -1
  190. package/lib-es/utils/hoc/withContext.js +1 -1
  191. package/lib-es/utils/hoc/withContext.js.map +1 -1
  192. package/package.json +27 -22
  193. package/src/components/EntityManager/Entity/Entity.js +59 -77
  194. package/src/components/EntityManager/Entity/EntityHeader/EntityHeader.js +1 -2
  195. package/src/components/EntityManager/Entity/SideBarRelations/hooks/useCustomSidebarData.js +9 -7
  196. package/src/components/EntityManager/Entity/SideBarRelations/index.js +64 -59
  197. package/src/components/EntityManager/EntityManager.js +52 -45
  198. package/src/components/InfoBoxes/container/InfoBoxContainer.js +3 -6
  199. package/src/components/InfoBoxes/hooks/useData.js +6 -1
  200. package/src/components/ListingTable/ListingTable.js +13 -21
  201. package/src/components/ListingTable/ListingTableContent/ListingTableContent.js +38 -44
  202. package/src/components/ListingTable/SearchFilter/SearchContainer.js +411 -134
  203. package/src/components/ListingTable/SearchFilter/SearchFilter.js +5 -2
  204. package/src/components/ListingTable/SearchFilter/helpers.js +56 -8
  205. package/src/components/ListingTable/service/index.js +2 -3
  206. package/src/components/Tabs/index.js +17 -21
  207. package/src/index.js +11 -7
  208. package/src/utils/hoc/withContext.js +5 -4
  209. package/CHANGELOG.md +0 -1947
  210. package/babel.config.js +0 -3
  211. package/jest.config.js +0 -5
@@ -1,38 +1,12 @@
1
1
  "use strict";
2
2
 
3
- require("core-js/modules/es.symbol.js");
4
- require("core-js/modules/es.object.define-properties.js");
5
- require("core-js/modules/es.object.define-property.js");
6
- require("core-js/modules/es.object.get-own-property-descriptor.js");
7
- require("core-js/modules/es.object.get-own-property-descriptors.js");
8
- require("core-js/modules/es.object.keys.js");
9
- require("core-js/modules/es.string.iterator.js");
10
- require("core-js/modules/es.weak-map.js");
11
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
12
- var _typeof = require("@babel/runtime/helpers/typeof");
13
4
  Object.defineProperty(exports, "__esModule", {
14
5
  value: true
15
6
  });
16
- exports["default"] = void 0;
17
- var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
7
+ exports.default = void 0;
18
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
19
9
  var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
20
- var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
21
- require("core-js/modules/es.array.concat.js");
22
- require("core-js/modules/es.array.filter.js");
23
- require("core-js/modules/es.array.find-index.js");
24
- require("core-js/modules/es.array.for-each.js");
25
- require("core-js/modules/es.array.includes.js");
26
- require("core-js/modules/es.array.iterator.js");
27
- require("core-js/modules/es.array.map.js");
28
- require("core-js/modules/es.array.slice.js");
29
- require("core-js/modules/es.function.name.js");
30
- require("core-js/modules/es.object.to-string.js");
31
- require("core-js/modules/es.string.includes.js");
32
- require("core-js/modules/web.dom-collections.for-each.js");
33
- require("core-js/modules/web.dom-collections.iterator.js");
34
- var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
35
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
36
10
  var _react = _interopRequireWildcard(require("react"));
37
11
  var _reactRouterDom = require("react-router-dom");
38
12
  var _client = require("@apollo/client");
@@ -47,138 +21,74 @@ var _dataMappers = require("../utils/data-mappers");
47
21
  var _isFormEmpty = _interopRequireDefault(require("../utils/is-form-empty"));
48
22
  var _actionsHandlers = _interopRequireDefault(require("./actions-handlers"));
49
23
  var _SideBarRelations = _interopRequireDefault(require("./SideBarRelations"));
50
- var _Tabs = _interopRequireDefault(require("../../Tabs"));
51
24
  var _useCallbackDebounce = _interopRequireDefault(require("../../hooks/useCallbackDebounce"));
52
25
  var _constants = require("../../../constants");
53
26
  var _EntityHeader = _interopRequireDefault(require("./EntityHeader"));
54
27
  var _entity = require("../utils/entity");
55
- var _useToggle5 = _interopRequireDefault(require("../../../utils/hooks/useToggle"));
28
+ var _useToggle = _interopRequireDefault(require("../../../utils/hooks/useToggle"));
56
29
  var _InfoBoxes = _interopRequireDefault(require("../../InfoBoxes/InfoBoxes"));
57
30
  var _RecordEditContext = require("../utils/RecordEditContext");
58
- var _excluded = ["isValid", "fields", "isNewValueSet", "valuesChecked", "currentField", "value"];
31
+ const _excluded = ["isValid", "fields", "isNewValueSet", "valuesChecked", "currentField", "value"];
59
32
  /* eslint-disable no-undef */
60
- function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
61
- function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
33
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function (e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != typeof e && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (const t in e) "default" !== t && {}.hasOwnProperty.call(e, t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, t)) && (i.get || i.set) ? o(f, t, i) : f[t] = e[t]); return f; })(e, t); }
62
34
  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; }
63
- 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) { (0, _defineProperty2["default"])(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; }
64
- var Entity = function Entity(_ref) {
65
- var _schema$interfaces, _schema$interfaces2, _formData$values;
66
- var formData = _ref.formData,
67
- entity = _ref.entity,
68
- schema = _ref.schema,
69
- previousQuery = _ref.previousQuery,
70
- action = _ref.action,
71
- history = _ref.history,
72
- updateFormData = _ref.updateFormData,
73
- onViewUrl = _ref.onViewUrl,
74
- refetchRecord = _ref.refetchRecord;
75
- var _useState = (0, _react.useState)(null),
76
- _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
77
- setCurrentTabId = _useState2[1];
78
- var _useState3 = (0, _react.useState)(null),
79
- _useState4 = (0, _slicedToArray2["default"])(_useState3, 2),
80
- formValues = _useState4[0],
81
- setFormValues = _useState4[1];
82
- var _useState5 = (0, _react.useState)(null),
83
- _useState6 = (0, _slicedToArray2["default"])(_useState5, 2),
84
- entitySchema = _useState6[0],
85
- setEntitySchema = _useState6[1];
86
- var _useState7 = (0, _react.useState)(null),
87
- _useState8 = (0, _slicedToArray2["default"])(_useState7, 2),
88
- entityData = _useState8[0],
89
- setEntityData = _useState8[1];
90
- var _useState9 = (0, _react.useState)(null),
91
- _useState10 = (0, _slicedToArray2["default"])(_useState9, 2),
92
- entityIdentifier = _useState10[0],
93
- setEntityIdentifier = _useState10[1];
94
- var _useState11 = (0, _react.useState)(''),
95
- _useState12 = (0, _slicedToArray2["default"])(_useState11, 2),
96
- pageTitle = _useState12[0],
97
- setPageTitle = _useState12[1];
98
- var _useState13 = (0, _react.useState)(false),
99
- _useState14 = (0, _slicedToArray2["default"])(_useState13, 2),
100
- isSaveButtonAvailable = _useState14[0],
101
- setIsSaveButtonAvailable = _useState14[1];
102
- var _useState15 = (0, _react.useState)(formData && formData.values && formData.values.status),
103
- _useState16 = (0, _slicedToArray2["default"])(_useState15, 2),
104
- entityIsPublished = _useState16[0],
105
- setEntityIsPublish = _useState16[1];
106
- var _useState17 = (0, _react.useState)(false),
107
- _useState18 = (0, _slicedToArray2["default"])(_useState17, 2),
108
- isEnablePublishButton = _useState18[0],
109
- setEnablePublishButton = _useState18[1];
110
- var _useState19 = (0, _react.useState)(false),
111
- _useState20 = (0, _slicedToArray2["default"])(_useState19, 2),
112
- isEnablePreviewButton = _useState20[0],
113
- setEnablePreviewButton = _useState20[1];
114
- var _useToggle = (0, _useToggle5["default"])(false),
115
- _useToggle2 = (0, _slicedToArray2["default"])(_useToggle, 2),
116
- modalStatus = _useToggle2[0],
117
- setModalStatus = _useToggle2[1];
118
- var _useToggle3 = (0, _useToggle5["default"])(false),
119
- _useToggle4 = (0, _slicedToArray2["default"])(_useToggle3, 2),
120
- copyModalStatus = _useToggle4[0],
121
- setCopyModalStatus = _useToggle4[1];
122
- var _useState21 = (0, _react.useState)(true),
123
- _useState22 = (0, _slicedToArray2["default"])(_useState21, 2),
124
- pageBuilderTemplateStatus = _useState22[0],
125
- setPageBuilderTemplateStatus = _useState22[1];
126
- var _useState23 = (0, _react.useState)(false),
127
- _useState24 = (0, _slicedToArray2["default"])(_useState23, 2),
128
- shouldCopyData = _useState24[0],
129
- setShouldCopyData = _useState24[1];
130
- var _useState25 = (0, _react.useState)(false),
131
- _useState26 = (0, _slicedToArray2["default"])(_useState25, 2),
132
- isFormValid = _useState26[0],
133
- setIsFormValid = _useState26[1];
134
- var _useState27 = (0, _react.useState)(null),
135
- _useState28 = (0, _slicedToArray2["default"])(_useState27, 2),
136
- formDataFromCopy = _useState28[0],
137
- setFormDataFromCopy = _useState28[1];
138
- var _useState29 = (0, _react.useState)(null),
139
- _useState30 = (0, _slicedToArray2["default"])(_useState29, 2),
140
- newUpdatedDate = _useState30[0],
141
- setNewUpdatedDate = _useState30[1];
142
- var _useState31 = (0, _react.useState)(_constants.SAVE_BUTTON_TEXTS.save),
143
- _useState32 = (0, _slicedToArray2["default"])(_useState31, 2),
144
- saveButtonText = _useState32[0],
145
- setSaveButtonText = _useState32[1];
146
- var _useState33 = (0, _react.useState)(null),
147
- _useState34 = (0, _slicedToArray2["default"])(_useState33, 2),
148
- externalUpdateTime = _useState34[0],
149
- setExternalUpdateTime = _useState34[1];
150
- var _useState35 = (0, _react.useState)(true),
151
- _useState36 = (0, _slicedToArray2["default"])(_useState35, 2),
152
- isRightSidebarOpen = _useState36[0],
153
- setIsRightSidebarOpen = _useState36[1];
154
- var handleToggleRightSidebar = function handleToggleRightSidebar() {
155
- return setIsRightSidebarOpen(!isRightSidebarOpen);
156
- };
157
- var isCreatePage = history.location.pathname.includes('create');
158
- var _useState37 = (0, _react.useState)(isCreatePage),
159
- _useState38 = (0, _slicedToArray2["default"])(_useState37, 2),
160
- isNewEntity = _useState38[0],
161
- setIsNewEntity = _useState38[1];
162
- var client = (0, _client.useApolloClient)();
163
- var shouldUpdateState = !entityIdentifier || (0, _entity.checkFulfilConditions)(entity, schema, previousQuery, !entityData) || entityData && entityData.id !== entity.id;
164
- var clonedFormData = (0, _lodash["default"])(formData);
165
- var _useToasts = (0, _toaster.useToasts)(),
166
- addToast = _useToasts.addToast;
35
+ 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) { (0, _defineProperty2.default)(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; }
36
+ const Entity = ({
37
+ formData,
38
+ entity,
39
+ schema,
40
+ previousQuery,
41
+ action,
42
+ history,
43
+ updateFormData,
44
+ onViewUrl,
45
+ refetchRecord
46
+ }) => {
47
+ var _formData$values;
48
+ const [formValues, setFormValues] = (0, _react.useState)(null);
49
+ const [entitySchema, setEntitySchema] = (0, _react.useState)(null);
50
+ const [entityData, setEntityData] = (0, _react.useState)(null);
51
+ const [entityIdentifier, setEntityIdentifier] = (0, _react.useState)(null);
52
+ const [pageTitle, setPageTitle] = (0, _react.useState)('');
53
+ const [isSaveButtonAvailable, setIsSaveButtonAvailable] = (0, _react.useState)(false);
54
+ const [entityIsPublished, setEntityIsPublish] = (0, _react.useState)(formData && formData.values && formData.values.status);
55
+ const [isEnablePublishButton, setEnablePublishButton] = (0, _react.useState)(false);
56
+ const [isEnablePreviewButton, setEnablePreviewButton] = (0, _react.useState)(false);
57
+ const [modalStatus, setModalStatus] = (0, _useToggle.default)(false);
58
+ const [copyModalStatus, setCopyModalStatus] = (0, _useToggle.default)(false);
59
+ const [pageBuilderTemplateStatus, setPageBuilderTemplateStatus] = (0, _react.useState)(true);
60
+ const [shouldCopyData, setShouldCopyData] = (0, _react.useState)(false);
61
+ const [isFormValid, setIsFormValid] = (0, _react.useState)(false);
62
+ const [formDataFromCopy, setFormDataFromCopy] = (0, _react.useState)(null);
63
+ const [newUpdatedDate, setNewUpdatedDate] = (0, _react.useState)(null);
64
+ const [saveButtonText, setSaveButtonText] = (0, _react.useState)(_constants.SAVE_BUTTON_TEXTS.save);
65
+ const [externalUpdateTime, setExternalUpdateTime] = (0, _react.useState)(null);
66
+ const [isRightSidebarOpen, setIsRightSidebarOpen] = (0, _react.useState)(true);
67
+ const handleToggleRightSidebar = () => setIsRightSidebarOpen(!isRightSidebarOpen);
68
+ const isCreatePage = history.location.pathname.includes('create');
69
+ const [isNewEntity, setIsNewEntity] = (0, _react.useState)(isCreatePage);
70
+ const client = (0, _client.useApolloClient)();
71
+ const shouldUpdateState = !entityIdentifier || (0, _entity.checkFulfilConditions)(entity, schema, previousQuery, !entityData) || entityData && entityData.id !== entity.id;
72
+ const clonedFormData = (0, _lodash.default)(formData);
73
+ const {
74
+ addToast
75
+ } = (0, _toaster.useToasts)();
167
76
 
168
77
  // Here's how we'll keep track of our component's mounted state
169
- var componentIsMounted = (0, _react.useRef)(true);
170
- var _schema$displayProper = schema.displayProperties.saveOnChange,
171
- saveOnChange = _schema$displayProper === void 0 ? false : _schema$displayProper;
172
- (0, _useCallbackDebounce["default"])(function () {
78
+ const componentIsMounted = (0, _react.useRef)(true);
79
+ const {
80
+ displayProperties: {
81
+ saveOnChange = false
82
+ }
83
+ } = schema;
84
+ (0, _useCallbackDebounce.default)(() => {
173
85
  isSaveButtonAvailable && onSubmit();
174
86
  }, 500, [isSaveButtonAvailable], !saveOnChange);
175
- (0, _react.useEffect)(function () {
176
- return function () {
177
- componentIsMounted.current = false;
178
- };
87
+ (0, _react.useEffect)(() => () => {
88
+ componentIsMounted.current = false;
179
89
  }, []); // Using an empty dependency array ensures this only runs on unmount
180
90
 
181
- (0, _react.useEffect)(function () {
91
+ (0, _react.useEffect)(() => {
182
92
  if (shouldUpdateState) {
183
93
  setSaveButtonText(_constants.SAVE_BUTTON_TEXTS.save);
184
94
  setEntityData(entity);
@@ -190,7 +100,7 @@ var Entity = function Entity(_ref) {
190
100
  setEnablePreviewButton(!!schema.interfaces.includes(_constants.PREVIEW_INTERFACE));
191
101
  }
192
102
  if (formData && pageBuilderTemplateStatus) {
193
- var isPageBuilderTemplateSet = !!formData.values.pageBuilderTemplateId;
103
+ const isPageBuilderTemplateSet = !!formData.values.pageBuilderTemplateId;
194
104
  client.writeQuery({
195
105
  query: (0, _adminUiUtils.getQuery)('GET_PB_TEMPLATE_STATUS'),
196
106
  data: {
@@ -203,60 +113,45 @@ var Entity = function Entity(_ref) {
203
113
  client.writeQuery({
204
114
  query: (0, _adminUiUtils.getQuery)('GET_CURRENT_ENTITY'),
205
115
  data: {
206
- currentEntity: schema.id
116
+ currentEntity: schema.id,
117
+ currentItemId: entity ? entity.id : null
207
118
  }
208
119
  });
209
120
  }
210
121
  }, [client, entity, entityData, formData, formValues, pageBuilderTemplateStatus, previousQuery, schema, shouldUpdateState]);
211
- var getFullUrl = /*#__PURE__*/function () {
212
- var _ref2 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee() {
213
- var query, _yield$client$query, _yield$client$query$d, _yield$client$query$d2, _yield$client$query$d3, getEntityUrl;
214
- return _regenerator["default"].wrap(function _callee$(_context) {
215
- while (1) switch (_context.prev = _context.next) {
216
- case 0:
217
- query = (0, _adminUiUtils.getQuery)('GET_ENTITY_URL');
218
- _context.next = 3;
219
- return client.query({
220
- query: query,
221
- variables: {
222
- itemId: entity.id,
223
- itemEntity: schema.id,
224
- fullUrl: true
225
- },
226
- fetchPolicy: 'network-only'
227
- });
228
- case 3:
229
- _yield$client$query = _context.sent;
230
- _yield$client$query$d = _yield$client$query.data;
231
- _yield$client$query$d2 = _yield$client$query$d === void 0 ? {} : _yield$client$query$d;
232
- _yield$client$query$d3 = _yield$client$query$d2.getEntityUrl;
233
- getEntityUrl = _yield$client$query$d3 === void 0 ? '' : _yield$client$query$d3;
234
- return _context.abrupt("return", getEntityUrl);
235
- case 9:
236
- case "end":
237
- return _context.stop();
238
- }
239
- }, _callee);
240
- }));
241
- return function getFullUrl() {
242
- return _ref2.apply(this, arguments);
243
- };
244
- }();
245
- var getFormValues = function getFormValues(values) {
122
+ const getFullUrl = async () => {
123
+ const query = (0, _adminUiUtils.getQuery)('GET_ENTITY_URL');
124
+ const {
125
+ data: {
126
+ getEntityUrl = ''
127
+ } = {}
128
+ } = await client.query({
129
+ query,
130
+ variables: {
131
+ itemId: entity.id,
132
+ itemEntity: schema.id,
133
+ fullUrl: true
134
+ },
135
+ fetchPolicy: 'network-only'
136
+ });
137
+ return getEntityUrl;
138
+ };
139
+ const getFormValues = values => {
246
140
  if (componentIsMounted.current) {
247
141
  setFormValues(values);
248
142
  }
249
143
  };
250
- var onChangeSideBarRelations = function onChangeSideBarRelations(_ref3, requiredChildField) {
251
- var id = _ref3.id,
252
- value = _ref3.value;
253
- var updatedFormValues = (0, _entity.getUpdatedFormValues)({
254
- id: id,
255
- value: value,
256
- requiredChildField: requiredChildField,
257
- formValues: formValues
144
+ const onChangeSideBarRelations = ({
145
+ id,
146
+ value
147
+ }, requiredChildField) => {
148
+ const updatedFormValues = (0, _entity.getUpdatedFormValues)({
149
+ id,
150
+ value,
151
+ requiredChildField,
152
+ formValues
258
153
  });
259
- var shouldActiveSaveButton = (0, _entity.validateSideBarRelations)(updatedFormValues, requiredChildField);
154
+ const shouldActiveSaveButton = (0, _entity.validateSideBarRelations)(updatedFormValues, requiredChildField);
260
155
  if (isFormValid && shouldActiveSaveButton && componentIsMounted.current) {
261
156
  setIsSaveButtonAvailable(true);
262
157
  setSaveButtonText(_constants.SAVE_BUTTON_TEXTS.save);
@@ -267,174 +162,141 @@ var Entity = function Entity(_ref) {
267
162
  setFormValues(updatedFormValues);
268
163
  }
269
164
  };
270
- var onChangeFormValues = /*#__PURE__*/function () {
271
- var _ref5 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee2(_ref4) {
272
- var isValid, fields, isNewValueSet, valuesChecked, currentField, fieldValue, otherProps, updatedFormValues, pageBuilderTemplateId, pageBuilder, _yield$client$query2, _yield$client$query2$, data, itemsToAdd, _fields$filter, _fields$filter2, _fields$filter2$, updatedEntity, isValidAndNewValueSet, isNotValidOrNotNewValueSet;
273
- return _regenerator["default"].wrap(function _callee2$(_context2) {
274
- while (1) switch (_context2.prev = _context2.next) {
275
- case 0:
276
- isValid = _ref4.isValid, fields = _ref4.fields, isNewValueSet = _ref4.isNewValueSet, valuesChecked = _ref4.valuesChecked, currentField = _ref4.currentField, fieldValue = _ref4.value, otherProps = (0, _objectWithoutProperties2["default"])(_ref4, _excluded);
277
- updatedFormValues = valuesChecked ? valuesChecked.slice() : [];
278
- if (!(currentField === _constants.PAGE_BUILDER_TEMPLATE_FIELD_ID)) {
279
- _context2.next = 14;
280
- break;
281
- }
282
- pageBuilderTemplateId = fieldValue;
283
- client.writeQuery({
284
- query: (0, _adminUiUtils.getQuery)('GET_PB_TEMPLATE_STATUS'),
285
- data: {
286
- pageBuilderTemplateSet: !!pageBuilderTemplateId,
287
- pageBuilderTemplateId: pageBuilderTemplateId
288
- }
289
- });
290
- if (componentIsMounted.current) {
291
- setPageBuilderTemplateStatus(false);
292
- }
293
- pageBuilder = updatedFormValues.filter(function (formValue) {
294
- return formValue.id === _constants.PAGE_BUILDER_FIELD_ID;
295
- });
296
- if (!pageBuilderTemplateId) {
297
- _context2.next = 14;
298
- break;
299
- }
300
- _context2.next = 10;
301
- return client.query({
302
- query: (0, _adminUiUtils.getQuery)('MERGE_PB_TEMPLATE_CHANGES'),
303
- variables: {
304
- parent: {
305
- pageBuilder: pageBuilder[0].value,
306
- pageBuilderTemplateId: pageBuilderTemplateId
307
- },
308
- entityIdentifier: entityIdentifier
309
- }
310
- });
311
- case 10:
312
- _yield$client$query2 = _context2.sent;
313
- _yield$client$query2$ = _yield$client$query2.data;
314
- data = _yield$client$query2$ === void 0 ? {} : _yield$client$query2$;
315
- if (data && data.mergePageBuilderTemplateChanges) {
316
- updatedFormValues = updatedFormValues.map(function (updatedFormValue) {
317
- if (updatedFormValue.id === _constants.PAGE_BUILDER_FIELD_ID) {
318
- return _objectSpread(_objectSpread({}, updatedFormValue), {}, {
319
- value: data.mergePageBuilderTemplateChanges
320
- });
321
- }
322
- return updatedFormValue;
323
- });
324
- }
325
- case 14:
326
- itemsToAdd = [];
327
- if (formValues && formValues.length > updatedFormValues.length) {
328
- [].concat((0, _toConsumableArray2["default"])(updatedFormValues), (0, _toConsumableArray2["default"])(formValues)).forEach(function (item) {
329
- var index = updatedFormValues.findIndex(function (value) {
330
- return value.id === item.id;
331
- });
332
- if (index === -1) {
333
- itemsToAdd.push(item);
334
- }
165
+ const onChangeFormValues = async _ref => {
166
+ let {
167
+ isValid,
168
+ fields,
169
+ isNewValueSet,
170
+ valuesChecked,
171
+ currentField,
172
+ value: fieldValue
173
+ } = _ref,
174
+ otherProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
175
+ let updatedFormValues = valuesChecked ? valuesChecked.slice() : [];
176
+ if (currentField === _constants.PAGE_BUILDER_TEMPLATE_FIELD_ID) {
177
+ const pageBuilderTemplateId = fieldValue;
178
+ client.writeQuery({
179
+ query: (0, _adminUiUtils.getQuery)('GET_PB_TEMPLATE_STATUS'),
180
+ data: {
181
+ pageBuilderTemplateSet: !!pageBuilderTemplateId,
182
+ pageBuilderTemplateId
183
+ }
184
+ });
185
+ if (componentIsMounted.current) {
186
+ setPageBuilderTemplateStatus(false);
187
+ }
188
+ const pageBuilder = updatedFormValues.filter(formValue => formValue.id === _constants.PAGE_BUILDER_FIELD_ID);
189
+ if (pageBuilderTemplateId) {
190
+ const {
191
+ data = {}
192
+ } = await client.query({
193
+ query: (0, _adminUiUtils.getQuery)('MERGE_PB_TEMPLATE_CHANGES'),
194
+ variables: {
195
+ parent: {
196
+ pageBuilder: pageBuilder[0].value,
197
+ pageBuilderTemplateId
198
+ },
199
+ entityIdentifier
200
+ }
201
+ });
202
+ if (data && data.mergePageBuilderTemplateChanges) {
203
+ updatedFormValues = updatedFormValues.map(updatedFormValue => {
204
+ if (updatedFormValue.id === _constants.PAGE_BUILDER_FIELD_ID) {
205
+ return _objectSpread(_objectSpread({}, updatedFormValue), {}, {
206
+ value: data.mergePageBuilderTemplateChanges
335
207
  });
336
208
  }
337
- _fields$filter = fields.filter(function (_ref6) {
338
- var id = _ref6.id;
339
- return id === 'name';
340
- }), _fields$filter2 = (0, _slicedToArray2["default"])(_fields$filter, 1), _fields$filter2$ = _fields$filter2[0], updatedEntity = _fields$filter2$ === void 0 ? null : _fields$filter2$;
341
- updatedEntity && setPageTitle(updatedEntity.value);
342
- isValidAndNewValueSet = isValid && isNewValueSet;
343
- isNotValidOrNotNewValueSet = !isValid || !isNewValueSet;
344
- if (componentIsMounted.current) {
345
- setIsFormValid(isValid);
346
- }
347
- if (isValidAndNewValueSet && componentIsMounted.current) {
348
- setIsSaveButtonAvailable(true);
349
- setSaveButtonText(_constants.SAVE_BUTTON_TEXTS.save);
350
- }
351
- if (isNotValidOrNotNewValueSet && componentIsMounted.current) {
352
- setIsSaveButtonAvailable(false);
353
- }
354
- if (componentIsMounted.current) {
355
- setFormValues([].concat((0, _toConsumableArray2["default"])(updatedFormValues), itemsToAdd));
356
- }
357
- case 24:
358
- case "end":
359
- return _context2.stop();
209
+ return updatedFormValue;
210
+ });
360
211
  }
361
- }, _callee2);
362
- }));
363
- return function onChangeFormValues(_x) {
364
- return _ref5.apply(this, arguments);
365
- };
366
- }();
367
- var onSubmit = function onSubmit(event) {
212
+ }
213
+ }
214
+ const itemsToAdd = [];
215
+ if (formValues && formValues.length > updatedFormValues.length) {
216
+ [...updatedFormValues, ...formValues].forEach(item => {
217
+ const index = updatedFormValues.findIndex(value => value.id === item.id);
218
+ if (index === -1) {
219
+ itemsToAdd.push(item);
220
+ }
221
+ });
222
+ }
223
+ const [updatedEntity = null] = fields.filter(({
224
+ id
225
+ }) => id === 'name');
226
+ updatedEntity && setPageTitle(updatedEntity.value);
227
+ const isValidAndNewValueSet = isValid && isNewValueSet;
228
+ const isNotValidOrNotNewValueSet = !isValid || !isNewValueSet;
229
+ if (componentIsMounted.current) {
230
+ setIsFormValid(isValid);
231
+ }
232
+ if (isValidAndNewValueSet && componentIsMounted.current) {
233
+ setIsSaveButtonAvailable(true);
234
+ setSaveButtonText(_constants.SAVE_BUTTON_TEXTS.save);
235
+ }
236
+ if (isNotValidOrNotNewValueSet && componentIsMounted.current) {
237
+ setIsSaveButtonAvailable(false);
238
+ }
239
+ if (componentIsMounted.current) {
240
+ setFormValues([...updatedFormValues, ...itemsToAdd]);
241
+ }
242
+ };
243
+ const onSubmit = event => {
368
244
  event && event.preventDefault();
369
245
  if (!isSaveButtonAvailable) return null;
370
- var parsedFormValues = (0, _reactFormBuilder.parseFormValues)(formValues);
371
- var updatedFormValues = newUpdatedDate ? _objectSpread(_objectSpread({}, formData.values), {}, {
246
+ const parsedFormValues = (0, _reactFormBuilder.parseFormValues)(formValues);
247
+ const updatedFormValues = newUpdatedDate ? _objectSpread(_objectSpread({}, formData.values), {}, {
372
248
  update: newUpdatedDate
373
249
  }) : _objectSpread({}, formData.values);
374
- var handleUpdateFormData = function handleUpdateFormData() {
375
- return updateFormData({
376
- values: _objectSpread(_objectSpread({}, updatedFormValues), parsedFormValues)
377
- }, true);
378
- };
379
- var submitParams = {
250
+ const handleUpdateFormData = () => updateFormData({
251
+ values: _objectSpread(_objectSpread({}, updatedFormValues), parsedFormValues)
252
+ }, true);
253
+ const submitParams = {
380
254
  update: {
381
- entitySchema: entitySchema,
382
- entityData: entityData,
383
- parsedFormValues: parsedFormValues,
384
- client: client,
385
- setIsSaveButtonAvailable: setIsSaveButtonAvailable,
386
- setNewUpdatedDate: setNewUpdatedDate,
387
- newUpdatedDate: newUpdatedDate,
388
- previousQuery: previousQuery,
389
- setSaveButtonText: setSaveButtonText,
390
- handleUpdateFormData: handleUpdateFormData
255
+ entitySchema,
256
+ entityData,
257
+ parsedFormValues,
258
+ client,
259
+ setIsSaveButtonAvailable,
260
+ setNewUpdatedDate,
261
+ newUpdatedDate,
262
+ previousQuery,
263
+ setSaveButtonText,
264
+ handleUpdateFormData
391
265
  },
392
266
  create: {
393
- entitySchema: entitySchema,
394
- parsedFormValues: parsedFormValues,
395
- client: client,
396
- setEntityData: setEntityData,
397
- setIsSaveButtonAvailable: setIsSaveButtonAvailable,
398
- history: history,
399
- setIsNewEntity: setIsNewEntity,
400
- setSaveButtonText: setSaveButtonText,
401
- handleUpdateFormData: handleUpdateFormData
267
+ entitySchema,
268
+ parsedFormValues,
269
+ client,
270
+ setEntityData,
271
+ setIsSaveButtonAvailable,
272
+ history,
273
+ setIsNewEntity,
274
+ setSaveButtonText,
275
+ handleUpdateFormData
402
276
  }
403
277
  };
404
- var currentAction = submitParams[action];
405
- return _actionsHandlers["default"][action].submit(currentAction, addToast);
278
+ const currentAction = submitParams[action];
279
+ return _actionsHandlers.default[action].submit(currentAction, addToast);
406
280
  };
407
- var onDelete = /*#__PURE__*/function () {
408
- var _ref7 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee3() {
409
- var id;
410
- return _regenerator["default"].wrap(function _callee3$(_context3) {
411
- while (1) switch (_context3.prev = _context3.next) {
412
- case 0:
413
- id = formData.values.id;
414
- if (componentIsMounted.current) {
415
- setIsSaveButtonAvailable(false);
416
- }
417
- _context3.next = 4;
418
- return _actionsHandlers["default"]["delete"].submit({
419
- entitySchema: entitySchema,
420
- client: client,
421
- parsedFormValues: {
422
- id: id
423
- }
424
- }, addToast);
425
- case 4:
426
- history.push("/data-listing/".concat(entitySchema.id));
427
- case 5:
428
- case "end":
429
- return _context3.stop();
430
- }
431
- }, _callee3);
432
- }));
433
- return function onDelete() {
434
- return _ref7.apply(this, arguments);
435
- };
436
- }();
437
- var onCopy = function onCopy() {
281
+ const onDelete = async () => {
282
+ const {
283
+ values: {
284
+ id
285
+ }
286
+ } = formData;
287
+ if (componentIsMounted.current) {
288
+ setIsSaveButtonAvailable(false);
289
+ }
290
+ await _actionsHandlers.default.delete.submit({
291
+ entitySchema,
292
+ client,
293
+ parsedFormValues: {
294
+ id
295
+ }
296
+ }, addToast);
297
+ history.push(`/data-listing/${entitySchema.id}`);
298
+ };
299
+ const onCopy = () => {
438
300
  if (formDataFromCopy && componentIsMounted.current) {
439
301
  updateFormData(formDataFromCopy);
440
302
  setShouldCopyData(true);
@@ -445,91 +307,66 @@ var Entity = function Entity(_ref) {
445
307
  }
446
308
  }
447
309
  };
448
- var updateCopyData = function updateCopyData() {
310
+ const updateCopyData = () => {
449
311
  setCopyModalStatus(!copyModalStatus);
450
312
  setShouldCopyData(false);
451
313
  };
452
- var handleCopyDataFromClose = function handleCopyDataFromClose() {
314
+ const handleCopyDataFromClose = () => {
453
315
  setCopyModalStatus(false);
454
316
  setFormDataFromCopy(null);
455
317
  };
456
- var getFormData = function getFormData(formDataValues) {
457
- var formDataUpdated = {
318
+ const getFormData = formDataValues => {
319
+ const formDataUpdated = {
458
320
  values: _objectSpread({}, formDataValues)
459
321
  };
460
322
  setFormDataFromCopy(formDataUpdated);
461
323
  };
462
- var handlePublishAndUnpublish = /*#__PURE__*/function () {
463
- var _ref9 = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee4(_ref8) {
464
- var textContent, isPublishButton, isPublished, isUnpublish, savedPageMessage;
465
- return _regenerator["default"].wrap(function _callee4$(_context4) {
466
- while (1) switch (_context4.prev = _context4.next) {
467
- case 0:
468
- textContent = _ref8.target.textContent;
469
- isPublishButton = textContent === _constants.TEXT_CONTENT_TYPE;
470
- isPublished = entityIsPublished === _constants.ENTITY_PUBLISHED;
471
- isUnpublish = (0, _entity.checkFulfilConditions)(!isPublishButton, !isPublished);
472
- if (!isUnpublish) {
473
- _context4.next = 6;
474
- break;
475
- }
476
- return _context4.abrupt("return", addToast(_constants.UNPUBLISHED_WARNING, {
477
- appearance: 'warning',
478
- autoDismiss: true
479
- }));
480
- case 6:
481
- if (!(0, _entity.checkFulfilConditions)(isPublishButton, isSaveButtonAvailable)) {
482
- _context4.next = 12;
483
- break;
484
- }
485
- _context4.next = 9;
486
- return onSubmit();
487
- case 9:
488
- savedPageMessage = _context4.sent;
489
- if (!(savedPageMessage === _constants.ERROR)) {
490
- _context4.next = 12;
491
- break;
492
- }
493
- return _context4.abrupt("return", addToast("Content not published", {
494
- appearance: _constants.ERROR,
495
- autoDismiss: true
496
- }));
497
- case 12:
498
- return _context4.abrupt("return", _actionsHandlers["default"].shared.triggerPublish({
499
- entityData: entityData,
500
- client: client,
501
- setEntityIsPublish: setEntityIsPublish,
502
- entitySchema: entitySchema,
503
- textContent: textContent,
504
- refetchRecord: refetchRecord
505
- }, addToast));
506
- case 13:
507
- case "end":
508
- return _context4.stop();
509
- }
510
- }, _callee4);
511
- }));
512
- return function handlePublishAndUnpublish(_x2) {
513
- return _ref9.apply(this, arguments);
514
- };
515
- }();
516
- var showModal = (0, _entity.checkFulfilConditions)(formData, modalStatus);
517
- var onViewUrlHandler = (0, _entity.canViewPage)(formData, entity, schema, entityIsPublished) ? function () {
518
- return (0, _entity.onViewUrlClick)(getFullUrl);
519
- } : onViewUrl;
520
- var pageName = formData && formData.values && formData.values.name;
521
- var hasNewFormValues = (0, _entity.checkFulfilConditions)(isNewEntity, !(0, _isFormEmpty["default"])(formValues));
522
- var hasToDisplayPrompt = isSaveButtonAvailable || hasNewFormValues;
523
- var showSideBarRelations = (0, _entity.checkFulfilConditions)(schema, formData);
524
- var showPageBuilderTabs = (schema === null || schema === void 0 ? void 0 : (_schema$interfaces = schema.interfaces) === null || _schema$interfaces === void 0 ? void 0 : _schema$interfaces.includes('page-builder/page-builder-template')) || (schema === null || schema === void 0 ? void 0 : (_schema$interfaces2 = schema.interfaces) === null || _schema$interfaces2 === void 0 ? void 0 : _schema$interfaces2.includes('page-builder/page-builder'));
525
- return /*#__PURE__*/_react["default"].createElement(_RecordEditContext.RecordEditContextProvider, {
324
+ const handlePublishAndUnpublish = async ({
325
+ target: {
326
+ textContent
327
+ }
328
+ }) => {
329
+ const isPublishButton = textContent === _constants.TEXT_CONTENT_TYPE;
330
+ const isPublished = entityIsPublished === _constants.ENTITY_PUBLISHED;
331
+ const isUnpublish = (0, _entity.checkFulfilConditions)(!isPublishButton, !isPublished);
332
+ if (isUnpublish) {
333
+ return addToast(_constants.UNPUBLISHED_WARNING, {
334
+ appearance: 'warning',
335
+ autoDismiss: true
336
+ });
337
+ }
338
+ if ((0, _entity.checkFulfilConditions)(isPublishButton, isSaveButtonAvailable)) {
339
+ const savedPageMessage = await onSubmit();
340
+ if (savedPageMessage === _constants.ERROR) {
341
+ return addToast(`Content not published`, {
342
+ appearance: _constants.ERROR,
343
+ autoDismiss: true
344
+ });
345
+ }
346
+ }
347
+ return _actionsHandlers.default.shared.triggerPublish({
348
+ entityData,
349
+ client,
350
+ setEntityIsPublish,
351
+ entitySchema,
352
+ textContent,
353
+ refetchRecord
354
+ }, addToast);
355
+ };
356
+ const showModal = (0, _entity.checkFulfilConditions)(formData, modalStatus);
357
+ const onViewUrlHandler = (0, _entity.canViewPage)(formData, entity, schema, entityIsPublished) ? () => (0, _entity.onViewUrlClick)(getFullUrl) : onViewUrl;
358
+ const pageName = formData && formData.values && formData.values.name;
359
+ const hasNewFormValues = (0, _entity.checkFulfilConditions)(isNewEntity, !(0, _isFormEmpty.default)(formValues));
360
+ const hasToDisplayPrompt = isSaveButtonAvailable || hasNewFormValues;
361
+ const showSideBarRelations = (0, _entity.checkFulfilConditions)(schema, formData);
362
+ return /*#__PURE__*/_react.default.createElement(_RecordEditContext.RecordEditContextProvider, {
526
363
  value: {
527
- externalUpdateTime: externalUpdateTime,
364
+ externalUpdateTime,
528
365
  updated: formData === null || formData === void 0 ? void 0 : (_formData$values = formData.values) === null || _formData$values === void 0 ? void 0 : _formData$values.updated
529
366
  }
530
- }, /*#__PURE__*/_react["default"].createElement("div", {
367
+ }, /*#__PURE__*/_react.default.createElement("div", {
531
368
  className: "page"
532
- }, /*#__PURE__*/_react["default"].createElement(_EntityHeader["default"], {
369
+ }, /*#__PURE__*/_react.default.createElement(_EntityHeader.default, {
533
370
  entityData: entityData,
534
371
  entityIdentifier: entityIdentifier,
535
372
  pageTitle: pageTitle,
@@ -546,46 +383,35 @@ var Entity = function Entity(_ref) {
546
383
  saveButtonText: saveButtonText,
547
384
  saveOnChange: saveOnChange,
548
385
  entitySchema: entitySchema
549
- }), /*#__PURE__*/_react["default"].createElement("div", {
386
+ }), /*#__PURE__*/_react.default.createElement("div", {
550
387
  className: "page-wrapper__content"
551
- }, /*#__PURE__*/_react["default"].createElement("div", {
388
+ }, /*#__PURE__*/_react.default.createElement("div", {
552
389
  className: "tabs-wrapper tabs-wrapper__tab"
553
- }, /*#__PURE__*/_react["default"].createElement(_reactRouterDom.Prompt, {
390
+ }, /*#__PURE__*/_react.default.createElement(_reactRouterDom.Prompt, {
554
391
  when: hasToDisplayPrompt,
555
392
  message: _constants.LEAVE_PAGE_MESSAGE
556
- }), showModal && /*#__PURE__*/_react["default"].createElement(_admin.DeleteAction, {
393
+ }), showModal && /*#__PURE__*/_react.default.createElement(_admin.DeleteAction, {
557
394
  onClose: setModalStatus,
558
395
  deleteAction: onDelete,
559
396
  itemName: formData.values.name
560
- }), copyModalStatus && /*#__PURE__*/_react["default"].createElement(_admin.CopyDataFromAction, {
397
+ }), copyModalStatus && /*#__PURE__*/_react.default.createElement(_admin.CopyDataFromAction, {
561
398
  onClose: handleCopyDataFromClose,
562
399
  copyAction: onCopy,
563
400
  getFormData: getFormData
564
- }), /*#__PURE__*/_react["default"].createElement("div", {
565
- className: "page__content--fixed".concat(!isRightSidebarOpen ? ' right-sidebar-collapsed' : '')
566
- }, /*#__PURE__*/_react["default"].createElement("div", {
401
+ }), /*#__PURE__*/_react.default.createElement("div", {
402
+ className: `page__content--fixed${!isRightSidebarOpen ? ' right-sidebar-collapsed' : ''}`
403
+ }, /*#__PURE__*/_react.default.createElement("div", {
567
404
  className: "page__content"
568
- }, /*#__PURE__*/_react["default"].createElement("div", {
405
+ }, /*#__PURE__*/_react.default.createElement("div", {
569
406
  className: "content"
570
- }, /*#__PURE__*/_react["default"].createElement(_pluginRenderHooksUi.RenderHook, {
571
- hookKey: "entity:".concat(action, ":main:top"),
407
+ }, /*#__PURE__*/_react.default.createElement(_pluginRenderHooksUi.RenderHook, {
408
+ hookKey: `entity:${action}:main:top`,
572
409
  entity: entity,
573
410
  schema: schema
574
- }), /*#__PURE__*/_react["default"].createElement(_InfoBoxes["default"], {
411
+ }), /*#__PURE__*/_react.default.createElement(_InfoBoxes.default, {
575
412
  id: entity.id,
576
413
  schema: schema
577
- }), /*#__PURE__*/_react["default"].createElement(_Tabs["default"], {
578
- enabled: showPageBuilderTabs,
579
- onTabChange: function onTabChange(tabId) {
580
- client.writeQuery({
581
- query: _adminUiUtils.GET_CURRENT_TAB_ID,
582
- data: {
583
- currentTabId: tabId
584
- }
585
- });
586
- setCurrentTabId(tabId);
587
- }
588
- }, /*#__PURE__*/_react["default"].createElement(_reactFormBuilder.FormBuilder, {
414
+ }), /*#__PURE__*/_react.default.createElement(_reactFormBuilder.FormBuilder, {
589
415
  getIsFormValid: setIsFormValid,
590
416
  getFormValues: getFormValues,
591
417
  schema: schema,
@@ -595,14 +421,15 @@ var Entity = function Entity(_ref) {
595
421
  updateCopyData: updateCopyData,
596
422
  formValues: formValues,
597
423
  isNewEntity: isNewEntity,
598
- onExternalUpdate: setExternalUpdateTime
599
- })), /*#__PURE__*/_react["default"].createElement(_pluginRenderHooksUi.RenderHook, {
600
- hookKey: "entity:".concat(action, ":main:bottom"),
424
+ onExternalUpdate: setExternalUpdateTime,
425
+ mode: isNewEntity ? 'create' : 'update'
426
+ }), /*#__PURE__*/_react.default.createElement(_pluginRenderHooksUi.RenderHook, {
427
+ hookKey: `entity:${action}:main:bottom`,
601
428
  entity: entity,
602
429
  schema: schema
603
- }))))), /*#__PURE__*/_react["default"].createElement("div", {
604
- className: "column column--one-third page-sidebar page-sidebar--relations".concat(!isRightSidebarOpen ? ' sidebar--collapsed' : '')
605
- }, showSideBarRelations && /*#__PURE__*/_react["default"].createElement(_SideBarRelations["default"], {
430
+ }))))), /*#__PURE__*/_react.default.createElement("div", {
431
+ className: `column column--one-third page-sidebar page-sidebar--relations${!isRightSidebarOpen ? ' sidebar--collapsed' : ''}`
432
+ }, showSideBarRelations && /*#__PURE__*/_react.default.createElement(_SideBarRelations.default, {
606
433
  entity: entity,
607
434
  formData: formData.values,
608
435
  schema: schema,
@@ -612,15 +439,15 @@ var Entity = function Entity(_ref) {
612
439
  })))));
613
440
  };
614
441
  Entity.propTypes = {
615
- entity: _propTypes["default"].object,
616
- schema: _propTypes["default"].object,
617
- previousQuery: _propTypes["default"].object,
618
- action: _propTypes["default"].string.isRequired,
619
- history: _propTypes["default"].object.isRequired,
620
- formData: _propTypes["default"].object,
621
- updateFormData: _propTypes["default"].func.isRequired,
622
- onViewUrl: _propTypes["default"].func,
623
- refetchRecord: _propTypes["default"].func.isRequired
442
+ entity: _propTypes.default.object,
443
+ schema: _propTypes.default.object,
444
+ previousQuery: _propTypes.default.object,
445
+ action: _propTypes.default.string.isRequired,
446
+ history: _propTypes.default.object.isRequired,
447
+ formData: _propTypes.default.object,
448
+ updateFormData: _propTypes.default.func.isRequired,
449
+ onViewUrl: _propTypes.default.func,
450
+ refetchRecord: _propTypes.default.func.isRequired
624
451
  };
625
452
  Entity.defaultProps = {
626
453
  previousQuery: null,
@@ -629,5 +456,5 @@ Entity.defaultProps = {
629
456
  formData: null,
630
457
  onViewUrl: null
631
458
  };
632
- var _default = exports["default"] = (0, _reactRouterDom.withRouter)(Entity);
459
+ var _default = exports.default = (0, _reactRouterDom.withRouter)(Entity);
633
460
  //# sourceMappingURL=Entity.js.map