@ukhomeoffice/cop-react-form-renderer 5.0.0-alpha → 5.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (277) hide show
  1. package/dist/components/CheckYourAnswers/Answer.js +18 -7
  2. package/dist/components/CheckYourAnswers/Answer.test.js +137 -0
  3. package/dist/components/CheckYourAnswers/CheckYourAnswers.js +70 -46
  4. package/dist/components/CheckYourAnswers/CheckYourAnswers.stories.mdx +410 -0
  5. package/dist/components/CheckYourAnswers/CheckYourAnswers.test.js +551 -0
  6. package/dist/components/CollectionPage/CollectionPage.js +15 -10
  7. package/dist/components/CollectionPage/CollectionPage.test.js +382 -0
  8. package/dist/components/FormComponent/Collection.js +91 -48
  9. package/dist/components/FormComponent/Collection.scss +2 -1
  10. package/dist/components/FormComponent/Collection.test.js +807 -0
  11. package/dist/components/FormComponent/Container.js +35 -16
  12. package/dist/components/FormComponent/Container.test.js +370 -0
  13. package/dist/components/FormComponent/FormComponent.js +39 -13
  14. package/dist/components/FormComponent/FormComponent.stories.mdx +184 -0
  15. package/dist/components/FormComponent/FormComponent.test.js +226 -0
  16. package/dist/components/FormComponent/helpers/addLabel.js +5 -4
  17. package/dist/components/FormComponent/helpers/getComponentFieldSet.js +16 -0
  18. package/dist/components/FormComponent/helpers/getComponentFieldSet.test.js +29 -0
  19. package/dist/components/FormComponent/helpers/index.js +8 -1
  20. package/dist/components/FormPage/FormPage.js +69 -30
  21. package/dist/components/FormPage/FormPage.stories.mdx +155 -0
  22. package/dist/components/FormPage/FormPage.test.js +330 -0
  23. package/dist/components/FormRenderer/FormRenderer.js +142 -228
  24. package/dist/components/FormRenderer/FormRenderer.stories.mdx +183 -0
  25. package/dist/components/FormRenderer/FormRenderer.test.js +968 -0
  26. package/dist/components/FormRenderer/handlers/index.js +1 -2
  27. package/dist/components/FormRenderer/handlers/navigate.js +3 -1
  28. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.js +35 -14
  29. package/dist/components/FormRenderer/helpers/cleanHiddenNestedData.test.js +88 -5
  30. package/dist/components/FormRenderer/helpers/getCYA.js +11 -2
  31. package/dist/components/FormRenderer/helpers/getNextPageId.js +13 -7
  32. package/dist/components/FormRenderer/helpers/getRelevantPages.js +10 -2
  33. package/dist/components/FormRenderer/helpers/getRelevantPages.test.js +1 -1
  34. package/dist/components/FormRenderer/helpers/getSubmissionStatus.js +2 -2
  35. package/dist/components/FormRenderer/helpers/getSubmissionStatus.test.js +6 -2
  36. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.js +171 -51
  37. package/dist/components/FormRenderer/helpers/getUpdatedSectionStates.test.js +307 -24
  38. package/dist/components/FormRenderer/helpers/index.js +1 -2
  39. package/dist/components/FormRenderer/onCYAAction.js +108 -0
  40. package/dist/components/FormRenderer/onCYAAction.test.js +583 -0
  41. package/dist/components/FormRenderer/onPageAction.js +145 -0
  42. package/dist/components/FormRenderer/onPageAction.test.js +678 -0
  43. package/dist/components/FormRenderer/onTaskAction.js +48 -0
  44. package/dist/components/FormRenderer/onTaskAction.test.js +217 -0
  45. package/dist/components/PageActions/ActionButton.js +0 -3
  46. package/dist/components/PageActions/ActionButton.test.js +93 -0
  47. package/dist/components/PageActions/PageActions.js +2 -2
  48. package/dist/components/PageActions/PageActions.stories.mdx +74 -0
  49. package/dist/components/PageActions/PageActions.test.js +132 -0
  50. package/dist/components/SummaryList/GroupAction.js +2 -2
  51. package/dist/components/SummaryList/GroupAction.test.js +80 -0
  52. package/dist/components/SummaryList/RowAction.js +2 -2
  53. package/dist/components/SummaryList/RowAction.test.js +80 -0
  54. package/dist/components/SummaryList/SummaryList.js +29 -12
  55. package/dist/components/SummaryList/SummaryList.scss +19 -0
  56. package/dist/components/SummaryList/SummaryList.stories.mdx +90 -0
  57. package/dist/components/SummaryList/SummaryList.test.js +400 -0
  58. package/dist/components/SummaryList/SummaryListHeadingRow.js +30 -0
  59. package/dist/components/SummaryList/SummaryListRow.js +5 -2
  60. package/dist/components/SummaryList/helpers/getGroupActionAttributes.js +2 -1
  61. package/dist/components/SummaryList/helpers/getRowActionAttributes.js +2 -1
  62. package/dist/components/TaskList/Task.js +3 -3
  63. package/dist/components/TaskList/Task.test.js +167 -0
  64. package/dist/components/TaskList/TaskList.js +73 -22
  65. package/dist/components/TaskList/TaskList.stories.mdx +164 -0
  66. package/dist/components/TaskList/TaskList.test.js +389 -0
  67. package/dist/components/TaskList/TaskState.js +2 -2
  68. package/dist/components/TaskList/TaskState.test.js +86 -0
  69. package/dist/components/index.js +14 -0
  70. package/dist/context/HooksContext/HooksContext.js +72 -8
  71. package/dist/context/HooksContext/HooksContext.test.js +44 -0
  72. package/dist/context/ValidationContext/ValidationContext.js +38 -28
  73. package/dist/context/ValidationContext/ValidationContext.test.js +84 -0
  74. package/dist/hooks/useAxios.js +10 -12
  75. package/dist/hooks/useGetRequest.js +48 -49
  76. package/dist/hooks/useRefData.js +7 -4
  77. package/dist/index.js +34 -1
  78. package/dist/json/addressDetails.json +149 -0
  79. package/dist/json/areYouACivilServant.json +7 -0
  80. package/dist/json/firstForm.json +94 -0
  81. package/dist/json/grade.json +108 -0
  82. package/dist/json/group.data.json +21 -0
  83. package/dist/json/group.json +402 -0
  84. package/dist/json/groupOfRow.json +137 -0
  85. package/dist/json/groupOfRowData.json +15 -0
  86. package/dist/json/port.json +346 -0
  87. package/dist/json/saveAndContinue.json +98 -0
  88. package/dist/json/sublocation.json +859 -0
  89. package/dist/json/taskList.json +265 -0
  90. package/dist/json/team.json +17351 -0
  91. package/dist/json/terminal.json +81 -0
  92. package/dist/json/userProfile.data.json +21 -0
  93. package/dist/json/userProfile.json +276 -0
  94. package/dist/models/ComponentTypes.js +8 -0
  95. package/dist/models/PageAction.js +4 -1
  96. package/dist/models/TaskStates.js +10 -2
  97. package/dist/models/index.js +16 -1
  98. package/dist/setupTests.js +46 -0
  99. package/dist/utils/CheckYourAnswers/getCYAAction.js +5 -5
  100. package/dist/utils/CheckYourAnswers/getCYAAction.test.js +121 -0
  101. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.js +6 -2
  102. package/dist/utils/CheckYourAnswers/getCYACollectionChangeAction.test.js +71 -0
  103. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.js +6 -2
  104. package/dist/utils/CheckYourAnswers/getCYACollectionDeleteAction.test.js +55 -0
  105. package/dist/utils/CheckYourAnswers/getCYARow.js +14 -11
  106. package/dist/utils/CheckYourAnswers/getCYARow.test.js +291 -0
  107. package/dist/utils/CheckYourAnswers/getCYARowForGroup.js +4 -1
  108. package/dist/utils/CheckYourAnswers/getCYARowForGroup.test.js +70 -0
  109. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.js +15 -10
  110. package/dist/utils/CheckYourAnswers/getCYARowsForCollection.test.js +288 -0
  111. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.js +94 -36
  112. package/dist/utils/CheckYourAnswers/getCYARowsForCollectionPage.test.js +414 -0
  113. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.js +21 -7
  114. package/dist/utils/CheckYourAnswers/getCYARowsForContainer.test.js +486 -0
  115. package/dist/utils/CheckYourAnswers/getCYARowsForPage.js +11 -3
  116. package/dist/utils/CheckYourAnswers/getCYARowsForPage.test.js +346 -0
  117. package/dist/utils/CheckYourAnswers/showComponentCYA.js +19 -3
  118. package/dist/utils/CheckYourAnswers/showComponentCYA.test.js +143 -0
  119. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.js +5 -1
  120. package/dist/utils/CollectionPage/duplicateCollectionPageActiveEntry.test.js +40 -0
  121. package/dist/utils/CollectionPage/getCollectionPageActiveIndex.test.js +53 -0
  122. package/dist/utils/CollectionPage/mergeCollectionPages.js +25 -17
  123. package/dist/utils/CollectionPage/mergeCollectionPages.test.js +130 -0
  124. package/dist/utils/Component/addShowWhen.js +44 -0
  125. package/dist/utils/Component/addShowWhen.test.js +216 -0
  126. package/dist/utils/Component/applyToComponentTree.js +71 -0
  127. package/dist/utils/Component/applyToComponentTree.test.js +127 -0
  128. package/dist/utils/Component/cleanAttributes.js +8 -2
  129. package/dist/utils/Component/cleanAttributes.test.js +68 -0
  130. package/dist/utils/Component/elevateNestedComponents.js +4 -1
  131. package/dist/utils/Component/elevateNestedComponents.test.js +122 -0
  132. package/dist/utils/Component/getComponent.js +80 -11
  133. package/dist/utils/Component/getComponentTests/getComponent.autocomplete.test.js +4 -4
  134. package/dist/utils/Component/getComponentTests/getComponent.calculation.test.js +25 -24
  135. package/dist/utils/Component/getComponentTests/getComponent.checkboxes.test.js +66 -5
  136. package/dist/utils/Component/getComponentTests/getComponent.date.test.js +2 -2
  137. package/dist/utils/Component/getComponentTests/getComponent.details.test.js +9 -7
  138. package/dist/utils/Component/getComponentTests/getComponent.email.test.js +3 -3
  139. package/dist/utils/Component/getComponentTests/getComponent.file.test.js +3 -3
  140. package/dist/utils/Component/getComponentTests/getComponent.list.test.js +44 -0
  141. package/dist/utils/Component/getComponentTests/{getComponent.textarea.test.js → getComponent.multifile.test.js} +29 -21
  142. package/dist/utils/Component/getComponentTests/getComponent.nested.test.js +159 -83
  143. package/dist/utils/Component/getComponentTests/getComponent.paragraph.test.js +43 -0
  144. package/dist/utils/Component/getComponentTests/getComponent.phoneNumber.test.js +3 -3
  145. package/dist/utils/Component/getComponentTests/getComponent.radios.test.js +55 -5
  146. package/dist/utils/Component/getComponentTests/getComponent.select.test.js +3 -9
  147. package/dist/utils/Component/getComponentTests/getComponent.text.test.js +3 -3
  148. package/dist/utils/Component/getComponentTests/getComponent.textArea.test.js +109 -0
  149. package/dist/utils/Component/getComponentTests/getComponent.time.test.js +7 -7
  150. package/dist/utils/Component/getDefaultValue.js +4 -1
  151. package/dist/utils/Component/getDefaultValue.test.js +50 -0
  152. package/dist/utils/Component/index.js +2 -0
  153. package/dist/utils/Component/isEditable.js +2 -2
  154. package/dist/utils/Component/isEditable.test.js +43 -0
  155. package/dist/utils/Component/optionIsSelected.js +22 -0
  156. package/dist/utils/Component/optionIsSelected.test.js +42 -0
  157. package/dist/utils/Component/setupContainerComponentsPath.js +40 -0
  158. package/dist/utils/Component/setupContainerComponentsPath.test.js +78 -0
  159. package/dist/utils/Component/showComponent.test.js +156 -0
  160. package/dist/utils/Component/wrapInFormGroup.js +1 -1
  161. package/dist/utils/Condition/meetsAllConditions.js +1 -1
  162. package/dist/utils/Condition/meetsAllConditions.test.js +61 -0
  163. package/dist/utils/Condition/meetsCondition.js +74 -4
  164. package/dist/utils/Condition/meetsCondition.test.js +763 -0
  165. package/dist/utils/Condition/meetsOneCondition.js +1 -1
  166. package/dist/utils/Condition/meetsOneCondition.test.js +100 -0
  167. package/dist/utils/Condition/setupConditions.js +6 -3
  168. package/dist/utils/Condition/setupConditions.test.js +33 -0
  169. package/dist/utils/Container/getEditableComponents.test.js +135 -0
  170. package/dist/utils/Container/setupNesting.js +21 -2
  171. package/dist/utils/Container/setupNesting.test.js +145 -0
  172. package/dist/utils/Container/showContainer.test.js +178 -0
  173. package/dist/utils/Data/applyFormula.js +20 -11
  174. package/dist/utils/Data/applyFormula.test.js +263 -0
  175. package/dist/utils/Data/getAutocompleteSource.js +6 -2
  176. package/dist/utils/Data/getAutocompleteSource.test.js +352 -0
  177. package/dist/utils/Data/getDataPath.test.js +48 -0
  178. package/dist/utils/Data/getOptions.js +17 -3
  179. package/dist/utils/Data/getOptions.test.js +140 -0
  180. package/dist/utils/Data/getSourceData.js +2 -2
  181. package/dist/utils/Data/getSourceData.test.js +153 -0
  182. package/dist/utils/Data/refDataToOptions.js +4 -1
  183. package/dist/utils/Data/refDataToOptions.test.js +196 -0
  184. package/dist/utils/Data/setDataItem.test.js +110 -0
  185. package/dist/utils/Data/setupFormData.js +39 -16
  186. package/dist/utils/Data/setupFormData.test.js +410 -0
  187. package/dist/utils/Data/setupRefDataUrlForComponent.js +4 -1
  188. package/dist/utils/Data/setupRefDataUrlForComponent.test.js +131 -0
  189. package/dist/utils/FormPage/applyConditionalProperties.js +35 -0
  190. package/dist/utils/FormPage/applyConditionalProperties.test.js +61 -0
  191. package/dist/utils/FormPage/getFormPage.js +5 -2
  192. package/dist/utils/FormPage/getFormPage.test.js +206 -0
  193. package/dist/utils/FormPage/getFormPages.js +4 -1
  194. package/dist/utils/FormPage/getFormPages.test.js +97 -0
  195. package/dist/utils/FormPage/getPageActions.js +8 -4
  196. package/dist/utils/FormPage/getPageActions.test.js +114 -0
  197. package/dist/utils/FormPage/getParagraphFromText.test.js +27 -0
  198. package/dist/utils/FormPage/index.js +2 -0
  199. package/dist/utils/FormPage/showFormPage.js +2 -2
  200. package/dist/utils/FormPage/showFormPage.test.js +180 -0
  201. package/dist/utils/FormPage/showFormPageCYA.js +1 -0
  202. package/dist/utils/FormPage/showFormPageCYA.test.js +28 -0
  203. package/dist/utils/FormPage/useComponent.js +29 -14
  204. package/dist/utils/FormPage/useComponent.test.js +167 -0
  205. package/dist/utils/Format/formatData.test.js +45 -0
  206. package/dist/utils/Format/formatDataForComponent.js +2 -1
  207. package/dist/utils/Format/formatDataForComponent.test.js +142 -0
  208. package/dist/utils/Format/formatDataForForm.js +4 -1
  209. package/dist/utils/Format/formatDataForForm.test.js +81 -0
  210. package/dist/utils/Format/formatDataForPage.test.js +99 -0
  211. package/dist/utils/Hub/getFormHub.test.js +105 -0
  212. package/dist/utils/Meta/documents/getDocuments.test.js +4 -1
  213. package/dist/utils/Meta/documents/index.js +2 -2
  214. package/dist/utils/Meta/documents/setDocumentsForField.js +31 -0
  215. package/dist/utils/Meta/documents/setDocumentsForField.test.js +59 -0
  216. package/dist/utils/Operate/checkValueIsTruthy.test.js +42 -0
  217. package/dist/utils/Operate/getFirstOf.js +31 -0
  218. package/dist/utils/Operate/getFirstOf.test.js +86 -0
  219. package/dist/utils/Operate/getIndexOfMatchingValueIn.test.js +163 -0
  220. package/dist/utils/Operate/persistValueInFormData.js +2 -1
  221. package/dist/utils/Operate/persistValueInFormData.test.js +115 -0
  222. package/dist/utils/Operate/runPageOperations.js +3 -1
  223. package/dist/utils/Operate/runPageOperations.test.js +105 -0
  224. package/dist/utils/Operate/setValueInFormData.test.js +44 -0
  225. package/dist/utils/Operate/shouldRun.js +16 -13
  226. package/dist/utils/Operate/shouldRun.test.js +66 -0
  227. package/dist/utils/Validate/additional/conditionallyRequired.js +24 -0
  228. package/dist/utils/Validate/additional/conditionallyRequired.test.js +73 -0
  229. package/dist/utils/Validate/additional/index.js +13 -4
  230. package/dist/utils/Validate/additional/mustBeAfter.js +8 -6
  231. package/dist/utils/Validate/additional/mustBeAfter.test.js +15 -1
  232. package/dist/utils/Validate/additional/mustBeBefore.js +9 -5
  233. package/dist/utils/Validate/additional/mustBeBefore.test.js +14 -0
  234. package/dist/utils/Validate/additional/mustBeEarlierDateTime.js +1 -1
  235. package/dist/utils/Validate/additional/mustBeEarlierDateTime.test.js +6 -3
  236. package/dist/utils/Validate/additional/mustBeGreaterThan.js +22 -0
  237. package/dist/utils/Validate/additional/mustBeGreaterThan.test.js +56 -0
  238. package/dist/utils/Validate/additional/mustBeInTheFuture.js +1 -1
  239. package/dist/utils/Validate/additional/mustBeInThePast.js +5 -5
  240. package/dist/utils/Validate/additional/mustBeLessThan.js +7 -6
  241. package/dist/utils/Validate/additional/mustBeLessThan.test.js +11 -1
  242. package/dist/utils/Validate/additional/mustBeNumbersOnly.js +9 -5
  243. package/dist/utils/Validate/additional/mustBeNumbersOnly.test.js +10 -2
  244. package/dist/utils/Validate/additional/mustEnterAtLeastOne.js +1 -0
  245. package/dist/utils/Validate/additional/mustEnterAtLeastOne.test.js +4 -1
  246. package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.js +19 -0
  247. package/dist/utils/Validate/additional/mustHaveLessThanDecimalPlaces.test.js +36 -0
  248. package/dist/utils/Validate/additional/mustSelectOnlyOne.js +29 -0
  249. package/dist/utils/Validate/additional/mustSelectOnlyOne.test.js +52 -0
  250. package/dist/utils/Validate/additional/utils.js +18 -18
  251. package/dist/utils/Validate/index.js +6 -0
  252. package/dist/utils/Validate/validateCollection.js +20 -5
  253. package/dist/utils/Validate/validateCollection.test.js +125 -0
  254. package/dist/utils/Validate/validateComponent.js +36 -20
  255. package/dist/utils/Validate/validateComponent.test.js +365 -0
  256. package/dist/utils/Validate/validateContainer.js +9 -3
  257. package/dist/utils/Validate/validateContainer.test.js +75 -0
  258. package/dist/utils/Validate/validateDate.js +4 -3
  259. package/dist/utils/Validate/validateDate.test.js +114 -0
  260. package/dist/utils/Validate/validateEmail.js +14 -1
  261. package/dist/utils/Validate/validateEmail.test.js +74 -0
  262. package/dist/utils/Validate/validateMultifile.js +32 -0
  263. package/dist/utils/Validate/validateMultifile.test.js +47 -0
  264. package/dist/utils/Validate/validatePage.js +12 -6
  265. package/dist/utils/Validate/validatePage.test.js +472 -0
  266. package/dist/utils/Validate/validateRegex.js +2 -5
  267. package/dist/utils/Validate/validateRegex.test.js +42 -0
  268. package/dist/utils/Validate/validateRequired.js +2 -4
  269. package/dist/utils/Validate/validateRequired.test.js +63 -0
  270. package/dist/utils/Validate/validateTextArea.js +37 -0
  271. package/dist/utils/Validate/validateTextArea.test.js +42 -0
  272. package/dist/utils/Validate/validateTime.js +2 -2
  273. package/dist/utils/Validate/validateTime.test.js +59 -0
  274. package/dist/utils/index.js +4 -1
  275. package/package.json +35 -50
  276. package/dist/utils/Meta/documents/setDocumentForField.js +0 -29
  277. package/dist/utils/Meta/documents/setDocumentForField.test.js +0 -49
