@ministryofjustice/hmpps-digital-prison-reporting-frontend 4.28.8 → 4.29.1

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 (197) hide show
  1. package/dpr/all.js +6 -8
  2. package/dpr/all.js.map +3 -3
  3. package/dpr/all.scss +296 -414
  4. package/dpr/all.ts +6 -11
  5. package/dpr/components/_catalogue/catalogue-list/utils.test.ts +1 -1
  6. package/dpr/components/_charts/chart/ChartTimeseries.js +3 -2
  7. package/dpr/components/_charts/chart/ChartTimeseries.js.map +2 -2
  8. package/dpr/components/_charts/chart/ChartTimeseries.ts +4 -2
  9. package/dpr/components/_charts/chart/clientClass.js +1 -0
  10. package/dpr/components/_charts/chart/clientClass.js.map +2 -2
  11. package/dpr/components/_charts/chart/clientClass.ts +1 -0
  12. package/dpr/components/_reports/{report-actions → report-heading/report-actions}/actionsTemplate.js.map +1 -1
  13. package/dpr/components/_reports/{report-actions → report-heading/report-actions}/clientClass.js +1 -1
  14. package/dpr/components/_reports/report-heading/report-actions/clientClass.js.map +7 -0
  15. package/dpr/components/_reports/{report-actions → report-heading/report-actions}/clientClass.ts +1 -1
  16. package/dpr/components/_reports/report-heading/report-actions/types.d.js.map +7 -0
  17. package/dpr/components/_reports/{report-actions → report-heading/report-actions}/types.d.ts +1 -1
  18. package/dpr/components/_reports/{report-actions → report-heading/report-actions}/utils.js.map +1 -1
  19. package/dpr/components/_reports/{report-actions → report-heading/report-actions}/utils.test.ts +2 -2
  20. package/dpr/components/_reports/{report-columns-form → report-heading/report-columns/report-columns-form}/clientClass.js +1 -3
  21. package/dpr/components/_reports/report-heading/report-columns/report-columns-form/clientClass.js.map +7 -0
  22. package/dpr/components/_reports/{report-columns-form → report-heading/report-columns/report-columns-form}/clientClass.ts +1 -3
  23. package/dpr/components/_reports/{report-columns-form → report-heading/report-columns/report-columns-form}/types.d.js.map +1 -1
  24. package/dpr/components/_reports/{report-columns-form → report-heading/report-columns/report-columns-form}/utils.js +1 -1
  25. package/dpr/components/_reports/report-heading/report-columns/report-columns-form/utils.js.map +7 -0
  26. package/dpr/components/_reports/{report-columns-form → report-heading/report-columns/report-columns-form}/utils.ts +2 -2
  27. package/dpr/components/_reports/{report-columns → report-heading/report-columns}/view.njk +1 -1
  28. package/dpr/components/_reports/{report-download-message → report-heading/report-download-message}/clientClass.js +1 -1
  29. package/dpr/components/_reports/report-heading/report-download-message/clientClass.js.map +7 -0
  30. package/dpr/components/_reports/{report-download-message → report-heading/report-download-message}/clientClass.ts +1 -1
  31. package/dpr/components/_reports/{report-filters → report-heading/report-filters}/view.njk +1 -1
  32. package/dpr/components/_reports/report-heading/view.njk +4 -4
  33. package/dpr/components/_reports/report-page/report-print-message/view.njk +10 -0
  34. package/dpr/components/_reports/report-page/report-template/report-no-data-message/styles.scss +8 -0
  35. package/dpr/components/_reports/report-page/report-template/report-no-data-message/view.njk +11 -0
  36. package/dpr/components/_reports/{report-pagination → report-page/report-template/report-pagination}/clientClass.js +1 -1
  37. package/dpr/components/_reports/report-page/report-template/report-pagination/clientClass.js.map +7 -0
  38. package/dpr/components/_reports/{report-pagination → report-page/report-template/report-pagination}/clientClass.ts +1 -1
  39. package/dpr/components/_reports/{report-pagination → report-page/report-template/report-pagination}/types.d.js.map +1 -1
  40. package/dpr/components/_reports/{report-pagination → report-page/report-template/report-pagination}/utils.js.map +1 -1
  41. package/dpr/components/_reports/report-page/report-template/report-section/parent-child-template/styles.scss +88 -0
  42. package/dpr/components/_reports/report-page/report-template/report-section/parent-child-template/view.njk +29 -0
  43. package/dpr/components/_reports/{report-data-table → report-page/report-template/report-section/report-data-table}/clientClass.js +17 -10
  44. package/dpr/components/_reports/report-page/report-template/report-section/report-data-table/clientClass.js.map +7 -0
  45. package/dpr/components/_reports/{report-data-table → report-page/report-template/report-section/report-data-table}/clientClass.ts +20 -10
  46. package/dpr/components/_reports/{report-data-table → report-page/report-template/report-section/report-data-table}/style.scss +35 -185
  47. package/dpr/components/_reports/report-page/report-template/report-section/report-data-table/types.d.js.map +7 -0
  48. package/dpr/components/_reports/{report-data-table → report-page/report-template/report-section/report-data-table}/types.d.ts +2 -2
  49. package/dpr/components/_reports/report-page/report-template/report-section/report-data-table/view.njk +27 -0
  50. package/dpr/components/_reports/report-page/report-template/report-section/styles.scss +33 -0
  51. package/dpr/components/_reports/report-page/report-template/report-section/view.njk +58 -0
  52. package/dpr/components/_reports/{report-summary-table → report-page/report-template/report-summary-table}/styles.scss +21 -4
  53. package/dpr/components/_reports/{report-totals → report-page/report-template/report-totals}/utils.js.map +1 -1
  54. package/dpr/components/_reports/report-page/report-template/styles.scss +5 -0
  55. package/dpr/components/_reports/report-page/report-template/template-config.js +66 -0
  56. package/dpr/components/_reports/report-page/report-template/template-config.js.map +7 -0
  57. package/dpr/components/_reports/report-page/report-template/template-config.ts +45 -0
  58. package/dpr/components/_reports/report-page/report-template/utils.js +82 -0
  59. package/dpr/components/_reports/report-page/report-template/utils.js.map +7 -0
  60. package/dpr/components/_reports/report-page/report-template/utils.ts +100 -0
  61. package/dpr/components/_reports/report-page/report-template/view.njk +61 -0
  62. package/dpr/components/_reports/{report-wrapper → report-page}/styles.scss +7 -5
  63. package/dpr/components/_reports/report-page/view.njk +26 -0
  64. package/dpr/components/card-group/view.njk +0 -4
  65. package/dpr/components/report-list/utils.js +11 -3
  66. package/dpr/components/report-list/utils.js.map +2 -2
  67. package/dpr/components/report-list/utils.ts +11 -1
  68. package/dpr/components/report-list/view.njk +2 -2
  69. package/dpr/components/show-more/style.scss +3 -4
  70. package/dpr/data/reportingClient.js.map +2 -2
  71. package/dpr/data/reportingClient.ts +4 -4
  72. package/dpr/routes/journeys/view-report/async/dashboard/utils.js +1 -1
  73. package/dpr/routes/journeys/view-report/async/dashboard/utils.js.map +1 -1
  74. package/dpr/routes/journeys/view-report/async/dashboard/utils.ts +1 -1
  75. package/dpr/routes/journeys/view-report/async/report/controller.js.map +2 -2
  76. package/dpr/routes/journeys/view-report/async/report/controller.ts +0 -1
  77. package/dpr/routes/journeys/view-report/async/report/report-variants.cy.js +207 -56
  78. package/dpr/routes/journeys/view-report/async/report/report-variants.cy.js.map +2 -2
  79. package/dpr/routes/journeys/view-report/async/report/report-variants.cy.ts +333 -64
  80. package/dpr/routes/journeys/view-report/async/report/utils.js +9 -17
  81. package/dpr/routes/journeys/view-report/async/report/utils.js.map +3 -3
  82. package/dpr/routes/journeys/view-report/async/report/utils.ts +12 -22
  83. package/dpr/routes/journeys/view-report/report.njk +2 -2
  84. package/dpr/routes/journeys/view-report/sync/dashboard/utils.js +1 -1
  85. package/dpr/routes/journeys/view-report/sync/dashboard/utils.js.map +1 -1
  86. package/dpr/routes/journeys/view-report/sync/dashboard/utils.ts +1 -1
  87. package/dpr/routes/journeys/view-report/sync/report/utils.js +38 -11
  88. package/dpr/routes/journeys/view-report/sync/report/utils.js.map +3 -3
  89. package/dpr/routes/journeys/view-report/sync/report/utils.ts +39 -14
  90. package/dpr/routes/journeys/view-report/utils.js +1 -1
  91. package/dpr/routes/journeys/view-report/utils.js.map +1 -1
  92. package/dpr/routes/journeys/view-report/utils.ts +1 -1
  93. package/dpr/services/reportingService.js.map +2 -2
  94. package/dpr/services/reportingService.ts +2 -2
  95. package/dpr/types/ReportQuery.js +1 -1
  96. package/dpr/types/ReportQuery.js.map +1 -1
  97. package/dpr/types/ReportQuery.ts +1 -1
  98. package/dpr/types/UserReports.js.map +1 -1
  99. package/dpr/types/UserReports.ts +3 -3
  100. package/dpr/utils/TemplateBuilder/ParentChildDataBuilder/ParentChildDataBuilder.js +193 -0
  101. package/dpr/utils/TemplateBuilder/ParentChildDataBuilder/ParentChildDataBuilder.js.map +7 -0
  102. package/dpr/utils/TemplateBuilder/ParentChildDataBuilder/ParentChildDataBuilder.ts +203 -0
  103. package/dpr/utils/TemplateBuilder/ParentChildDataBuilder/types.d.js.map +7 -0
  104. package/dpr/utils/TemplateBuilder/ParentChildDataBuilder/types.d.ts +36 -0
  105. package/dpr/utils/TemplateBuilder/ReportBuilder/ReportBuilder.js +114 -0
  106. package/dpr/utils/TemplateBuilder/ReportBuilder/ReportBuilder.js.map +7 -0
  107. package/dpr/utils/TemplateBuilder/ReportBuilder/ReportBuilder.ts +117 -0
  108. package/dpr/utils/TemplateBuilder/ReportBuilder/types.d.js.map +7 -0
  109. package/dpr/utils/TemplateBuilder/ReportBuilder/types.d.ts +6 -0
  110. package/dpr/utils/TemplateBuilder/SectionedDataHelper/SectionedDataHelper.js +202 -0
  111. package/dpr/utils/TemplateBuilder/SectionedDataHelper/SectionedDataHelper.js.map +7 -0
  112. package/dpr/utils/TemplateBuilder/SectionedDataHelper/SectionedDataHelper.ts +246 -0
  113. package/dpr/utils/TemplateBuilder/SectionedDataHelper/types.js +17 -0
  114. package/dpr/utils/TemplateBuilder/SectionedDataHelper/types.js.map +7 -0
  115. package/dpr/utils/TemplateBuilder/SectionedDataHelper/types.ts +41 -0
  116. package/dpr/utils/{CollatedSummaryBuilder/CollatedSummaryBuilder.js → TemplateBuilder/SummaryDataHelper/SummaryDataHelper.js} +6 -8
  117. package/dpr/utils/TemplateBuilder/SummaryDataHelper/SummaryDataHelper.js.map +7 -0
  118. package/dpr/utils/{CollatedSummaryBuilder/CollatedSummaryBuilder.test.ts → TemplateBuilder/SummaryDataHelper/SummaryDataHelper.test.ts} +4 -4
  119. package/dpr/utils/{CollatedSummaryBuilder/CollatedSummaryBuilder.ts → TemplateBuilder/SummaryDataHelper/SummaryDataHelper.ts} +6 -9
  120. package/dpr/utils/TemplateBuilder/TemplateBuilder.js +74 -0
  121. package/dpr/utils/TemplateBuilder/TemplateBuilder.js.map +7 -0
  122. package/dpr/utils/TemplateBuilder/TemplateBuilder.ts +68 -0
  123. package/dpr/utils/definitionUtils.js +22 -2
  124. package/dpr/utils/definitionUtils.js.map +2 -2
  125. package/dpr/utils/definitionUtils.ts +26 -1
  126. package/package.json +1 -1
  127. package/dpr/DprLoadingHelper.js +0 -51
  128. package/dpr/DprLoadingHelper.js.map +0 -7
  129. package/dpr/DprLoadingHelper.ts +0 -27
  130. package/dpr/components/_reports/report/view.njk +0 -40
  131. package/dpr/components/_reports/report-actions/clientClass.js.map +0 -7
  132. package/dpr/components/_reports/report-actions/types.d.js.map +0 -7
  133. package/dpr/components/_reports/report-columns-form/clientClass.js.map +0 -7
  134. package/dpr/components/_reports/report-columns-form/utils.js.map +0 -7
  135. package/dpr/components/_reports/report-data-table/clientClass.js.map +0 -7
  136. package/dpr/components/_reports/report-data-table/types.d.js.map +0 -7
  137. package/dpr/components/_reports/report-data-table/utils.js +0 -123
  138. package/dpr/components/_reports/report-data-table/utils.js.map +0 -7
  139. package/dpr/components/_reports/report-data-table/utils.test.ts +0 -604
  140. package/dpr/components/_reports/report-data-table/utils.ts +0 -150
  141. package/dpr/components/_reports/report-data-table/view.njk +0 -24
  142. package/dpr/components/_reports/report-data-table-wrapper/view.njk +0 -27
  143. package/dpr/components/_reports/report-download-message/clientClass.js.map +0 -7
  144. package/dpr/components/_reports/report-no-data-message/styles.scss +0 -4
  145. package/dpr/components/_reports/report-no-data-message/view.njk +0 -13
  146. package/dpr/components/_reports/report-pagination/clientClass.js.map +0 -7
  147. package/dpr/components/_reports/report-print-message/view.njk +0 -8
  148. package/dpr/components/_reports/report-template/view.njk +0 -44
  149. package/dpr/components/_reports/report-wrapper/view.njk +0 -19
  150. package/dpr/components/loading-anim/styles.scss +0 -117
  151. package/dpr/components/loading-anim/view.njk +0 -18
  152. package/dpr/utils/CollatedSummaryBuilder/CollatedSummaryBuilder.js.map +0 -7
  153. package/dpr/utils/ParentChildDataTableBuilder/ParentChildDataTableBuilder.js +0 -202
  154. package/dpr/utils/ParentChildDataTableBuilder/ParentChildDataTableBuilder.js.map +0 -7
  155. package/dpr/utils/ParentChildDataTableBuilder/ParentChildDataTableBuilder.test.ts +0 -503
  156. package/dpr/utils/ParentChildDataTableBuilder/ParentChildDataTableBuilder.ts +0 -224
  157. package/dpr/utils/ParentChildDataTableBuilder/types.d.js.map +0 -7
  158. package/dpr/utils/ParentChildDataTableBuilder/types.d.ts +0 -11
  159. package/dpr/utils/SectionedDataTableBuilder/SectionedDataTableBuilder.js +0 -311
  160. package/dpr/utils/SectionedDataTableBuilder/SectionedDataTableBuilder.js.map +0 -7
  161. package/dpr/utils/SectionedDataTableBuilder/SectionedDataTableBuilder.test.ts +0 -492
  162. package/dpr/utils/SectionedDataTableBuilder/SectionedDataTableBuilder.ts +0 -342
  163. package/dpr/utils/SectionedDataTableBuilder/types.d.js.map +0 -7
  164. package/dpr/utils/SectionedDataTableBuilder/types.d.ts +0 -5
  165. package/dpr/utils/SectionedFieldsTableBuilder/SectionedFieldsTableBuilder.js +0 -146
  166. package/dpr/utils/SectionedFieldsTableBuilder/SectionedFieldsTableBuilder.js.map +0 -7
  167. package/dpr/utils/SectionedFieldsTableBuilder/SectionedFieldsTableBuilder.test.ts +0 -140
  168. package/dpr/utils/SectionedFieldsTableBuilder/SectionedFieldsTableBuilder.ts +0 -150
  169. /package/dpr/components/_reports/{report-actions → report-heading/report-actions}/actionsTemplate.js +0 -0
  170. /package/dpr/components/_reports/{report-actions → report-heading/report-actions}/actionsTemplate.ts +0 -0
  171. /package/dpr/components/_reports/{report-actions → report-heading/report-actions}/style.scss +0 -0
  172. /package/dpr/components/_reports/{report-actions → report-heading/report-actions}/types.d.js +0 -0
  173. /package/dpr/components/_reports/{report-actions → report-heading/report-actions}/utils.js +0 -0
  174. /package/dpr/components/_reports/{report-actions → report-heading/report-actions}/utils.ts +0 -0
  175. /package/dpr/components/_reports/{report-actions → report-heading/report-actions}/view.njk +0 -0
  176. /package/dpr/components/_reports/{report-columns-form → report-heading/report-columns/report-columns-form}/style.scss +0 -0
  177. /package/dpr/components/_reports/{report-columns-form → report-heading/report-columns/report-columns-form}/types.d.js +0 -0
  178. /package/dpr/components/_reports/{report-columns-form → report-heading/report-columns/report-columns-form}/types.d.ts +0 -0
  179. /package/dpr/components/_reports/{report-columns-form → report-heading/report-columns/report-columns-form}/view.njk +0 -0
  180. /package/dpr/components/_reports/{report-columns → report-heading/report-columns}/styles.scss +0 -0
  181. /package/dpr/components/_reports/{report-download-message → report-heading/report-download-message}/style.scss +0 -0
  182. /package/dpr/components/_reports/{report-download-message → report-heading/report-download-message}/view.njk +0 -0
  183. /package/dpr/components/_reports/{report-pagination → report-page/report-template/report-pagination}/style.scss +0 -0
  184. /package/dpr/components/_reports/{report-data-table → report-page/report-template/report-pagination}/types.d.js +0 -0
  185. /package/dpr/components/_reports/{report-pagination → report-page/report-template/report-pagination}/types.d.ts +0 -0
  186. /package/dpr/components/_reports/{report-pagination → report-page/report-template/report-pagination}/utils.js +0 -0
  187. /package/dpr/components/_reports/{report-pagination → report-page/report-template/report-pagination}/utils.test.ts +0 -0
  188. /package/dpr/components/_reports/{report-pagination → report-page/report-template/report-pagination}/utils.ts +0 -0
  189. /package/dpr/components/_reports/{report-pagination → report-page/report-template/report-pagination}/view.njk +0 -0
  190. /package/dpr/components/_reports/{report-pagination → report-page/report-template/report-section/report-data-table}/types.d.js +0 -0
  191. /package/dpr/components/_reports/{report-summary-table → report-page/report-template/report-summary-table}/view.njk +0 -0
  192. /package/dpr/components/_reports/{report-totals → report-page/report-template/report-totals}/style.scss +0 -0
  193. /package/dpr/components/_reports/{report-totals → report-page/report-template/report-totals}/utils.js +0 -0
  194. /package/dpr/components/_reports/{report-totals → report-page/report-template/report-totals}/utils.ts +0 -0
  195. /package/dpr/components/_reports/{report-totals → report-page/report-template/report-totals}/view.njk +0 -0
  196. /package/dpr/utils/{ParentChildDataTableBuilder → TemplateBuilder/ParentChildDataBuilder}/types.d.js +0 -0
  197. /package/dpr/utils/{SectionedDataTableBuilder → TemplateBuilder/ReportBuilder}/types.d.js +0 -0
