@ministryofjustice/hmpps-digital-prison-reporting-frontend 4.28.7 → 4.29.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.
- package/dpr/all.js +6 -8
- package/dpr/all.js.map +3 -3
- package/dpr/all.scss +296 -414
- package/dpr/all.ts +6 -11
- package/dpr/components/_catalogue/catalogue-list/utils.test.ts +1 -1
- package/dpr/components/_charts/chart/clientClass.js +1 -0
- package/dpr/components/_charts/chart/clientClass.js.map +2 -2
- package/dpr/components/_charts/chart/clientClass.ts +1 -0
- package/dpr/components/_reports/{report-actions → report-heading/report-actions}/actionsTemplate.js.map +1 -1
- package/dpr/components/_reports/{report-actions → report-heading/report-actions}/clientClass.js +1 -1
- package/dpr/components/_reports/report-heading/report-actions/clientClass.js.map +7 -0
- package/dpr/components/_reports/{report-actions → report-heading/report-actions}/clientClass.ts +1 -1
- package/dpr/components/_reports/report-heading/report-actions/types.d.js.map +7 -0
- package/dpr/components/_reports/{report-actions → report-heading/report-actions}/types.d.ts +1 -1
- package/dpr/components/_reports/{report-actions → report-heading/report-actions}/utils.js.map +1 -1
- package/dpr/components/_reports/{report-actions → report-heading/report-actions}/utils.test.ts +2 -2
- package/dpr/components/_reports/{report-columns-form → report-heading/report-columns/report-columns-form}/clientClass.js +1 -3
- package/dpr/components/_reports/report-heading/report-columns/report-columns-form/clientClass.js.map +7 -0
- package/dpr/components/_reports/{report-columns-form → report-heading/report-columns/report-columns-form}/clientClass.ts +1 -3
- package/dpr/components/_reports/{report-columns-form → report-heading/report-columns/report-columns-form}/types.d.js.map +1 -1
- package/dpr/components/_reports/{report-columns-form → report-heading/report-columns/report-columns-form}/utils.js +1 -1
- package/dpr/components/_reports/report-heading/report-columns/report-columns-form/utils.js.map +7 -0
- package/dpr/components/_reports/{report-columns-form → report-heading/report-columns/report-columns-form}/utils.ts +2 -2
- package/dpr/components/_reports/{report-columns → report-heading/report-columns}/view.njk +1 -1
- package/dpr/components/_reports/{report-download-message → report-heading/report-download-message}/clientClass.js +1 -1
- package/dpr/components/_reports/report-heading/report-download-message/clientClass.js.map +7 -0
- package/dpr/components/_reports/{report-download-message → report-heading/report-download-message}/clientClass.ts +1 -1
- package/dpr/components/_reports/{report-filters → report-heading/report-filters}/view.njk +1 -1
- package/dpr/components/_reports/report-heading/view.njk +4 -4
- package/dpr/components/_reports/report-page/report-print-message/view.njk +10 -0
- package/dpr/components/_reports/report-page/report-template/report-no-data-message/styles.scss +8 -0
- package/dpr/components/_reports/report-page/report-template/report-no-data-message/view.njk +11 -0
- package/dpr/components/_reports/{report-pagination → report-page/report-template/report-pagination}/clientClass.js +1 -1
- package/dpr/components/_reports/report-page/report-template/report-pagination/clientClass.js.map +7 -0
- package/dpr/components/_reports/{report-pagination → report-page/report-template/report-pagination}/clientClass.ts +1 -1
- package/dpr/components/_reports/{report-pagination → report-page/report-template/report-pagination}/types.d.js.map +1 -1
- package/dpr/components/_reports/{report-pagination → report-page/report-template/report-pagination}/utils.js.map +1 -1
- package/dpr/components/_reports/report-page/report-template/report-section/parent-child-template/styles.scss +88 -0
- package/dpr/components/_reports/report-page/report-template/report-section/parent-child-template/view.njk +29 -0
- package/dpr/components/_reports/{report-data-table → report-page/report-template/report-section/report-data-table}/clientClass.js +17 -10
- package/dpr/components/_reports/report-page/report-template/report-section/report-data-table/clientClass.js.map +7 -0
- package/dpr/components/_reports/{report-data-table → report-page/report-template/report-section/report-data-table}/clientClass.ts +20 -10
- package/dpr/components/_reports/{report-data-table → report-page/report-template/report-section/report-data-table}/style.scss +35 -185
- package/dpr/components/_reports/report-page/report-template/report-section/report-data-table/types.d.js.map +7 -0
- package/dpr/components/_reports/{report-data-table → report-page/report-template/report-section/report-data-table}/types.d.ts +2 -2
- package/dpr/components/_reports/report-page/report-template/report-section/report-data-table/view.njk +27 -0
- package/dpr/components/_reports/report-page/report-template/report-section/styles.scss +33 -0
- package/dpr/components/_reports/report-page/report-template/report-section/view.njk +58 -0
- package/dpr/components/_reports/{report-summary-table → report-page/report-template/report-summary-table}/styles.scss +21 -4
- package/dpr/components/_reports/{report-totals → report-page/report-template/report-totals}/utils.js.map +1 -1
- package/dpr/components/_reports/report-page/report-template/styles.scss +5 -0
- package/dpr/components/_reports/report-page/report-template/template-config.js +66 -0
- package/dpr/components/_reports/report-page/report-template/template-config.js.map +7 -0
- package/dpr/components/_reports/report-page/report-template/template-config.ts +45 -0
- package/dpr/components/_reports/report-page/report-template/utils.js +82 -0
- package/dpr/components/_reports/report-page/report-template/utils.js.map +7 -0
- package/dpr/components/_reports/report-page/report-template/utils.ts +100 -0
- package/dpr/components/_reports/report-page/report-template/view.njk +61 -0
- package/dpr/components/_reports/{report-wrapper → report-page}/styles.scss +7 -5
- package/dpr/components/_reports/report-page/view.njk +26 -0
- package/dpr/components/card-group/view.njk +0 -4
- package/dpr/components/report-list/utils.js +11 -3
- package/dpr/components/report-list/utils.js.map +2 -2
- package/dpr/components/report-list/utils.ts +11 -1
- package/dpr/components/report-list/view.njk +2 -2
- package/dpr/components/show-more/style.scss +3 -4
- package/dpr/data/reportingClient.js.map +2 -2
- package/dpr/data/reportingClient.ts +4 -4
- package/dpr/routes/journeys/view-report/async/dashboard/utils.js +1 -1
- package/dpr/routes/journeys/view-report/async/dashboard/utils.js.map +1 -1
- package/dpr/routes/journeys/view-report/async/dashboard/utils.ts +1 -1
- package/dpr/routes/journeys/view-report/async/report/controller.js.map +2 -2
- package/dpr/routes/journeys/view-report/async/report/controller.ts +0 -1
- package/dpr/routes/journeys/view-report/async/report/report-variants.cy.js +207 -56
- package/dpr/routes/journeys/view-report/async/report/report-variants.cy.js.map +2 -2
- package/dpr/routes/journeys/view-report/async/report/report-variants.cy.ts +333 -64
- package/dpr/routes/journeys/view-report/async/report/utils.js +9 -17
- package/dpr/routes/journeys/view-report/async/report/utils.js.map +3 -3
- package/dpr/routes/journeys/view-report/async/report/utils.ts +12 -22
- package/dpr/routes/journeys/view-report/report.njk +2 -2
- package/dpr/routes/journeys/view-report/sync/dashboard/utils.js +2 -2
- package/dpr/routes/journeys/view-report/sync/dashboard/utils.js.map +1 -1
- package/dpr/routes/journeys/view-report/sync/dashboard/utils.ts +2 -2
- package/dpr/routes/journeys/view-report/sync/report/utils.js +38 -11
- package/dpr/routes/journeys/view-report/sync/report/utils.js.map +3 -3
- package/dpr/routes/journeys/view-report/sync/report/utils.ts +39 -14
- package/dpr/routes/journeys/view-report/utils.js +1 -1
- package/dpr/routes/journeys/view-report/utils.js.map +1 -1
- package/dpr/routes/journeys/view-report/utils.ts +1 -1
- package/dpr/services/reportingService.js.map +2 -2
- package/dpr/services/reportingService.ts +2 -2
- package/dpr/types/ReportQuery.js +1 -1
- package/dpr/types/ReportQuery.js.map +1 -1
- package/dpr/types/ReportQuery.ts +1 -1
- package/dpr/types/UserReports.js.map +1 -1
- package/dpr/types/UserReports.ts +3 -3
- package/dpr/utils/TemplateBuilder/ParentChildDataBuilder/ParentChildDataBuilder.js +193 -0
- package/dpr/utils/TemplateBuilder/ParentChildDataBuilder/ParentChildDataBuilder.js.map +7 -0
- package/dpr/utils/TemplateBuilder/ParentChildDataBuilder/ParentChildDataBuilder.ts +203 -0
- package/dpr/utils/TemplateBuilder/ParentChildDataBuilder/types.d.js.map +7 -0
- package/dpr/utils/TemplateBuilder/ParentChildDataBuilder/types.d.ts +36 -0
- package/dpr/utils/TemplateBuilder/ReportBuilder/ReportBuilder.js +114 -0
- package/dpr/utils/TemplateBuilder/ReportBuilder/ReportBuilder.js.map +7 -0
- package/dpr/utils/TemplateBuilder/ReportBuilder/ReportBuilder.ts +117 -0
- package/dpr/utils/TemplateBuilder/ReportBuilder/types.d.js.map +7 -0
- package/dpr/utils/TemplateBuilder/ReportBuilder/types.d.ts +6 -0
- package/dpr/utils/TemplateBuilder/SectionedDataHelper/SectionedDataHelper.js +202 -0
- package/dpr/utils/TemplateBuilder/SectionedDataHelper/SectionedDataHelper.js.map +7 -0
- package/dpr/utils/TemplateBuilder/SectionedDataHelper/SectionedDataHelper.ts +246 -0
- package/dpr/utils/TemplateBuilder/SectionedDataHelper/types.js +17 -0
- package/dpr/utils/TemplateBuilder/SectionedDataHelper/types.js.map +7 -0
- package/dpr/utils/TemplateBuilder/SectionedDataHelper/types.ts +41 -0
- package/dpr/utils/{CollatedSummaryBuilder/CollatedSummaryBuilder.js → TemplateBuilder/SummaryDataHelper/SummaryDataHelper.js} +6 -8
- package/dpr/utils/TemplateBuilder/SummaryDataHelper/SummaryDataHelper.js.map +7 -0
- package/dpr/utils/{CollatedSummaryBuilder/CollatedSummaryBuilder.test.ts → TemplateBuilder/SummaryDataHelper/SummaryDataHelper.test.ts} +4 -4
- package/dpr/utils/{CollatedSummaryBuilder/CollatedSummaryBuilder.ts → TemplateBuilder/SummaryDataHelper/SummaryDataHelper.ts} +6 -9
- package/dpr/utils/TemplateBuilder/TemplateBuilder.js +74 -0
- package/dpr/utils/TemplateBuilder/TemplateBuilder.js.map +7 -0
- package/dpr/utils/TemplateBuilder/TemplateBuilder.ts +68 -0
- package/dpr/utils/definitionUtils.js +22 -2
- package/dpr/utils/definitionUtils.js.map +2 -2
- package/dpr/utils/definitionUtils.ts +26 -1
- package/package.json +1 -1
- package/dpr/DprLoadingHelper.js +0 -51
- package/dpr/DprLoadingHelper.js.map +0 -7
- package/dpr/DprLoadingHelper.ts +0 -27
- package/dpr/components/_reports/report/view.njk +0 -40
- package/dpr/components/_reports/report-actions/clientClass.js.map +0 -7
- package/dpr/components/_reports/report-actions/types.d.js.map +0 -7
- package/dpr/components/_reports/report-columns-form/clientClass.js.map +0 -7
- package/dpr/components/_reports/report-columns-form/utils.js.map +0 -7
- package/dpr/components/_reports/report-data-table/clientClass.js.map +0 -7
- package/dpr/components/_reports/report-data-table/types.d.js.map +0 -7
- package/dpr/components/_reports/report-data-table/utils.js +0 -123
- package/dpr/components/_reports/report-data-table/utils.js.map +0 -7
- package/dpr/components/_reports/report-data-table/utils.test.ts +0 -604
- package/dpr/components/_reports/report-data-table/utils.ts +0 -150
- package/dpr/components/_reports/report-data-table/view.njk +0 -24
- package/dpr/components/_reports/report-data-table-wrapper/view.njk +0 -27
- package/dpr/components/_reports/report-download-message/clientClass.js.map +0 -7
- package/dpr/components/_reports/report-no-data-message/styles.scss +0 -4
- package/dpr/components/_reports/report-no-data-message/view.njk +0 -13
- package/dpr/components/_reports/report-pagination/clientClass.js.map +0 -7
- package/dpr/components/_reports/report-print-message/view.njk +0 -8
- package/dpr/components/_reports/report-template/view.njk +0 -44
- package/dpr/components/_reports/report-wrapper/view.njk +0 -19
- package/dpr/components/loading-anim/styles.scss +0 -117
- package/dpr/components/loading-anim/view.njk +0 -18
- package/dpr/utils/CollatedSummaryBuilder/CollatedSummaryBuilder.js.map +0 -7
- package/dpr/utils/ParentChildDataTableBuilder/ParentChildDataTableBuilder.js +0 -202
- package/dpr/utils/ParentChildDataTableBuilder/ParentChildDataTableBuilder.js.map +0 -7
- package/dpr/utils/ParentChildDataTableBuilder/ParentChildDataTableBuilder.test.ts +0 -503
- package/dpr/utils/ParentChildDataTableBuilder/ParentChildDataTableBuilder.ts +0 -224
- package/dpr/utils/ParentChildDataTableBuilder/types.d.js.map +0 -7
- package/dpr/utils/ParentChildDataTableBuilder/types.d.ts +0 -11
- package/dpr/utils/SectionedDataTableBuilder/SectionedDataTableBuilder.js +0 -311
- package/dpr/utils/SectionedDataTableBuilder/SectionedDataTableBuilder.js.map +0 -7
- package/dpr/utils/SectionedDataTableBuilder/SectionedDataTableBuilder.test.ts +0 -492
- package/dpr/utils/SectionedDataTableBuilder/SectionedDataTableBuilder.ts +0 -342
- package/dpr/utils/SectionedDataTableBuilder/types.d.js.map +0 -7
- package/dpr/utils/SectionedDataTableBuilder/types.d.ts +0 -5
- package/dpr/utils/SectionedFieldsTableBuilder/SectionedFieldsTableBuilder.js +0 -146
- package/dpr/utils/SectionedFieldsTableBuilder/SectionedFieldsTableBuilder.js.map +0 -7
- package/dpr/utils/SectionedFieldsTableBuilder/SectionedFieldsTableBuilder.test.ts +0 -140
- package/dpr/utils/SectionedFieldsTableBuilder/SectionedFieldsTableBuilder.ts +0 -150
- /package/dpr/components/_reports/{report-actions → report-heading/report-actions}/actionsTemplate.js +0 -0
- /package/dpr/components/_reports/{report-actions → report-heading/report-actions}/actionsTemplate.ts +0 -0
- /package/dpr/components/_reports/{report-actions → report-heading/report-actions}/style.scss +0 -0
- /package/dpr/components/_reports/{report-actions → report-heading/report-actions}/types.d.js +0 -0
- /package/dpr/components/_reports/{report-actions → report-heading/report-actions}/utils.js +0 -0
- /package/dpr/components/_reports/{report-actions → report-heading/report-actions}/utils.ts +0 -0
- /package/dpr/components/_reports/{report-actions → report-heading/report-actions}/view.njk +0 -0
- /package/dpr/components/_reports/{report-columns-form → report-heading/report-columns/report-columns-form}/style.scss +0 -0
- /package/dpr/components/_reports/{report-columns-form → report-heading/report-columns/report-columns-form}/types.d.js +0 -0
- /package/dpr/components/_reports/{report-columns-form → report-heading/report-columns/report-columns-form}/types.d.ts +0 -0
- /package/dpr/components/_reports/{report-columns-form → report-heading/report-columns/report-columns-form}/view.njk +0 -0
- /package/dpr/components/_reports/{report-columns → report-heading/report-columns}/styles.scss +0 -0
- /package/dpr/components/_reports/{report-download-message → report-heading/report-download-message}/style.scss +0 -0
- /package/dpr/components/_reports/{report-download-message → report-heading/report-download-message}/view.njk +0 -0
- /package/dpr/components/_reports/{report-pagination → report-page/report-template/report-pagination}/style.scss +0 -0
- /package/dpr/components/_reports/{report-data-table → report-page/report-template/report-pagination}/types.d.js +0 -0
- /package/dpr/components/_reports/{report-pagination → report-page/report-template/report-pagination}/types.d.ts +0 -0
- /package/dpr/components/_reports/{report-pagination → report-page/report-template/report-pagination}/utils.js +0 -0
- /package/dpr/components/_reports/{report-pagination → report-page/report-template/report-pagination}/utils.test.ts +0 -0
- /package/dpr/components/_reports/{report-pagination → report-page/report-template/report-pagination}/utils.ts +0 -0
- /package/dpr/components/_reports/{report-pagination → report-page/report-template/report-pagination}/view.njk +0 -0
- /package/dpr/components/_reports/{report-pagination → report-page/report-template/report-section/report-data-table}/types.d.js +0 -0
- /package/dpr/components/_reports/{report-summary-table → report-page/report-template/report-summary-table}/view.njk +0 -0
- /package/dpr/components/_reports/{report-totals → report-page/report-template/report-totals}/style.scss +0 -0
- /package/dpr/components/_reports/{report-totals → report-page/report-template/report-totals}/utils.js +0 -0
- /package/dpr/components/_reports/{report-totals → report-page/report-template/report-totals}/utils.ts +0 -0
- /package/dpr/components/_reports/{report-totals → report-page/report-template/report-totals}/view.njk +0 -0
- /package/dpr/utils/{ParentChildDataTableBuilder → TemplateBuilder/ParentChildDataBuilder}/types.d.js +0 -0
- /package/dpr/utils/{SectionedDataTableBuilder → TemplateBuilder/ReportBuilder}/types.d.js +0 -0
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { components } from '../../../types/api'
|
|
2
|
+
import DataTableBuilder from '../../DataTableBuilder/DataTableBuilder'
|
|
3
|
+
import { DataTable } from '../../DataTableBuilder/types'
|
|
4
|
+
import { SectionedDataHelper } from '../SectionedDataHelper/SectionedDataHelper'
|
|
5
|
+
import { ReportTemplateData, SectionData } from '../SectionedDataHelper/types'
|
|
6
|
+
import { TemplateBuilder } from '../TemplateBuilder'
|
|
7
|
+
import { ChildData, GroupedParentChildDataset, ParentChildTableData, ParentChildDataset } from './types'
|
|
8
|
+
|
|
9
|
+
export class ParentChildDataBuilder extends TemplateBuilder {
|
|
10
|
+
childColumns: Array<string> = []
|
|
11
|
+
|
|
12
|
+
childVariants: components['schemas']['ChildVariantDefinition'][] = []
|
|
13
|
+
|
|
14
|
+
childData: Array<ChildData> = []
|
|
15
|
+
|
|
16
|
+
joinFields: Array<components['schemas']['FieldDefinition']> = []
|
|
17
|
+
|
|
18
|
+
childFields: Array<components['schemas']['FieldDefinition']> = []
|
|
19
|
+
|
|
20
|
+
parentChildDatasets: ParentChildDataset[] = []
|
|
21
|
+
|
|
22
|
+
dataTableBuilder!: DataTableBuilder
|
|
23
|
+
|
|
24
|
+
constructor(variant: components['schemas']['VariantDefinition']) {
|
|
25
|
+
super(variant)
|
|
26
|
+
|
|
27
|
+
this.childVariants = this.variant.childVariants || []
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
getChildVariant(childId: string) {
|
|
31
|
+
return this.childVariants.find((cv) => cv.id === childId)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Exracts the relevant data from the child variant definition
|
|
36
|
+
* to generate the child table
|
|
37
|
+
*
|
|
38
|
+
* @param {string} childId
|
|
39
|
+
* @return { fields: components['schemas']['FieldDefinition'][], joinFields: string[], columns: string[], name: string }
|
|
40
|
+
* @memberof ParentChildDataBuilder
|
|
41
|
+
*/
|
|
42
|
+
getChildVariantDefinitionData(childId: string) {
|
|
43
|
+
const childVariant = this.getChildVariant(childId)
|
|
44
|
+
|
|
45
|
+
let fields: components['schemas']['FieldDefinition'][] = []
|
|
46
|
+
let joinFields: string[] = []
|
|
47
|
+
let columns: string[] = []
|
|
48
|
+
let name = 'Child report'
|
|
49
|
+
|
|
50
|
+
if (childVariant && childVariant.specification) {
|
|
51
|
+
fields = childVariant.specification.fields
|
|
52
|
+
joinFields = childVariant && childVariant.specification ? childVariant.joinFields : []
|
|
53
|
+
columns = fields.filter((f) => f.visible).map((f) => f.name)
|
|
54
|
+
name = childVariant.name
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
fields,
|
|
59
|
+
joinFields,
|
|
60
|
+
columns,
|
|
61
|
+
name,
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Maps the parent child rows.
|
|
67
|
+
* Splits into sections that will become the parent table
|
|
68
|
+
*
|
|
69
|
+
* @return {*} {GroupedParentChildDataset[]}
|
|
70
|
+
* @memberof ParentChildDataBuilder
|
|
71
|
+
*/
|
|
72
|
+
mergeParentChildAndGroup(parentData: Record<string, string>[]): GroupedParentChildDataset[] {
|
|
73
|
+
const groups: GroupedParentChildDataset[] = []
|
|
74
|
+
let pendingParents: Array<Record<string, string>> = []
|
|
75
|
+
|
|
76
|
+
parentData.forEach((parentRow) => {
|
|
77
|
+
// Build a dataset for this parent
|
|
78
|
+
const dataset: ParentChildDataset = {
|
|
79
|
+
parent: parentRow,
|
|
80
|
+
children: [],
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
// Match against each child dataset
|
|
84
|
+
this.childData.forEach((child) => {
|
|
85
|
+
const { joinFields } = this.getChildVariantDefinitionData(child.id)
|
|
86
|
+
const matchedChildren: Record<string, string>[] = []
|
|
87
|
+
|
|
88
|
+
// Compare join fields
|
|
89
|
+
child.data.forEach((childRow) => {
|
|
90
|
+
const isMatch = joinFields.every((col) => {
|
|
91
|
+
return parentRow[col] === childRow[col]
|
|
92
|
+
})
|
|
93
|
+
if (isMatch) matchedChildren.push(childRow)
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
if (matchedChildren.length) {
|
|
97
|
+
dataset.children.push({
|
|
98
|
+
id: child.id,
|
|
99
|
+
data: matchedChildren,
|
|
100
|
+
})
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
|
|
104
|
+
// Always collect the parent
|
|
105
|
+
pendingParents.push(dataset.parent)
|
|
106
|
+
|
|
107
|
+
// If dataset has children → close the group
|
|
108
|
+
if (dataset.children.length > 0) {
|
|
109
|
+
groups.push({
|
|
110
|
+
parent: pendingParents,
|
|
111
|
+
children: dataset.children,
|
|
112
|
+
})
|
|
113
|
+
pendingParents = []
|
|
114
|
+
}
|
|
115
|
+
})
|
|
116
|
+
|
|
117
|
+
// If leftover parents exist, make a final group (empty children)
|
|
118
|
+
if (pendingParents.length > 0) {
|
|
119
|
+
groups.push({
|
|
120
|
+
parent: pendingParents,
|
|
121
|
+
children: [],
|
|
122
|
+
})
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
return groups
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* Maps the parent child data to a table data
|
|
130
|
+
*
|
|
131
|
+
* @param {GroupedParentChildDataset[]} parentChildGroups
|
|
132
|
+
* @return {*} {ParentChildData[]}
|
|
133
|
+
* @memberof ParentChildDataBuilder
|
|
134
|
+
*/
|
|
135
|
+
mapToTableData(parentChildGroups: GroupedParentChildDataset[]): ParentChildTableData[] {
|
|
136
|
+
const parentTableBuilder = new DataTableBuilder(this.fields)
|
|
137
|
+
return parentChildGroups.map((group: GroupedParentChildDataset) => {
|
|
138
|
+
const parentTable = parentTableBuilder.withNoHeaderOptions(this.columns).buildTable(group.parent)
|
|
139
|
+
const children: ParentChildTableData['children'] = this.mapChildDataToTableData(group)
|
|
140
|
+
|
|
141
|
+
return {
|
|
142
|
+
parent: parentTable,
|
|
143
|
+
children,
|
|
144
|
+
}
|
|
145
|
+
})
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* Maps the grouped child data to table data
|
|
150
|
+
*
|
|
151
|
+
* @param {GroupedParentChildDataset} group
|
|
152
|
+
* @return {*}
|
|
153
|
+
* @memberof ParentChildDataBuilder
|
|
154
|
+
*/
|
|
155
|
+
mapChildDataToTableData(group: GroupedParentChildDataset) {
|
|
156
|
+
return group.children.map((child) => {
|
|
157
|
+
const { fields: childFields, columns: childColumns, name } = this.getChildVariantDefinitionData(child.id)
|
|
158
|
+
const childTableBuilder = new DataTableBuilder(childFields)
|
|
159
|
+
const childTable = childTableBuilder.withNoHeaderOptions(childColumns).buildTable(child.data)
|
|
160
|
+
|
|
161
|
+
return {
|
|
162
|
+
title: name,
|
|
163
|
+
...childTable,
|
|
164
|
+
}
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
withChildData(childData: Array<ChildData>) {
|
|
169
|
+
this.childData = childData
|
|
170
|
+
return this
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
withChildColumns(childColumns: string[]) {
|
|
174
|
+
this.childColumns = childColumns
|
|
175
|
+
return this
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
build(): ReportTemplateData {
|
|
179
|
+
const sectionData = new SectionedDataHelper()
|
|
180
|
+
.withSections(this.sections)
|
|
181
|
+
.withData(this.data)
|
|
182
|
+
.withFields(this.fields)
|
|
183
|
+
.withReportQuery(this.reportQuery)
|
|
184
|
+
.build()
|
|
185
|
+
|
|
186
|
+
const { sections } = sectionData
|
|
187
|
+
const mappedSections = sections.map((section: SectionData) => {
|
|
188
|
+
const groups = this.mergeParentChildAndGroup(<Array<Record<string, string>>>section.data)
|
|
189
|
+
const table = this.mapToTableData(groups)
|
|
190
|
+
|
|
191
|
+
return {
|
|
192
|
+
...section,
|
|
193
|
+
summaries: [] as unknown as Record<string, DataTable[]>,
|
|
194
|
+
data: table,
|
|
195
|
+
}
|
|
196
|
+
})
|
|
197
|
+
|
|
198
|
+
return {
|
|
199
|
+
rowCount: this.data.length,
|
|
200
|
+
sections: mappedSections,
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../dpr/utils/TemplateBuilder/ParentChildDataBuilder/types.d.ts"],
|
|
4
|
+
"sourcesContent": ["import { Cell } from '../../DataTableBuilder/types'\n\nexport interface ChildData {\n id: string\n data: Array<Record<string, string>>\n}\n\nexport interface ParentChildTableData {\n parent: {\n head: Cell[] | null\n rows: Cell[][]\n }\n children: {\n title: string\n head: Cell[] | null\n rows: Cell[][]\n }[]\n}\n\nexport interface ParentChildDataset {\n parent: Record<string, string>\n children: ChildData[]\n}\n\nexport interface GroupedParentChildDataset {\n parent: Array<Record<string, string>>\n children: ChildData[]\n}\nexport interface ParentChildTemplateData {\n rowCount: number\n sections: {\n title?: string\n count?: number\n data: ParentChildTableData[]\n }[]\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Cell } from '../../DataTableBuilder/types'
|
|
2
|
+
|
|
3
|
+
export interface ChildData {
|
|
4
|
+
id: string
|
|
5
|
+
data: Array<Record<string, string>>
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export interface ParentChildTableData {
|
|
9
|
+
parent: {
|
|
10
|
+
head: Cell[] | null
|
|
11
|
+
rows: Cell[][]
|
|
12
|
+
}
|
|
13
|
+
children: {
|
|
14
|
+
title: string
|
|
15
|
+
head: Cell[] | null
|
|
16
|
+
rows: Cell[][]
|
|
17
|
+
}[]
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ParentChildDataset {
|
|
21
|
+
parent: Record<string, string>
|
|
22
|
+
children: ChildData[]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface GroupedParentChildDataset {
|
|
26
|
+
parent: Array<Record<string, string>>
|
|
27
|
+
children: ChildData[]
|
|
28
|
+
}
|
|
29
|
+
export interface ParentChildTemplateData {
|
|
30
|
+
rowCount: number
|
|
31
|
+
sections: {
|
|
32
|
+
title?: string
|
|
33
|
+
count?: number
|
|
34
|
+
data: ParentChildTableData[]
|
|
35
|
+
}[]
|
|
36
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
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 ReportBuilder_exports = {};
|
|
30
|
+
__export(ReportBuilder_exports, {
|
|
31
|
+
ReportBuilder: () => ReportBuilder
|
|
32
|
+
});
|
|
33
|
+
module.exports = __toCommonJS(ReportBuilder_exports);
|
|
34
|
+
var import_SummaryDataHelper = require("../SummaryDataHelper/SummaryDataHelper");
|
|
35
|
+
var import_DataTableBuilder = __toESM(require("../../DataTableBuilder/DataTableBuilder"));
|
|
36
|
+
var import_SectionedDataHelper = require("../SectionedDataHelper/SectionedDataHelper");
|
|
37
|
+
var import_TemplateBuilder = require("../TemplateBuilder");
|
|
38
|
+
class ReportBuilder extends import_TemplateBuilder.TemplateBuilder {
|
|
39
|
+
dataTableBuilder;
|
|
40
|
+
sectionBuilder;
|
|
41
|
+
constructor(variant) {
|
|
42
|
+
super(variant);
|
|
43
|
+
}
|
|
44
|
+
buildMainTable(section) {
|
|
45
|
+
const collatedSummaryBuilder = new import_SummaryDataHelper.CollatedSummaryBuilder(this.specification, section.summaries);
|
|
46
|
+
const tableSummaries = collatedSummaryBuilder.collateDataTableSummaries();
|
|
47
|
+
this.dataTableBuilder = new import_DataTableBuilder.default(this.fields);
|
|
48
|
+
return this.dataTableBuilder.withSummaries(tableSummaries).withHeaderOptions({
|
|
49
|
+
columns: this.columns,
|
|
50
|
+
reportQuery: this.reportQuery,
|
|
51
|
+
interactive: Boolean(this.interactive)
|
|
52
|
+
}).buildTable(section.data);
|
|
53
|
+
}
|
|
54
|
+
buildSummaryTables(summaries) {
|
|
55
|
+
const summaryTables = summaries.map((summaryData) => {
|
|
56
|
+
const fields = summaryData.fields;
|
|
57
|
+
const { data, template } = summaryData;
|
|
58
|
+
const summaryTableData = new import_DataTableBuilder.default(fields).withNoHeaderOptions(fields.map((f) => f.name)).buildTable(data);
|
|
59
|
+
return {
|
|
60
|
+
template,
|
|
61
|
+
data: summaryTableData
|
|
62
|
+
};
|
|
63
|
+
});
|
|
64
|
+
return this.groupSummaryTables(summaryTables);
|
|
65
|
+
}
|
|
66
|
+
buildSummariesTables(section) {
|
|
67
|
+
const { summaries } = section;
|
|
68
|
+
const summaryTables = summaries.map((summaryData) => {
|
|
69
|
+
const fields = summaryData.fields;
|
|
70
|
+
const { data, template } = summaryData;
|
|
71
|
+
const summaryTableData = new import_DataTableBuilder.default(fields).withNoHeaderOptions(fields.map((f) => f.name)).buildTable(data);
|
|
72
|
+
return {
|
|
73
|
+
template,
|
|
74
|
+
data: summaryTableData
|
|
75
|
+
};
|
|
76
|
+
});
|
|
77
|
+
return this.groupSummaryTables(summaryTables);
|
|
78
|
+
}
|
|
79
|
+
groupSummaryTables(summaryTables) {
|
|
80
|
+
return summaryTables.reduce((acc, item) => {
|
|
81
|
+
if (!acc[item.template]) {
|
|
82
|
+
acc[item.template] = [];
|
|
83
|
+
}
|
|
84
|
+
acc[item.template].push(item.data);
|
|
85
|
+
return acc;
|
|
86
|
+
}, {});
|
|
87
|
+
}
|
|
88
|
+
buildSectionedData() {
|
|
89
|
+
const sectionData = new import_SectionedDataHelper.SectionedDataHelper().withData(this.data).withSections(this.sections).withSummaries(this.summaries).withFields(this.fields).withReportQuery(this.reportQuery).build();
|
|
90
|
+
return sectionData.sections.map((section) => {
|
|
91
|
+
const tableData = this.buildMainTable(section);
|
|
92
|
+
const sectionSummaryTables = this.buildSummaryTables(section.summaries);
|
|
93
|
+
return {
|
|
94
|
+
...section,
|
|
95
|
+
summaries: sectionSummaryTables,
|
|
96
|
+
data: tableData
|
|
97
|
+
};
|
|
98
|
+
});
|
|
99
|
+
}
|
|
100
|
+
build() {
|
|
101
|
+
const pageSummaryTables = this.buildSummaryTables(this.pageSummaries);
|
|
102
|
+
const sections = this.buildSectionedData();
|
|
103
|
+
return {
|
|
104
|
+
rowCount: this.data.length,
|
|
105
|
+
summaries: pageSummaryTables,
|
|
106
|
+
sections
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
111
|
+
0 && (module.exports = {
|
|
112
|
+
ReportBuilder
|
|
113
|
+
});
|
|
114
|
+
//# sourceMappingURL=ReportBuilder.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../dpr/utils/TemplateBuilder/ReportBuilder/ReportBuilder.ts"],
|
|
4
|
+
"sourcesContent": ["import { AsyncSummary } from '../../../types/UserReports'\nimport { SummaryTemplate } from '../../../types/Templates'\nimport { components } from '../../../types/api'\nimport { CollatedSummaryBuilder } from '../SummaryDataHelper/SummaryDataHelper'\nimport DataTableBuilder from '../../DataTableBuilder/DataTableBuilder'\nimport { SectionedDataHelper } from '../SectionedDataHelper/SectionedDataHelper'\nimport { ReportTemplateData, SectionData } from '../SectionedDataHelper/types'\nimport { DataTable } from '../../DataTableBuilder/types'\nimport { TemplateBuilder } from '../TemplateBuilder'\n\nexport class ReportBuilder extends TemplateBuilder {\n dataTableBuilder!: DataTableBuilder\n\n sectionBuilder!: SectionedDataHelper\n\n constructor(variant: components['schemas']['VariantDefinition']) {\n super(variant)\n }\n\n buildMainTable(section: SectionData) {\n const collatedSummaryBuilder = new CollatedSummaryBuilder(this.specification, section.summaries)\n const tableSummaries = collatedSummaryBuilder.collateDataTableSummaries()\n this.dataTableBuilder = new DataTableBuilder(this.fields)\n return this.dataTableBuilder\n .withSummaries(tableSummaries)\n .withHeaderOptions({\n columns: this.columns,\n reportQuery: this.reportQuery,\n interactive: Boolean(this.interactive),\n })\n .buildTable(section.data)\n }\n\n buildSummaryTables(summaries: AsyncSummary[]) {\n const summaryTables = summaries.map((summaryData) => {\n const fields = <components['schemas']['FieldDefinition'][]>summaryData.fields\n const { data, template } = summaryData\n const summaryTableData = new DataTableBuilder(fields)\n .withNoHeaderOptions(fields.map((f) => f.name))\n .buildTable(data)\n\n return {\n template,\n data: summaryTableData,\n }\n })\n\n return this.groupSummaryTables(summaryTables)\n }\n\n buildSummariesTables(section: SectionData) {\n const { summaries } = section\n const summaryTables: {\n template: SummaryTemplate\n data: DataTable\n }[] = summaries.map((summaryData) => {\n const fields = <components['schemas']['FieldDefinition'][]>summaryData.fields\n const { data, template } = summaryData\n const summaryTableData = new DataTableBuilder(fields)\n .withNoHeaderOptions(fields.map((f) => f.name))\n .buildTable(data)\n\n return {\n template,\n data: summaryTableData,\n }\n })\n\n return this.groupSummaryTables(summaryTables)\n }\n\n groupSummaryTables(\n summaryTables: {\n template: SummaryTemplate\n data: DataTable\n }[],\n ) {\n return summaryTables.reduce<Record<string, DataTable[]>>((acc, item) => {\n if (!acc[item.template]) {\n acc[item.template] = []\n }\n acc[item.template].push(item.data)\n return acc\n }, {})\n }\n\n buildSectionedData() {\n const sectionData = new SectionedDataHelper()\n .withData(this.data)\n .withSections(this.sections)\n .withSummaries(this.summaries)\n .withFields(this.fields)\n .withReportQuery(this.reportQuery)\n .build()\n\n return sectionData.sections.map((section: SectionData) => {\n const tableData = this.buildMainTable(section)\n const sectionSummaryTables = this.buildSummaryTables(section.summaries)\n return {\n ...section,\n summaries: sectionSummaryTables,\n data: tableData,\n }\n })\n }\n\n build(): ReportTemplateData {\n const pageSummaryTables = this.buildSummaryTables(this.pageSummaries)\n const sections = this.buildSectionedData()\n\n return {\n rowCount: this.data.length,\n summaries: pageSummaryTables,\n sections,\n }\n }\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGA,+BAAuC;AACvC,8BAA6B;AAC7B,iCAAoC;AAGpC,6BAAgC;AAEzB,MAAM,sBAAsB,uCAAgB;AAAA,EACjD;AAAA,EAEA;AAAA,EAEA,YAAY,SAAqD;AAC/D,UAAM,OAAO;AAAA,EACf;AAAA,EAEA,eAAe,SAAsB;AACnC,UAAM,yBAAyB,IAAI,gDAAuB,KAAK,eAAe,QAAQ,SAAS;AAC/F,UAAM,iBAAiB,uBAAuB,0BAA0B;AACxE,SAAK,mBAAmB,IAAI,wBAAAA,QAAiB,KAAK,MAAM;AACxD,WAAO,KAAK,iBACT,cAAc,cAAc,EAC5B,kBAAkB;AAAA,MACjB,SAAS,KAAK;AAAA,MACd,aAAa,KAAK;AAAA,MAClB,aAAa,QAAQ,KAAK,WAAW;AAAA,IACvC,CAAC,EACA,WAAW,QAAQ,IAAI;AAAA,EAC5B;AAAA,EAEA,mBAAmB,WAA2B;AAC5C,UAAM,gBAAgB,UAAU,IAAI,CAAC,gBAAgB;AACnD,YAAM,SAAqD,YAAY;AACvE,YAAM,EAAE,MAAM,SAAS,IAAI;AAC3B,YAAM,mBAAmB,IAAI,wBAAAA,QAAiB,MAAM,EACjD,oBAAoB,OAAO,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,EAC7C,WAAW,IAAI;AAElB,aAAO;AAAA,QACL;AAAA,QACA,MAAM;AAAA,MACR;AAAA,IACF,CAAC;AAED,WAAO,KAAK,mBAAmB,aAAa;AAAA,EAC9C;AAAA,EAEA,qBAAqB,SAAsB;AACzC,UAAM,EAAE,UAAU,IAAI;AACtB,UAAM,gBAGA,UAAU,IAAI,CAAC,gBAAgB;AACnC,YAAM,SAAqD,YAAY;AACvE,YAAM,EAAE,MAAM,SAAS,IAAI;AAC3B,YAAM,mBAAmB,IAAI,wBAAAA,QAAiB,MAAM,EACjD,oBAAoB,OAAO,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,EAC7C,WAAW,IAAI;AAElB,aAAO;AAAA,QACL;AAAA,QACA,MAAM;AAAA,MACR;AAAA,IACF,CAAC;AAED,WAAO,KAAK,mBAAmB,aAAa;AAAA,EAC9C;AAAA,EAEA,mBACE,eAIA;AACA,WAAO,cAAc,OAAoC,CAAC,KAAK,SAAS;AACtE,UAAI,CAAC,IAAI,KAAK,QAAQ,GAAG;AACvB,YAAI,KAAK,QAAQ,IAAI,CAAC;AAAA,MACxB;AACA,UAAI,KAAK,QAAQ,EAAE,KAAK,KAAK,IAAI;AACjC,aAAO;AAAA,IACT,GAAG,CAAC,CAAC;AAAA,EACP;AAAA,EAEA,qBAAqB;AACnB,UAAM,cAAc,IAAI,+CAAoB,EACzC,SAAS,KAAK,IAAI,EAClB,aAAa,KAAK,QAAQ,EAC1B,cAAc,KAAK,SAAS,EAC5B,WAAW,KAAK,MAAM,EACtB,gBAAgB,KAAK,WAAW,EAChC,MAAM;AAET,WAAO,YAAY,SAAS,IAAI,CAAC,YAAyB;AACxD,YAAM,YAAY,KAAK,eAAe,OAAO;AAC7C,YAAM,uBAAuB,KAAK,mBAAmB,QAAQ,SAAS;AACtE,aAAO;AAAA,QACL,GAAG;AAAA,QACH,WAAW;AAAA,QACX,MAAM;AAAA,MACR;AAAA,IACF,CAAC;AAAA,EACH;AAAA,EAEA,QAA4B;AAC1B,UAAM,oBAAoB,KAAK,mBAAmB,KAAK,aAAa;AACpE,UAAM,WAAW,KAAK,mBAAmB;AAEzC,WAAO;AAAA,MACL,UAAU,KAAK,KAAK;AAAA,MACpB,WAAW;AAAA,MACX;AAAA,IACF;AAAA,EACF;AACF;",
|
|
6
|
+
"names": ["DataTableBuilder"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
import { AsyncSummary } from '../../../types/UserReports'
|
|
2
|
+
import { SummaryTemplate } from '../../../types/Templates'
|
|
3
|
+
import { components } from '../../../types/api'
|
|
4
|
+
import { CollatedSummaryBuilder } from '../SummaryDataHelper/SummaryDataHelper'
|
|
5
|
+
import DataTableBuilder from '../../DataTableBuilder/DataTableBuilder'
|
|
6
|
+
import { SectionedDataHelper } from '../SectionedDataHelper/SectionedDataHelper'
|
|
7
|
+
import { ReportTemplateData, SectionData } from '../SectionedDataHelper/types'
|
|
8
|
+
import { DataTable } from '../../DataTableBuilder/types'
|
|
9
|
+
import { TemplateBuilder } from '../TemplateBuilder'
|
|
10
|
+
|
|
11
|
+
export class ReportBuilder extends TemplateBuilder {
|
|
12
|
+
dataTableBuilder!: DataTableBuilder
|
|
13
|
+
|
|
14
|
+
sectionBuilder!: SectionedDataHelper
|
|
15
|
+
|
|
16
|
+
constructor(variant: components['schemas']['VariantDefinition']) {
|
|
17
|
+
super(variant)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
buildMainTable(section: SectionData) {
|
|
21
|
+
const collatedSummaryBuilder = new CollatedSummaryBuilder(this.specification, section.summaries)
|
|
22
|
+
const tableSummaries = collatedSummaryBuilder.collateDataTableSummaries()
|
|
23
|
+
this.dataTableBuilder = new DataTableBuilder(this.fields)
|
|
24
|
+
return this.dataTableBuilder
|
|
25
|
+
.withSummaries(tableSummaries)
|
|
26
|
+
.withHeaderOptions({
|
|
27
|
+
columns: this.columns,
|
|
28
|
+
reportQuery: this.reportQuery,
|
|
29
|
+
interactive: Boolean(this.interactive),
|
|
30
|
+
})
|
|
31
|
+
.buildTable(section.data)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
buildSummaryTables(summaries: AsyncSummary[]) {
|
|
35
|
+
const summaryTables = summaries.map((summaryData) => {
|
|
36
|
+
const fields = <components['schemas']['FieldDefinition'][]>summaryData.fields
|
|
37
|
+
const { data, template } = summaryData
|
|
38
|
+
const summaryTableData = new DataTableBuilder(fields)
|
|
39
|
+
.withNoHeaderOptions(fields.map((f) => f.name))
|
|
40
|
+
.buildTable(data)
|
|
41
|
+
|
|
42
|
+
return {
|
|
43
|
+
template,
|
|
44
|
+
data: summaryTableData,
|
|
45
|
+
}
|
|
46
|
+
})
|
|
47
|
+
|
|
48
|
+
return this.groupSummaryTables(summaryTables)
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
buildSummariesTables(section: SectionData) {
|
|
52
|
+
const { summaries } = section
|
|
53
|
+
const summaryTables: {
|
|
54
|
+
template: SummaryTemplate
|
|
55
|
+
data: DataTable
|
|
56
|
+
}[] = summaries.map((summaryData) => {
|
|
57
|
+
const fields = <components['schemas']['FieldDefinition'][]>summaryData.fields
|
|
58
|
+
const { data, template } = summaryData
|
|
59
|
+
const summaryTableData = new DataTableBuilder(fields)
|
|
60
|
+
.withNoHeaderOptions(fields.map((f) => f.name))
|
|
61
|
+
.buildTable(data)
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
template,
|
|
65
|
+
data: summaryTableData,
|
|
66
|
+
}
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
return this.groupSummaryTables(summaryTables)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
groupSummaryTables(
|
|
73
|
+
summaryTables: {
|
|
74
|
+
template: SummaryTemplate
|
|
75
|
+
data: DataTable
|
|
76
|
+
}[],
|
|
77
|
+
) {
|
|
78
|
+
return summaryTables.reduce<Record<string, DataTable[]>>((acc, item) => {
|
|
79
|
+
if (!acc[item.template]) {
|
|
80
|
+
acc[item.template] = []
|
|
81
|
+
}
|
|
82
|
+
acc[item.template].push(item.data)
|
|
83
|
+
return acc
|
|
84
|
+
}, {})
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
buildSectionedData() {
|
|
88
|
+
const sectionData = new SectionedDataHelper()
|
|
89
|
+
.withData(this.data)
|
|
90
|
+
.withSections(this.sections)
|
|
91
|
+
.withSummaries(this.summaries)
|
|
92
|
+
.withFields(this.fields)
|
|
93
|
+
.withReportQuery(this.reportQuery)
|
|
94
|
+
.build()
|
|
95
|
+
|
|
96
|
+
return sectionData.sections.map((section: SectionData) => {
|
|
97
|
+
const tableData = this.buildMainTable(section)
|
|
98
|
+
const sectionSummaryTables = this.buildSummaryTables(section.summaries)
|
|
99
|
+
return {
|
|
100
|
+
...section,
|
|
101
|
+
summaries: sectionSummaryTables,
|
|
102
|
+
data: tableData,
|
|
103
|
+
}
|
|
104
|
+
})
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
build(): ReportTemplateData {
|
|
108
|
+
const pageSummaryTables = this.buildSummaryTables(this.pageSummaries)
|
|
109
|
+
const sections = this.buildSectionedData()
|
|
110
|
+
|
|
111
|
+
return {
|
|
112
|
+
rowCount: this.data.length,
|
|
113
|
+
summaries: pageSummaryTables,
|
|
114
|
+
sections,
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../dpr/utils/TemplateBuilder/ReportBuilder/types.d.ts"],
|
|
4
|
+
"sourcesContent": ["import { Cell } from '../../DataTableBuilder/types'\n\nexport interface ListSectionTableData {\n head: Cell[] | null\n rows: Cell[][]\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
|
|
6
|
+
"names": []
|
|
7
|
+
}
|