@@ -8,11 +8,15 @@ var _copReactComponents = require("@ukhomeoffice/cop-react-components");
8
8
  var _models = require("../../models");
9
9
  var _getCYAAction = _interopRequireDefault(require("./getCYAAction"));
10
10
  var _getCYARowsForContainer = _interopRequireDefault(require("./getCYARowsForContainer"));
11
+ var _setupContainerComponentsPath = _interopRequireDefault(require("../Component/setupContainerComponentsPath"));
11
12
  var _showComponentCYA = _interopRequireDefault(require("./showComponentCYA"));
12
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
14
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
13
15
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
14
16
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
15
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
19
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
16
20
  var getEntryToCollectionRow = function getEntryToCollectionRow(page, onAction) {
17
21
  var _page$components$0$la;
18
22
  return [{
@@ -22,30 +26,30 @@ var getEntryToCollectionRow = function getEntryToCollectionRow(page, onAction) {
22
26
  action: (0, _getCYAAction.default)(false, page, onAction)
23
27
  }];
24
28
  };
25
- var getContainerForItem = function getContainerForItem(collection, item, labelCount, full_path) {
29
+ var getContainerForItem = function getContainerForItem(collection, item, labelCount, fullPath) {
26
30
  return {
27
31
  id: item.id,
28
32
  fieldId: item.id,
29
33
  type: _models.ComponentTypes.CONTAINER,
30
34
  required: collection.required,
31
- full_path: full_path,
35
+ full_path: fullPath,
32
36
  components: collection.item.map(function (component) {
33
37
  return _objectSpread(_objectSpread({}, component), {}, {
34
38
  label: _copReactComponents.Utils.interpolateString(component.label, _objectSpread(_objectSpread({}, item), {}, {
35
39
  index: labelCount
36
40
  })),
37
- full_path: "".concat(full_path, ".").concat(component.fieldId)
41
+ full_path: "".concat(fullPath, ".").concat(component.fieldId)
38
42
  });
39
43
  })
40
44
  };
41
45
  };
42
- var getTitleRowForItem = function getTitleRowForItem(collection, item, pageId, labelCount, full_path) {
46
+ var getTitleRowForItem = function getTitleRowForItem(collection, item, pageId, labelCount, fullPath) {
43
47
  var labels = _objectSpread(_objectSpread({}, _models.CollectionLabels), collection.labels);
44
48
  if (labels.item) {
45
49
  return {
46
50
  pageId: pageId,
47
51
  fieldId: collection.fieldId,
48
- full_path: full_path,
52
+ full_path: fullPath,
49
53
  key: _copReactComponents.Utils.interpolateString(labels.item, _objectSpread(_objectSpread({}, item), {}, {
50
54
  index: labelCount
51
55
  })),
@@ -55,13 +59,14 @@ var getTitleRowForItem = function getTitleRowForItem(collection, item, pageId, l
55
59
  }
56
60
  return null;
57
61
  };
58
- var getCYARowsForCollection = function getCYARowsForCollection(page, collection, items, onAction) {
62
+ var getCYARowsForCollection = function getCYARowsForCollection(page, collection, items, onAction, fnOverride) {
59
63
  if (Array.isArray(items) && items.length && (0, _showComponentCYA.default)(collection, page.formData)) {
60
64
  return items.flatMap(function (item, index) {
61
65
  var labelCount = (collection.countOffset || 0) + index + 1;
62
- var full_path = "".concat(collection.full_path || collection.fieldId, "[").concat(index, "]");
63
- var container = getContainerForItem(collection, item, labelCount, full_path);
64
- return [getTitleRowForItem(collection, item, page.id, labelCount, full_path)].concat((0, _getCYARowsForContainer.default)(page, container, item, onAction));
66
+ var fullPath = "".concat(collection.full_path || collection.fieldId, "[").concat(index, "]");
67
+ var container = getContainerForItem(collection, item, labelCount, fullPath);
68
+ container = (0, _setupContainerComponentsPath.default)(container);
69
+ return [getTitleRowForItem(collection, item, page.id, labelCount, fullPath)].concat((0, _getCYARowsForContainer.default)(page, container, item, onAction, fnOverride));
65
70
  }).filter(function (r) {
66
71
  return !!r;
67
72
  });
@@ -0,0 +1,288 @@
1
+ "use strict";
2
+
3
+ var _models = require("../../models");
4
+ var _setupTests = require("../../setupTests");
5
+ var _getCYARowsForCollection = _interopRequireDefault(require("./getCYARowsForCollection"));
6
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
7
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
8
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
9
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
10
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
11
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
12
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
13
+ describe('utils.CheckYourAnswers.getCYARowsForCollection', function () {
14
+ it('should get a single entry point row when there are no items', function () {
15
+ var FORM_DATA = undefined;
16
+ var PAGE = {
17
+ id: 'page',
18
+ components: [{
19
+ labels: {
20
+ add: 'Add'
21
+ }
22
+ }],
23
+ formData: FORM_DATA,
24
+ cya_link: {}
25
+ };
26
+ var COMPONENT = {
27
+ type: 'text',
28
+ readonly: true,
29
+ id: 'a',
30
+ fieldId: 'a',
31
+ label: 'Alpha'
32
+ };
33
+ var COLLECTION = {
34
+ id: 'collection',
35
+ fieldId: 'collection',
36
+ type: _models.ComponentTypes.COLLECTION,
37
+ item: [COMPONENT]
38
+ };
39
+ var ON_ACTION = function ON_ACTION() {};
40
+ var ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, undefined, ON_ACTION);
41
+ expect(ROWS.length).toEqual(1);
42
+ });
43
+ it('should get an appropriate row for a collection with a single readonly text component', function () {
44
+ var FORM_DATA = {
45
+ collection: [{
46
+ a: 'Bravo'
47
+ }]
48
+ };
49
+ var PAGE = {
50
+ id: 'page',
51
+ formData: FORM_DATA,
52
+ cya_link: {}
53
+ };
54
+ var COMPONENT = {
55
+ type: 'text',
56
+ readonly: true,
57
+ id: 'a',
58
+ fieldId: 'a',
59
+ label: 'Alpha'
60
+ };
61
+ var COLLECTION = {
62
+ id: 'collection',
63
+ fieldId: 'collection',
64
+ type: _models.ComponentTypes.COLLECTION,
65
+ countOffset: 22,
66
+ item: [COMPONENT],
67
+ value: FORM_DATA.collection,
68
+ formData: FORM_DATA
69
+ };
70
+ var ON_ACTION = function ON_ACTION() {};
71
+ var ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, FORM_DATA.collection, ON_ACTION);
72
+ expect(ROWS.length).toEqual(2); // Item title row + component row
73
+ (0, _setupTests.expectObjectLike)(ROWS[0], {
74
+ pageId: PAGE.id,
75
+ fieldId: COLLECTION.fieldId,
76
+ full_path: "".concat(COLLECTION.fieldId, "[0]"),
77
+ key: 'Item 23',
78
+ // includes countOffset
79
+ type: 'title',
80
+ action: null
81
+ });
82
+ (0, _setupTests.expectObjectLike)(ROWS[1], {
83
+ pageId: PAGE.id,
84
+ fieldId: COMPONENT.fieldId,
85
+ full_path: "".concat(COLLECTION.fieldId, "[0].").concat(COMPONENT.fieldId),
86
+ key: COMPONENT.label,
87
+ action: null,
88
+ component: _objectSpread(_objectSpread({}, COMPONENT), {}, {
89
+ full_path: "".concat(COLLECTION.fieldId, "[0].").concat(COMPONENT.fieldId)
90
+ }),
91
+ value: 'Bravo'
92
+ });
93
+ });
94
+ it('should get an appropriate row for a collection with a single readonly text component where the item label is an empty string', function () {
95
+ var FORM_DATA = {
96
+ collection: [{
97
+ a: 'Bravo'
98
+ }]
99
+ };
100
+ var PAGE = {
101
+ id: 'page',
102
+ formData: FORM_DATA,
103
+ cya_link: {}
104
+ };
105
+ var COMPONENT = {
106
+ type: 'text',
107
+ readonly: true,
108
+ id: 'a',
109
+ fieldId: 'a',
110
+ label: 'Alpha'
111
+ };
112
+ var COLLECTION = {
113
+ id: 'collection',
114
+ fieldId: 'collection',
115
+ type: _models.ComponentTypes.COLLECTION,
116
+ labels: {
117
+ item: ''
118
+ },
119
+ countOffset: 22,
120
+ item: [COMPONENT],
121
+ value: FORM_DATA.collection,
122
+ formData: FORM_DATA
123
+ };
124
+ var ON_ACTION = function ON_ACTION() {};
125
+ var ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, FORM_DATA.collection, ON_ACTION);
126
+ expect(ROWS.length).toEqual(1); // Just the component row, no title row
127
+ (0, _setupTests.expectObjectLike)(ROWS[0], {
128
+ pageId: PAGE.id,
129
+ fieldId: COMPONENT.fieldId,
130
+ full_path: "".concat(COLLECTION.fieldId, "[0].").concat(COMPONENT.fieldId),
131
+ key: COMPONENT.label,
132
+ action: null,
133
+ component: _objectSpread(_objectSpread({}, COMPONENT), {}, {
134
+ full_path: "".concat(COLLECTION.fieldId, "[0].").concat(COMPONENT.fieldId)
135
+ }),
136
+ value: 'Bravo'
137
+ });
138
+ });
139
+ it('should interpolate a field label appropriately', function () {
140
+ var FORM_DATA = {
141
+ collection: [{
142
+ a: 'Bravo'
143
+ }]
144
+ };
145
+ var PAGE = {
146
+ id: 'page',
147
+ formData: FORM_DATA,
148
+ cya_link: {}
149
+ };
150
+ // eslint-disable-next-line no-template-curly-in-string
151
+ var COMPONENT = {
152
+ type: 'text',
153
+ readonly: true,
154
+ id: 'a',
155
+ fieldId: 'a',
156
+ label: 'Alpha ${index}'
157
+ };
158
+ var COLLECTION = {
159
+ id: 'collection',
160
+ fieldId: 'collection',
161
+ type: _models.ComponentTypes.COLLECTION,
162
+ item: [COMPONENT],
163
+ value: FORM_DATA.collection,
164
+ formData: FORM_DATA
165
+ };
166
+ var ON_ACTION = function ON_ACTION() {};
167
+ var ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, FORM_DATA.collection, ON_ACTION);
168
+ expect(ROWS.length).toEqual(2); // Title and item row.
169
+ (0, _setupTests.expectObjectLike)(ROWS[1], {
170
+ pageId: PAGE.id,
171
+ fieldId: COMPONENT.fieldId,
172
+ full_path: "".concat(COLLECTION.fieldId, "[0].").concat(COMPONENT.fieldId),
173
+ key: 'Alpha 1',
174
+ // no countOffset
175
+ action: null,
176
+ component: _objectSpread(_objectSpread({}, COMPONENT), {}, {
177
+ full_path: "".concat(COLLECTION.fieldId, "[0].").concat(COMPONENT.fieldId),
178
+ label: 'Alpha 1' // no countOffset
179
+ }),
180
+
181
+ value: 'Bravo'
182
+ });
183
+ });
184
+ it('should ignore the result of the override function if it returns nullish', function () {
185
+ var FORM_DATA = {
186
+ collection: [{
187
+ a: 'Bravo'
188
+ }]
189
+ };
190
+ var PAGE = {
191
+ id: 'page',
192
+ formData: FORM_DATA,
193
+ cya_link: {}
194
+ };
195
+ var COMPONENT = {
196
+ type: 'text',
197
+ readonly: true,
198
+ id: 'a',
199
+ fieldId: 'a',
200
+ label: 'Alpha'
201
+ };
202
+ var COLLECTION = {
203
+ id: 'collection',
204
+ fieldId: 'collection',
205
+ type: _models.ComponentTypes.COLLECTION,
206
+ countOffset: 22,
207
+ item: [COMPONENT],
208
+ value: FORM_DATA.collection,
209
+ formData: FORM_DATA
210
+ };
211
+ var ON_ACTION = function ON_ACTION() {};
212
+ var ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, FORM_DATA.collection, ON_ACTION, function () {
213
+ return null;
214
+ });
215
+ expect(ROWS.length).toEqual(2); // Item title row + component row
216
+ (0, _setupTests.expectObjectLike)(ROWS[0], {
217
+ pageId: PAGE.id,
218
+ fieldId: COLLECTION.fieldId,
219
+ full_path: "".concat(COLLECTION.fieldId, "[0]"),
220
+ key: 'Item 23',
221
+ // includes countOffset
222
+ type: 'title',
223
+ action: null
224
+ });
225
+ (0, _setupTests.expectObjectLike)(ROWS[1], {
226
+ pageId: PAGE.id,
227
+ fieldId: COMPONENT.fieldId,
228
+ full_path: "".concat(COLLECTION.fieldId, "[0].").concat(COMPONENT.fieldId),
229
+ key: COMPONENT.label,
230
+ action: null,
231
+ component: _objectSpread(_objectSpread({}, COMPONENT), {}, {
232
+ full_path: "".concat(COLLECTION.fieldId, "[0].").concat(COMPONENT.fieldId)
233
+ }),
234
+ value: 'Bravo'
235
+ });
236
+ });
237
+ it('should use rows produced by the override function if provided', function () {
238
+ var FORM_DATA = {
239
+ collection: [{
240
+ a: 'Bravo'
241
+ }]
242
+ };
243
+ var PAGE = {
244
+ id: 'page',
245
+ formData: FORM_DATA,
246
+ cya_link: {}
247
+ };
248
+ var COMPONENT = {
249
+ type: 'text',
250
+ readonly: true,
251
+ id: 'a',
252
+ fieldId: 'a',
253
+ label: 'Alpha'
254
+ };
255
+ var COLLECTION = {
256
+ id: 'collection',
257
+ fieldId: 'collection',
258
+ type: _models.ComponentTypes.COLLECTION,
259
+ countOffset: 22,
260
+ item: [COMPONENT],
261
+ value: FORM_DATA.collection,
262
+ formData: FORM_DATA
263
+ };
264
+ var ON_ACTION = function ON_ACTION() {};
265
+ // eslint-disable-next-line arrow-body-style
266
+ var OVERRIDE = function OVERRIDE(page, comp) {
267
+ // This will be called for each component in the collection,
268
+ // returning a custom row object.
269
+ return {
270
+ key: "CustomRowFor".concat(comp.label)
271
+ };
272
+ };
273
+ var ROWS = (0, _getCYARowsForCollection.default)(PAGE, COLLECTION, FORM_DATA.collection, ON_ACTION, OVERRIDE);
274
+ expect(ROWS.length).toEqual(2); // Item title row + component row
275
+ (0, _setupTests.expectObjectLike)(ROWS[0], {
276
+ pageId: PAGE.id,
277
+ fieldId: COLLECTION.fieldId,
278
+ full_path: "".concat(COLLECTION.fieldId, "[0]"),
279
+ key: 'Item 23',
280
+ // includes countOffset
281
+ type: 'title',
282
+ action: null
283
+ });
284
+ (0, _setupTests.expectObjectLike)(ROWS[1], {
285
+ key: "CustomRowFor".concat(COMPONENT.label)
286
+ });
287
+ });
288
+ });
@@ -5,79 +5,137 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.default = void 0;
7
7
  var _copReactComponents = require("@ukhomeoffice/cop-react-components");
8
- var _elevateNestedComponents = _interopRequireDefault(require("../Component/elevateNestedComponents"));
9
8
  var _models = require("../../models");
10
- var _getCYARowsForContainer = _interopRequireDefault(require("./getCYARowsForContainer"));
9
+ var _addShowWhen = _interopRequireDefault(require("../Component/addShowWhen"));
10
+ var _showFormPageCYA = _interopRequireDefault(require("../FormPage/showFormPageCYA"));
11
11
  var _getCYACollectionDeleteAction = _interopRequireDefault(require("./getCYACollectionDeleteAction"));
12
12
  var _getCYACollectionChangeAction = _interopRequireDefault(require("./getCYACollectionChangeAction"));
13
- var _showComponentCYA = _interopRequireDefault(require("./showComponentCYA"));
13
+ var _getCYARowsForContainer = _interopRequireDefault(require("./getCYARowsForContainer"));
14
14
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
15
+ function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
15
16
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
16
17
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
17
- function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
18
- var getContainerForPage = function getContainerForPage(page, item, labelCount, full_path) {
19
- var allComponents = (0, _elevateNestedComponents.default)(page.components, item);
18
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
19
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
20
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
21
+ var getContainerForPage = function getContainerForPage(page, item, labelCount, fullPath) {
20
22
  return {
21
23
  id: item.id,
22
24
  fieldId: item.id,
23
25
  type: _models.ComponentTypes.CONTAINER,
24
26
  required: true,
25
- full_path: full_path,
26
- components: allComponents.map(function (component) {
27
- if ((0, _showComponentCYA.default)(component, item)) {
28
- return _objectSpread(_objectSpread({}, component), {}, {
29
- label: _copReactComponents.Utils.interpolateString(component.label, _objectSpread(_objectSpread({}, item), {}, {
30
- index: labelCount
31
- })),
32
- full_path: "".concat(full_path, ".").concat(component.fieldId)
33
- });
34
- }
35
- return undefined;
36
- }).filter(function (c) {
37
- return c;
27
+ full_path: fullPath,
28
+ components: page.components.map(function (component) {
29
+ return _objectSpread(_objectSpread({}, component), {}, {
30
+ label: _copReactComponents.Utils.interpolateString(component.label, _objectSpread(_objectSpread({}, item), {}, {
31
+ index: labelCount
32
+ })),
33
+ full_path: "".concat(fullPath, ".").concat(component.fieldId)
34
+ });
38
35
  })
39
36
  };
40
37
  };
41
- var getTitleRowForItem = function getTitleRowForItem(page, item, pageId, labelCount, full_path) {
38
+ var getTitleRowForItem = function getTitleRowForItem(page, item, pageId, labelCount, fullPath) {
42
39
  var labels = _objectSpread(_objectSpread({}, _models.CollectionLabels), page.collection.labels);
43
40
  return {
44
41
  pageId: pageId,
45
42
  fieldId: 'Title',
46
- full_path: "".concat(full_path, ".Title"),
43
+ full_path: "".concat(fullPath, ".Title"),
47
44
  key: _copReactComponents.Utils.interpolateString(labels.item, _objectSpread(_objectSpread({}, item), {}, {
48
45
  index: labelCount
49
46
  })),
50
- type: 'title'
47
+ type: 'heading',
48
+ size: page.collection.titleSize || 's'
49
+ };
50
+ };
51
+ var getHeadingRow = function getHeadingRow(config, pageId, labelCount) {
52
+ if (config.text === '') {
53
+ return null;
54
+ }
55
+ return {
56
+ pageId: pageId,
57
+ fieldId: "heading".concat(labelCount),
58
+ full_path: "heading".concat(labelCount),
59
+ key: config.text,
60
+ type: 'heading',
61
+ size: config.size || 's'
51
62
  };
52
63
  };
53
64
  var getActionRows = function getActionRows(page, item, onAction, labelCount) {
54
65
  var _page$collection, _page$collection$acti;
55
- var actions = (_page$collection = page.collection) === null || _page$collection === void 0 ? void 0 : (_page$collection$acti = _page$collection.actions) === null || _page$collection$acti === void 0 ? void 0 : _page$collection$acti.map(function (action) {
66
+ return (_page$collection = page.collection) === null || _page$collection === void 0 ? void 0 : (_page$collection$acti = _page$collection.actions) === null || _page$collection$acti === void 0 ? void 0 : _page$collection$acti.map(function (action) {
56
67
  if (action.type === 'remove') {
57
68
  return (0, _getCYACollectionDeleteAction.default)(page, item, onAction, labelCount, action);
58
- } else if (action.type === 'change') {
69
+ }
70
+ if (action.type === 'change') {
59
71
  return (0, _getCYACollectionChangeAction.default)(page, item, onAction, labelCount, action);
60
- } else {
61
- return null;
62
72
  }
73
+ return null;
63
74
  }).filter(function (action) {
64
75
  return !!action;
65
76
  });
66
- return actions;
67
77
  };
68
- var getCYARowsForCollectionPage = function getCYARowsForCollectionPage(page, onAction) {
69
- var _page$formData, _page$formData$page$c;
78
+
79
+ // eslint-disable-next-line arrow-body-style
80
+ var getChangeActionForPage = function getChangeActionForPage(page, item, onAction) {
81
+ return function () {
82
+ var changeCallback = function changeCallback(changeData) {
83
+ var data = changeData;
84
+ data["".concat(page.collection.name, "ActiveId")] = item.id;
85
+ return data;
86
+ };
87
+ onAction({
88
+ pageId: page.id
89
+ }, changeCallback);
90
+ };
91
+ };
92
+ var getCYARowsForCollectionPage = function getCYARowsForCollectionPage(page, onAction, fnOverride) {
93
+ var _page$formData, _page$formData$page$c, _page$formData2, _page$formData2$page$;
94
+ if (!((_page$formData = page.formData) !== null && _page$formData !== void 0 && (_page$formData$page$c = _page$formData[page.collection.name]) !== null && _page$formData$page$c !== void 0 && _page$formData$page$c.length)) {
95
+ return [];
96
+ }
70
97
  var rows = [];
71
- (_page$formData = page.formData) === null || _page$formData === void 0 ? void 0 : (_page$formData$page$c = _page$formData[page.collection.name]) === null || _page$formData$page$c === void 0 ? void 0 : _page$formData$page$c.forEach(function (item, index) {
98
+ if (!page.collection.hideNameFromCYA) {
99
+ rows.push({
100
+ pageId: page.id,
101
+ fieldId: "".concat(page.collection.name, "Title"),
102
+ full_path: "".concat(page.collection.name, "Title"),
103
+ key: page.collection.name.charAt(0).toUpperCase() + page.collection.name.slice(1),
104
+ type: 'heading',
105
+ size: 'm'
106
+ });
107
+ }
108
+ (_page$formData2 = page.formData) === null || _page$formData2 === void 0 ? void 0 : (_page$formData2$page$ = _page$formData2[page.collection.name]) === null || _page$formData2$page$ === void 0 ? void 0 : _page$formData2$page$.forEach(function (item, index) {
109
+ var _page$collection2;
72
110
  var labelCount = index + 1;
73
- var full_path = "".concat(page.collection.name, "[").concat(index, "]");
74
- var container = getContainerForPage(page, item, labelCount, full_path);
75
- var containerRows = (0, _getCYARowsForContainer.default)(page, container, item, undefined);
76
- var titleRow = getTitleRowForItem(page, item, page.id, labelCount, full_path);
111
+ var actionPosition = ((_page$collection2 = page.collection) === null || _page$collection2 === void 0 ? void 0 : _page$collection2.actionPosition) || 'top';
112
+ var fullPath = "".concat(page.collection.name, "[").concat(index, "]");
113
+ var titleRow = getTitleRowForItem(page, item, page.id, labelCount, fullPath);
77
114
  var actionRows = getActionRows(page, item, onAction, labelCount);
78
115
  rows = rows.concat(titleRow);
79
- rows = rows.concat(actionRows);
80
- rows = rows.concat(containerRows);
116
+ if (actionPosition === 'top') {
117
+ rows = rows.concat(actionRows);
118
+ }
119
+ page.collectionPages.forEach(function (p) {
120
+ var collectionPage = p;
121
+ if (collectionPage.collection.route) {
122
+ var pageWithRoute = (0, _addShowWhen.default)(collectionPage, p.collection.route);
123
+ collectionPage = pageWithRoute || collectionPage;
124
+ }
125
+ if ((0, _showFormPageCYA.default)(collectionPage, _objectSpread(_objectSpread({}, collectionPage.formData), item))) {
126
+ if (collectionPage.collection.heading) {
127
+ var headingRow = getHeadingRow(collectionPage.collection.heading, collectionPage.id, labelCount);
128
+ rows = rows.concat(headingRow);
129
+ }
130
+ var container = getContainerForPage(collectionPage, item, labelCount, fullPath);
131
+ var rowChangeAction = getChangeActionForPage(collectionPage, item, onAction);
132
+ var containerRows = (0, _getCYARowsForContainer.default)(collectionPage, container, item, rowChangeAction, fnOverride);
133
+ rows = rows.concat(containerRows);
134
+ }
135
+ });
136
+ if (actionPosition === 'bottom') {
137
+ rows = rows.concat(actionRows);
138
+ }
81
139
  });
82
140
  return rows.filter(function (row) {
83
141
  return !!row;