@@ -1,150 +0,0 @@
1
- import { components } from '../../../types/api'
2
- import Dict = NodeJS.Dict
3
- import ReportQuery from '../../../types/ReportQuery'
4
- import { AsyncSummary } from '../../../types/UserReports'
5
- import CollatedSummaryBuilder from '../../../utils/CollatedSummaryBuilder/CollatedSummaryBuilder'
6
- import DataTableBuilder from '../../../utils/DataTableBuilder/DataTableBuilder'
7
- import { Columns } from '../report-columns-form/types'
8
- import { ChildData } from '../../../utils/ParentChildDataTableBuilder/types'
9
- import ParentChildDataTableBuilder from '../../../utils/ParentChildDataTableBuilder/ParentChildDataTableBuilder'
10
- import SectionedDataTableBuilder from '../../../utils/SectionedDataTableBuilder/SectionedDataTableBuilder'
11
- import SectionedFieldsDataTableBuilder from '../../../utils/SectionedFieldsTableBuilder/SectionedFieldsTableBuilder'
12
- import { DataTable } from '../../../utils/DataTableBuilder/types'
13
- import type { Template } from '../../../types/Templates'
14
-
15
- const validateDefinition = (definition: components['schemas']['SingleVariantReportDefinition']) => {
16
- const { variant } = definition
17
- const { specification } = variant
18
-
19
- if (!specification) {
20
- throw new Error('No specification in definition')
21
- }
22
-
23
- return { variant, specification }
24
- }
25
-
26
- const buildListTable = (
27
- definition: components['schemas']['SingleVariantReportDefinition'],
28
- columns: Columns,
29
- reportData: Dict<string>[],
30
- summariesData: AsyncSummary[],
31
- reportQuery: ReportQuery,
32
- ): DataTable => {
33
- const { variant, specification } = validateDefinition(definition)
34
- const { interactive } = variant
35
-
36
- const collatedSummaryBuilder = new CollatedSummaryBuilder(specification, summariesData)
37
- return new DataTableBuilder(specification.fields)
38
- .withSummaries(collatedSummaryBuilder.collateDataTableSummaries())
39
- .withHeaderOptions({
40
- columns: columns.value,
41
- reportQuery,
42
- interactive: Boolean(interactive),
43
- })
44
- .buildTable(reportData)
45
- }
46
-
47
- const buildParentChildTable = (
48
- definition: components['schemas']['SingleVariantReportDefinition'],
49
- columns: Columns,
50
- reportData: Dict<string>[],
51
- childData: ChildData[],
52
- ): DataTable => {
53
- return new ParentChildDataTableBuilder(definition.variant)
54
- .withNoHeaderOptions(columns.value)
55
- .withChildData(childData)
56
- .buildTable(reportData)
57
- }
58
-
59
- const buildSummarySectionTable = (
60
- definition: components['schemas']['SingleVariantReportDefinition'],
61
- columns: Columns,
62
- reportData: Dict<string>[],
63
- summariesData: AsyncSummary[],
64
- reportQuery: ReportQuery,
65
- ): DataTable => {
66
- const { variant, specification } = validateDefinition(definition)
67
- const { interactive } = variant
68
-
69
- const collatedSummaryBuilder = new CollatedSummaryBuilder(specification, summariesData)
70
- return new SectionedDataTableBuilder(specification)
71
- .withSummaries(collatedSummaryBuilder.collateDataTableSummaries())
72
- .withHeaderOptions({
73
- columns: columns.value,
74
- reportQuery,
75
- interactive: Boolean(interactive),
76
- })
77
- .buildTable(reportData)
78
- }
79
-
80
- const buildRowSectionedTable = (
81
- definition: components['schemas']['SingleVariantReportDefinition'],
82
- reportData: Dict<string>[],
83
- childData: ChildData[],
84
- ): DataTable[] => {
85
- const { variant } = definition
86
- const { interactive } = variant
87
-
88
- return reportData.map((rowData) => {
89
- return new SectionedFieldsDataTableBuilder(variant)
90
- .withHeaderOptions({
91
- columns: new Array(2),
92
- interactive: Boolean(interactive),
93
- })
94
- .withChildData(childData)
95
- .buildTable([rowData])
96
- })
97
- }
98
-
99
- export const createDataTable = (
100
- definition: components['schemas']['SingleVariantReportDefinition'],
101
- columns: Columns,
102
- reportData: Dict<string>[],
103
- childData: ChildData[],
104
- summariesData: AsyncSummary[],
105
- reportQuery: ReportQuery,
106
- ): DataTable[] => {
107
- let dataTables: DataTable[] = []
108
- const { specification } = validateDefinition(definition)
109
- const { template } = specification
110
-
111
- switch (template as Template) {
112
- case 'summary-section':
113
- case 'list-section': {
114
- const dataTable = buildSummarySectionTable(definition, columns, reportData, summariesData, reportQuery)
115
- dataTables.push(dataTable)
116
- break
117
- }
118
-
119
- case 'parent-child':
120
- case 'parent-child-section': {
121
- const dataTable = buildParentChildTable(definition, columns, reportData, childData)
122
- dataTables.push(dataTable)
123
- break
124
- }
125
-
126
- case 'list': {
127
- const dataTable = buildListTable(definition, columns, reportData, summariesData, reportQuery)
128
- dataTables.push(dataTable)
129
- break
130
- }
131
-
132
- case 'row-section-child':
133
- case 'row-section': {
134
- dataTables = buildRowSectionedTable(definition, reportData, childData)
135
- break
136
- }
137
-
138
- default: {
139
- const dataTable = buildListTable(definition, columns, reportData, summariesData, reportQuery)
140
- dataTables.push(dataTable)
141
- break
142
- }
143
- }
144
-
145
- return dataTables
146
- }
147
-
148
- export default {
149
- createDataTable,
150
- }
@@ -1,24 +0,0 @@
1
- {% from "govuk/components/table/macro.njk" import govukTable %}
2
-
3
- {% macro dprDataTable(dataTable, classification) %}
4
- {% set rows = dataTable.rows %}
5
- {% set head = dataTable.head %}
6
- {% set colCount = dataTable.colCount %}
7
-
8
- <div id="table-container" class='dpr-table-container' data-dpr-module="data-table" aria-labelledby="dpr-report-name">
9
- <div class="dpr-overflow-gradient" id="dpr-overflow-gradient"></div>
10
- <div class="dpr-table-wrapper" id="dpr-table-wrapper">
11
- <div class="dpr-table-content">
12
- {{ govukTable({
13
- head: head,
14
- rows: rows,
15
- attributes: {
16
- 'id': 'dpr-data-table',
17
- 'data-classification': classification,
18
- 'data-col-length': colCount
19
- }
20
- }) }}
21
- </div>
22
- </div>
23
- </div>
24
- {% endmacro %}
@@ -1,27 +0,0 @@
1
- {% from "../report-data-table/view.njk" import dprDataTable %}
2
- {% from "govuk/components/tabs/macro.njk" import govukTabs %}
3
-
4
- {% macro dprDataTableWrapper(dataTables, classification) %}
5
-
6
- {% if dataTables.length > 1 %}
7
- {% set tabItems = [] %}
8
- {% for dataTable in dataTables %}
9
-
10
- {% set dataTableHtml %}
11
- {{ dprDataTable(dataTable, classification) }}
12
- {% endset -%}
13
-
14
- {% set tabItems = (tabItems.push({
15
- label: "Report " + loop.index,
16
- id: "report_" + loop.index,
17
- panel: {
18
- html: dataTableHtml
19
- }
20
- }), tabItems) %}
21
- {% endfor %}
22
-
23
- {{ govukTabs({ items: tabItems}) }}
24
- {% else %}
25
- {{ dprDataTable(dataTables[0], classification) }}
26
- {% endif %}
27
- {% endmacro %}
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../dpr/components/_reports/report-download-message/clientClass.ts"],
4
- "sourcesContent": ["// @ts-nocheck\nimport { DprClientClass } from '../../../DprClientClass'\n\nclass DownloadMessage extends DprClientClass {\n static getModuleName() {\n return 'download-message'\n }\n\n initialise() {\n this.downloadMessage = this.getElement()\n if (window.location.href.indexOf('download-disabled') > -1) {\n this.downloadMessage.classList.remove('dpr-download-message--hidden')\n }\n }\n}\n\nexport { DownloadMessage }\nexport default DownloadMessage\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,4BAA+B;AAE/B,MAAM,wBAAwB,qCAAe;AAAA,EAC3C,OAAO,gBAAgB;AACrB,WAAO;AAAA,EACT;AAAA,EAEA,aAAa;AACX,SAAK,kBAAkB,KAAK,WAAW;AACvC,QAAI,OAAO,SAAS,KAAK,QAAQ,mBAAmB,IAAI,IAAI;AAC1D,WAAK,gBAAgB,UAAU,OAAO,8BAA8B;AAAA,IACtE;AAAA,EACF;AACF;AAGA,IAAO,sBAAQ;",
6
- "names": []
7
- }
@@ -1,4 +0,0 @@
1
- .report-no-data-available {
2
- text-align: left;
3
- margin-top: govuk-spacing(6);
4
- }
@@ -1,13 +0,0 @@
1
-
2
- {% from "govuk/components/button/macro.njk" import govukButton %}
3
-
4
- {% macro dprReportNoDataMessage(href) %}
5
- <div class="report-no-data-available">
6
- <div class="report-no-data-available">
7
- <p class="govuk-body-l govuk-!-margin-bottom-3"><strong>No data to display</strong></p>
8
- {% if href %}
9
- <a href={{ href }} class='govuk-link govuk-link--no-visited-state' >Make a new request</a>
10
- {% endif %}
11
- </div>
12
- </div>
13
- {% endmacro %}
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../../dpr/components/_reports/report-pagination/clientClass.ts"],
4
- "sourcesContent": ["// @ts-nocheck\nimport DprQueryParamClass from '../../../DprQueryParamClass'\n\nclass Pagination extends DprQueryParamClass {\n static getModuleName() {\n return 'pagination'\n }\n\n initialise() {\n this.pageSizeSelect = document.getElementById('page-size-select')\n\n this.initInputsFromQueryParams()\n this.initSelectEvent()\n }\n\n initSelectEvent() {\n this.pageSizeSelect.addEventListener('change', () => {\n this.queryParams = new URLSearchParams(window.location.search)\n const { name, value } = this.pageSizeSelect\n this.queryParams.set(name, value)\n this.queryParams.set('selectedPage', '1')\n window.history.replaceState(null, null, `?${this.queryParams.toString()}`)\n window.location.reload()\n })\n }\n}\n\nexport { Pagination }\nexport default Pagination\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AACA,gCAA+B;AAE/B,MAAM,mBAAmB,0BAAAA,QAAmB;AAAA,EAC1C,OAAO,gBAAgB;AACrB,WAAO;AAAA,EACT;AAAA,EAEA,aAAa;AACX,SAAK,iBAAiB,SAAS,eAAe,kBAAkB;AAEhE,SAAK,0BAA0B;AAC/B,SAAK,gBAAgB;AAAA,EACvB;AAAA,EAEA,kBAAkB;AAChB,SAAK,eAAe,iBAAiB,UAAU,MAAM;AACnD,WAAK,cAAc,IAAI,gBAAgB,OAAO,SAAS,MAAM;AAC7D,YAAM,EAAE,MAAM,MAAM,IAAI,KAAK;AAC7B,WAAK,YAAY,IAAI,MAAM,KAAK;AAChC,WAAK,YAAY,IAAI,gBAAgB,GAAG;AACxC,aAAO,QAAQ,aAAa,MAAM,MAAM,IAAI,KAAK,YAAY,SAAS,CAAC,EAAE;AACzE,aAAO,SAAS,OAAO;AAAA,IACzB,CAAC;AAAA,EACH;AACF;AAGA,IAAO,sBAAQ;",
6
- "names": ["DprQueryParamClass"]
7
- }
@@ -1,8 +0,0 @@
1
- {% from "govuk/components/button/macro.njk" import govukButton %}
2
-
3
- {% macro dprReportPrintMessage() %}
4
- <h3 class="govuk-heading-s screen-hide">
5
- Printing this report has been disabled due to time or content sensitivity.<br/>
6
- Please speak to your report administrator for further details.
7
- </h3>
8
- {% endmacro %}
@@ -1,44 +0,0 @@
1
-
2
- {% from "../report-pagination/view.njk" import dprReportPagination %}
3
- {% from "../report/view.njk" import dprReport %}
4
- {% from "../report-summary-table/view.njk" import dprReportSummary %}
5
- {% from "../report-no-data-message/view.njk" import dprReportNoDataMessage %}
6
-
7
- {% macro dprReportTemplate(renderData) %}
8
-
9
- {% set printable = renderData.printable %}
10
- {% set pagination = renderData.pagination %}
11
- {% set template = renderData.template %}
12
- {% set reportSummaries = renderData.reportSummaries %}
13
- {% set count = renderData.count %}
14
-
15
- <div class="report-template-container {% if (printable == false) %}print-hide{% endif %}">
16
- {% if template === 'list-tab' %}
17
-
18
- {# Add template view here #}
19
-
20
- {% elif template === 'list-section' or template === 'summary-section' or template === 'parent-child' or template === 'parent-child-section' or template === 'row-section' or template === 'row-section-child' %}
21
-
22
- {{ dprReport(renderData, count, template) }}
23
-
24
- {% elif template === 'summary' %}
25
-
26
- {% if not count or count === 0 %}
27
- {{ dprReportNoDataMessage(renderData.requestUrl.fullUrl) }}
28
- {% else %}
29
- {{ dprReportSummary(reportSummaries, 'page-header') }}
30
- {{ dprReportSummary(reportSummaries, 'page-footer') }}
31
- {% endif %}
32
-
33
- {% else %}
34
-
35
- {{ dprReport(renderData, count, template) }}
36
-
37
- {% if count and count > 0 %}
38
- {{ dprReportPagination(pagination) }}
39
- {% endif %}
40
-
41
- {% endif %}
42
- </div>
43
-
44
- {% endmacro %}
@@ -1,19 +0,0 @@
1
- {% from "../report-heading/view.njk" import dprReportHeading %}
2
- {% from "../report-print-message/view.njk" import dprReportPrintMessage %}
3
- {% from "../report-print-message/view.njk" import dprReportPrintMessage %}
4
- {% from "../report-template/view.njk" import dprReportTemplate %}
5
-
6
- {% macro dprReportWrapper(renderData) %}
7
- {% set printable = renderData.printable %}
8
- <div class="govuk-width-container">
9
- <div class="govuk-width-container report-list-container">
10
- {% if (printable == false) %}
11
- {{ dprReportPrintMessage() }}
12
- {% endif %}
13
- <div class="dpr-reports-heading-container">
14
- {{ dprReportHeading(renderData) }}
15
- </div>
16
- {{ dprReportTemplate(renderData)}}
17
- </div>
18
- </div>
19
- {% endmacro %}
@@ -1,117 +0,0 @@
1
- .dpr-loading-panel {
2
- display: none;
3
- width: 100%;
4
- height: 100%;
5
- position: absolute;
6
- top: 0;
7
- left: 0;
8
- z-index: 2;
9
- justify-content: center;
10
- align-items: center;
11
- background-color: rgba(255, 255, 255, 0.8);
12
-
13
- &.show {
14
- display: flex;
15
- }
16
- }
17
-
18
- .dpr-loading-anim {
19
- display: none;
20
-
21
- &.show {
22
- display: inline-block;
23
- position: relative;
24
- width: 80px;
25
- height: 80px;
26
- }
27
-
28
- &.show div {
29
- position: absolute;
30
- width: 6px;
31
- height: 6px;
32
- background: govuk-colour("light-blue");
33
- border-radius: 50%;
34
- animation: dpr-loading-anim 1.2s linear infinite;
35
- }
36
-
37
- &.show div:nth-child(1) {
38
- animation-delay: 0s;
39
- top: 37px;
40
- left: 66px;
41
- }
42
-
43
- &.show div:nth-child(2) {
44
- animation-delay: -0.1s;
45
- top: 22px;
46
- left: 62px;
47
- }
48
-
49
- &.show div:nth-child(3) {
50
- animation-delay: -0.2s;
51
- top: 11px;
52
- left: 52px;
53
- }
54
-
55
- &.show div:nth-child(4) {
56
- animation-delay: -0.3s;
57
- top: 7px;
58
- left: 37px;
59
- }
60
-
61
- &.show div:nth-child(5) {
62
- animation-delay: -0.4s;
63
- top: 11px;
64
- left: 22px;
65
- }
66
-
67
- &.show div:nth-child(6) {
68
- animation-delay: -0.5s;
69
- top: 22px;
70
- left: 11px;
71
- }
72
-
73
- &.show div:nth-child(7) {
74
- animation-delay: -0.6s;
75
- top: 37px;
76
- left: 7px;
77
- }
78
-
79
- &.show div:nth-child(8) {
80
- animation-delay: -0.7s;
81
- top: 52px;
82
- left: 11px;
83
- }
84
-
85
- &.show div:nth-child(9) {
86
- animation-delay: -0.8s;
87
- top: 62px;
88
- left: 22px;
89
- }
90
-
91
- &.show div:nth-child(10) {
92
- animation-delay: -0.9s;
93
- top: 66px;
94
- left: 37px;
95
- }
96
-
97
- &.show div:nth-child(11) {
98
- animation-delay: -1s;
99
- top: 62px;
100
- left: 52px;
101
- }
102
-
103
- &.show div:nth-child(12) {
104
- animation-delay: -1.1s;
105
- top: 52px;
106
- left: 62px;
107
- }
108
- }
109
-
110
- @keyframes dpr-loading-anim {
111
- 0%, 20%, 80%, 100% {
112
- transform: scale(1);
113
- }
114
- 50% {
115
- transform: scale(1.5);
116
- }
117
- }
@@ -1,18 +0,0 @@
1
- {% macro dprLoadingAnim() %}
2
- <div class="dpr-loading-panel">
3
- <div class="dpr-loading-anim">
4
- <div></div>
5
- <div></div>
6
- <div></div>
7
- <div></div>
8
- <div></div>
9
- <div></div>
10
- <div></div>
11
- <div></div>
12
- <div></div>
13
- <div></div>
14
- <div></div>
15
- <div></div>
16
- </div>
17
- </div>
18
- {% endmacro %}
@@ -1,7 +0,0 @@
1
- {
2
- "version": 3,
3
- "sources": ["../../../dpr/utils/CollatedSummaryBuilder/CollatedSummaryBuilder.ts"],
4
- "sourcesContent": ["import Dict = NodeJS.Dict\nimport { AsyncSummary } from '../../types/UserReports'\nimport { SummaryTemplate } from '../../types/Templates'\nimport { components } from '../../types/api'\nimport { DataTable } from '../DataTableBuilder/types'\nimport SummaryDataTableBuilder from '../SummaryDataTableBuilder/SummaryDataTableBuilder'\n\nclass CollatedSummaryBuilder {\n private summaries: Array<AsyncSummary>\n\n private specification: components['schemas']['Specification']\n\n constructor(specification: components['schemas']['Specification'], summaries: Array<AsyncSummary>) {\n this.specification = specification\n this.summaries = summaries\n }\n\n pageSummaryTemplates: Array<SummaryTemplate> = ['page-header', 'page-footer']\n\n dataTableSummaryTemplates: Array<SummaryTemplate> = [\n 'section-footer',\n 'section-header',\n 'table-footer',\n 'table-header',\n ]\n\n collatePageSummaries(): Dict<Array<DataTable>> {\n return this.collateAndMapToDataTable(this.pageSummaryTemplates)\n }\n\n collateDataTableSummaries(): Dict<Array<AsyncSummary>> {\n return this.collate(this.dataTableSummaryTemplates)\n }\n\n collateAndMapToDataTable(summaryTemplates: Array<SummaryTemplate> = []): Dict<Array<DataTable>> {\n const collatedSummaries = this.collate(summaryTemplates)\n\n return this.mapToDataTables(collatedSummaries)\n }\n\n collate(summaryTemplates: Array<SummaryTemplate> = this.pageSummaryTemplates): Dict<Array<AsyncSummary>> {\n const collatedSummaries: Dict<Array<AsyncSummary>> = {}\n if (this.summaries) {\n this.summaries.forEach((summary: AsyncSummary) => {\n const { template } = summary\n if (summaryTemplates.includes(template)) {\n if (!collatedSummaries[template]) {\n collatedSummaries[template] = []\n }\n collatedSummaries[template].push(summary)\n }\n })\n }\n\n return collatedSummaries\n }\n\n private mapToDataTables(summaries: Dict<Array<AsyncSummary>>): Dict<Array<DataTable>> {\n const dataTables: Dict<Array<DataTable>> = {}\n\n Object.keys(summaries).forEach((summaryType) => {\n if (summaries[summaryType]) {\n dataTables[summaryType] = summaries[summaryType].map((summary) => {\n return new SummaryDataTableBuilder(summary, this.specification.sections).buildSummaryTable()\n })\n }\n })\n\n return dataTables\n }\n}\n\nexport { CollatedSummaryBuilder }\nexport default CollatedSummaryBuilder\n"],
5
- "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAKA,qCAAoC;AAEpC,MAAM,uBAAuB;AAAA,EACnB;AAAA,EAEA;AAAA,EAER,YAAY,eAAuD,WAAgC;AACjG,SAAK,gBAAgB;AACrB,SAAK,YAAY;AAAA,EACnB;AAAA,EAEA,uBAA+C,CAAC,eAAe,aAAa;AAAA,EAE5E,4BAAoD;AAAA,IAClD;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACF;AAAA,EAEA,uBAA+C;AAC7C,WAAO,KAAK,yBAAyB,KAAK,oBAAoB;AAAA,EAChE;AAAA,EAEA,4BAAuD;AACrD,WAAO,KAAK,QAAQ,KAAK,yBAAyB;AAAA,EACpD;AAAA,EAEA,yBAAyB,mBAA2C,CAAC,GAA2B;AAC9F,UAAM,oBAAoB,KAAK,QAAQ,gBAAgB;AAEvD,WAAO,KAAK,gBAAgB,iBAAiB;AAAA,EAC/C;AAAA,EAEA,QAAQ,mBAA2C,KAAK,sBAAiD;AACvG,UAAM,oBAA+C,CAAC;AACtD,QAAI,KAAK,WAAW;AAClB,WAAK,UAAU,QAAQ,CAAC,YAA0B;AAChD,cAAM,EAAE,SAAS,IAAI;AACrB,YAAI,iBAAiB,SAAS,QAAQ,GAAG;AACvC,cAAI,CAAC,kBAAkB,QAAQ,GAAG;AAChC,8BAAkB,QAAQ,IAAI,CAAC;AAAA,UACjC;AACA,4BAAkB,QAAQ,EAAE,KAAK,OAAO;AAAA,QAC1C;AAAA,MACF,CAAC;AAAA,IACH;AAEA,WAAO;AAAA,EACT;AAAA,EAEQ,gBAAgB,WAA8D;AACpF,UAAM,aAAqC,CAAC;AAE5C,WAAO,KAAK,SAAS,EAAE,QAAQ,CAAC,gBAAgB;AAC9C,UAAI,UAAU,WAAW,GAAG;AAC1B,mBAAW,WAAW,IAAI,UAAU,WAAW,EAAE,IAAI,CAAC,YAAY;AAChE,iBAAO,IAAI,+BAAAA,QAAwB,SAAS,KAAK,cAAc,QAAQ,EAAE,kBAAkB;AAAA,QAC7F,CAAC;AAAA,MACH;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AACF;AAGA,IAAO,iCAAQ;",
6
- "names": ["SummaryDataTableBuilder"]
7
- }
@@ -1,202 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var ParentChildDataTableBuilder_exports = {};
30
- __export(ParentChildDataTableBuilder_exports, {
31
- ParentChildDataTableBuilder: () => ParentChildDataTableBuilder,
32
- default: () => ParentChildDataTableBuilder_default
33
- });
34
- module.exports = __toCommonJS(ParentChildDataTableBuilder_exports);
35
- var import_DataTableBuilder = __toESM(require("../DataTableBuilder/DataTableBuilder"));
36
- var import_arrayUtils = require("../arrayUtils");
37
- var import_SectionedDataTableBuilder = __toESM(require("../SectionedDataTableBuilder/SectionedDataTableBuilder"));
38
- class ParentChildDataTableBuilder extends import_SectionedDataTableBuilder.default {
39
- variant;
40
- childVariants;
41
- childData = [];
42
- constructor(variant) {
43
- const { specification } = variant;
44
- const { sections, template } = specification;
45
- super(specification);
46
- this.sections = sections;
47
- this.template = template;
48
- this.variant = variant;
49
- this.childVariants = this.variant.childVariants || [];
50
- }
51
- createParentChildTable(parentData, header) {
52
- let sectionedParentChildData = {};
53
- const joinFields = this.mapNamesToFields(this.childVariants.flatMap((c) => c.joinFields).reduce(import_arrayUtils.distinct, []));
54
- const parentChildKeys = this.calculateParentChildKeys(parentData, joinFields);
55
- parentChildKeys.forEach((parentKey) => {
56
- sectionedParentChildData[parentKey.sortKey] = {
57
- parent: []
58
- };
59
- });
60
- sectionedParentChildData = this.splitParentDataIntoSections(sectionedParentChildData, parentData, joinFields);
61
- sectionedParentChildData = this.splitChildDataIntoSections(parentChildKeys, sectionedParentChildData);
62
- const childDataTableBuilders = this.createChildDataTableBuilders();
63
- const parentChildTable = parentChildKeys.flatMap((key) => {
64
- const sectionData = sectionedParentChildData[key.sortKey] || {};
65
- let parentSectionData = [];
66
- if (sectionData) {
67
- parentSectionData = sectionData["parent"] ? sectionData["parent"] : [];
68
- }
69
- return [header].concat(parentSectionData.map((r) => this.mapRow(r, "dpr-parent-cell"))).concat(
70
- this.childVariants.filter((childVariant) => sectionData && sectionData[childVariant.id]).map((childVariant) => {
71
- const builder = childDataTableBuilders[childVariant.id];
72
- const section = sectionData[childVariant.id];
73
- const dataTable = builder && section ? builder.buildTable(section) : void 0;
74
- const dataTableHtml = dataTable ? this.convertDataTableToHtml(dataTable) : "";
75
- return [
76
- {
77
- classes: "dpr-child-report-cell",
78
- format: "string",
79
- html: `<div class='dpr-child-report'><h2 class="govuk-heading-s">${childVariant.name}</h2><div class="dpr-child-report_table">${dataTableHtml}</div></div>`,
80
- colspan: this.columns.length
81
- }
82
- ];
83
- })
84
- );
85
- });
86
- return parentChildTable;
87
- }
88
- createParentChildSectionRows(parentData, header) {
89
- const sectionsDetails = this.mapSections(parentData);
90
- const sectionedData = sectionsDetails.sectionedData;
91
- const sectionedParentChildSectionedRows = [];
92
- Object.keys(sectionedData).forEach((sectionDescription) => {
93
- const data = sectionedData[sectionDescription];
94
- sectionedParentChildSectionedRows.push({
95
- sectionDescription,
96
- ...this.getSectionCount(sectionedData, sectionDescription),
97
- rows: this.createParentChildTable(data, header)
98
- });
99
- });
100
- const rows = sectionedParentChildSectionedRows.flatMap((section, index) => {
101
- const sectionHeader = this.createSectionHeader(
102
- section.sectionDescription,
103
- index,
104
- section.count,
105
- section.countDescription
106
- );
107
- return [...sectionHeader, ...section.rows];
108
- });
109
- return rows;
110
- }
111
- mapParentChildData(parentData, header) {
112
- if (this.sections?.length) {
113
- return this.createParentChildSectionRows(parentData, header);
114
- }
115
- return this.createParentChildTable(parentData, header);
116
- }
117
- createChildDataTableBuilders() {
118
- const childDataTables = this.childVariants.reduce((previousValue, childVariant) => {
119
- const { specification } = childVariant;
120
- const fields = specification ? specification.fields : [];
121
- const fieldNamesToDisplay = fields.filter((f) => f.visible || f.mandatory).map((f) => f.name);
122
- const dataTableBuilder = new import_DataTableBuilder.default(fields).withNoHeaderOptions(fieldNamesToDisplay).withSortedData();
123
- return {
124
- ...previousValue,
125
- [childVariant.id]: dataTableBuilder
126
- };
127
- }, {});
128
- return childDataTables;
129
- }
130
- calculateParentChildKeys(parentData, joinFields) {
131
- return parentData.map(
132
- (rowData) => ({
133
- sortKey: this.getSortKey(rowData, joinFields),
134
- childSortKeys: this.childVariants.reduce((previousValue, childVariant) => {
135
- return {
136
- ...previousValue,
137
- [childVariant.id]: this.getSortKey(rowData, this.mapNamesToFields(childVariant.joinFields))
138
- };
139
- }, {})
140
- })
141
- ).reduce((previousValue, sortKey) => {
142
- if (previousValue.find((v) => v.sortKey === sortKey.sortKey)) {
143
- return previousValue;
144
- }
145
- return previousValue.concat(sortKey);
146
- }, []);
147
- }
148
- splitParentDataIntoSections(sectionedParentChildData, parentData, joinFields) {
149
- return parentData.reduce((previousValue, rowData) => {
150
- const parentKey = this.getSortKey(rowData, joinFields);
151
- const previousParentValue = previousValue[parentKey] ? previousValue[parentKey]["parent"] : [];
152
- return {
153
- ...previousValue,
154
- ...previousParentValue && {
155
- [parentKey]: {
156
- parent: previousParentValue.concat(rowData)
157
- }
158
- }
159
- };
160
- }, sectionedParentChildData);
161
- }
162
- splitChildDataIntoSections(parentKeys, sectionedParentChildData) {
163
- const sectionedParentChildDataWithChildren = { ...sectionedParentChildData };
164
- this.childVariants.forEach((childVariant) => {
165
- const childFields = this.mapNamesToFields(childVariant.joinFields);
166
- const matchingChildData = this.childData.find((d) => d.id === childVariant.id);
167
- const data = matchingChildData ? matchingChildData.data : [];
168
- data.filter((rowData) => {
169
- const sortKey = this.getSortKey(rowData, childFields);
170
- return parentKeys.find((p) => p.childSortKeys[childVariant.id] === sortKey);
171
- }).forEach((rowData) => {
172
- const sortKey = this.getSortKey(rowData, childFields);
173
- const parent = parentKeys.find((p) => p.childSortKeys[childVariant.id] === sortKey);
174
- const parentSortKey = parent ? parent.sortKey : "";
175
- const parentSection = sectionedParentChildDataWithChildren[parentSortKey];
176
- if (parentSection) {
177
- const existingChildData = parentSection[childVariant.id] || [];
178
- parentSection[childVariant.id] = existingChildData.concat(rowData);
179
- }
180
- });
181
- });
182
- return sectionedParentChildDataWithChildren;
183
- }
184
- withChildData(childData) {
185
- this.childData = childData;
186
- return this;
187
- }
188
- buildTable(data) {
189
- return {
190
- head: null,
191
- rows: this.mapParentChildData(data, this.mapHeader(true, "govuk-table__header")),
192
- rowCount: data.length,
193
- colCount: this.columns.length
194
- };
195
- }
196
- }
197
- var ParentChildDataTableBuilder_default = ParentChildDataTableBuilder;
198
- // Annotate the CommonJS export names for ESM import in node:
199
- 0 && (module.exports = {
200
- ParentChildDataTableBuilder
201
- });
202
- //# sourceMappingURL=ParentChildDataTableBuilder.js.map