UNPKG

@ministryofjustice/hmpps-digital-prison-reporting-frontend

Version:

The Digital Prison Reporting Frontend contains templates and code to help display data effectively in UI applications.

99 lines (98 loc) 3.49 kB
import { Request, Response } from 'express'; import { SubscriptionActionConfig } from 'src/dpr/types/AsyncReportUtils'; import { components } from '../../types/api'; import ReportQuery from '../../types/ReportQuery'; import { Services } from '../../types/Services'; import { ExtractedDefinitionData, ExtractedRequestData } from '../../routes/journeys/view-report/async/report/types'; import { LoadType, ReportType, RequestedReport } from '../../types/UserReports'; import { FilterValue } from '../_filters/types'; import { DownloadActionParams, ReportAction } from '../_reports/report-heading/report-actions/types'; import { AppliedFilterChip } from '../_filters/filters-applied/utils'; export default class DataPresentation { readonly services: Services; readonly res: Response; readonly req: Request; readonly definition: components['schemas']['DashboardDefinition'] | components['schemas']['SingleVariantReportDefinition']; readonly loadType: LoadType; readonly type: ReportType; readonly requestData?: RequestedReport | undefined; id: string; reportId: string; tableId: string; token: string; userId: string; expired: boolean; extractedRequestData: ExtractedRequestData | undefined; reportDetails: ExtractedDefinitionData; fields: components['schemas']['FieldDefinition'][] | undefined | null; reportQuery: ReportQuery; actions: { actions: ReportAction[]; downloadConfig: DownloadActionParams | undefined; bookmarkConfig: { bookmarkActionEndpoint: string; showBookmark: boolean; linkText: string; linkType: string; }; subscriptionConfig: SubscriptionActionConfig | undefined; feedbackFormHref: string | undefined; }; filterData: FilterValue[]; appliedFilters: AppliedFilterChip[]; savedDefaultsConfig: { hasDefaults: boolean | undefined; saveDefaultsEnabled: boolean; }; constructor(services: Services, res: Response, req: Request, definition: components['schemas']['DashboardDefinition'] | components['schemas']['SingleVariantReportDefinition'], loadType: LoadType, type: ReportType, requestData?: RequestedReport | undefined); /** * Gets and sets the fields by report types * */ getFields: () => void; /** * Builds the report meta data * */ buildReportMeta: (type: ReportType) => { loadType: LoadType; csrfToken: string; type: ReportType; tableId?: string; id: string; reportId: string; }; /** * Build the filters */ buildFilters: () => Promise<void>; /** * Builds the applied filters buttons * */ buildAppliedFilters: () => void; /** * Builds the saved defaults config * */ buildSavedDefaultsConfig: () => Promise<void>; /** * Extracts the relevant data from the requested report data * * @param {RequestedReport} requestData * @return {*} {ExtractedRequestData} */ extractDataFromRequest: (requestData: RequestedReport) => ExtractedRequestData; /** * Builds the report actions: * - download config * - bookmark config * - general actions */ buildActions: (type: ReportType, schedule?: string | undefined) => Promise<void>; /** * Gets the current request query * */ getCurrentQuery: () => Record<string, string | string[]>; }