@ministryofjustice/hmpps-digital-prison-reporting-frontend
Version:
The Digital Prison Reporting Frontend contains templates and code to help display data effectively in UI applications.
84 lines (83 loc) • 3.4 kB
TypeScript
import { components } from '../../../types/api';
import DataTableBuilder from '../../DataTableBuilder/DataTableBuilder';
import { ReportTemplateData } from '../SectionedDataHelper/types';
import { TemplateBuilder } from '../TemplateBuilder';
import { ChildData, GroupedParentChildDataset, ParentChildTableData, ParentChildDataset } from './types';
export declare class ParentChildDataBuilder extends TemplateBuilder {
childColumns: Array<string>;
childVariants: components['schemas']['ChildVariantDefinition'][];
childData: Array<ChildData>;
joinFields: Array<components['schemas']['FieldDefinition']>;
childFields: Array<components['schemas']['FieldDefinition']>;
parentChildDatasets: ParentChildDataset[];
dataTableBuilder: DataTableBuilder;
constructor(variant: components['schemas']['VariantDefinition'], defId: string);
getChildVariant(childId: string): {
id: string;
name: string;
resourceName: string;
specification?: components["schemas"]["Specification"] | null;
joinFields: string[];
} | undefined;
/**
* Exracts the relevant data from the child variant definition
* to generate the child table
*
* @param {string} childId
* @return { fields: components['schemas']['FieldDefinition'][], joinFields: string[], columns: string[], name: string }
* @memberof ParentChildDataBuilder
*/
getChildVariantDefinitionData(childId: string): {
fields: {
name: string;
display: string;
wordWrap?: "none" | "normal" | "break-words" | null;
filter?: components["schemas"]["FilterDefinition"] | null;
sortable: boolean;
defaultsort: boolean;
sortDirection?: "asc" | "desc" | null;
type: "boolean" | "date" | "double" | "HTML" | "long" | "string" | "time" | "timestamp";
mandatory: boolean;
visible: boolean;
calculated: boolean;
header: boolean;
fieldSource: "specfield" | "paramfield";
}[];
joinFields: string[];
columns: string[];
name: string;
};
/**
* Maps the parent child rows.
* Splits into sections that will become the parent table
*
* @return {*} {GroupedParentChildDataset[]}
* @memberof ParentChildDataBuilder
*/
mergeParentChildAndGroup(parentData: Record<string, string>[]): GroupedParentChildDataset[];
/**
* Maps the parent child data to a table data
*
* @param {GroupedParentChildDataset[]} parentChildGroups
* @return {*} {ParentChildData[]}
* @memberof ParentChildDataBuilder
*/
mapToTableData(parentChildGroups: GroupedParentChildDataset[]): ParentChildTableData[];
/**
* Maps the grouped child data to table data
*
* @param {GroupedParentChildDataset} group
* @return {*}
* @memberof ParentChildDataBuilder
*/
mapChildDataToTableData(group: GroupedParentChildDataset): {
head: Array<import("../../DataTableBuilder/types").Cell> | null;
rows: Array<Array<import("../../DataTableBuilder/types").Cell>>;
rowCount: number;
colCount: number;
title: string;
}[];
withChildData(childData: Array<ChildData>): this;
withChildColumns(childColumns: string[]): this;
build(): ReportTemplateData;
}