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.

44 lines (41 loc) 1.62 kB
import ViewReportUtils from '../../utils.js'; import { ErrorHandler } from '../../../../../utils/ErrorHandler/ErrorHandler.js'; import { LoadType } from '../../../../../types/UserReports.js'; class ViewAsyncReportController { layoutPath; services; constructor(layoutPath, services) { this.layoutPath = layoutPath; this.services = services; } // ----------------------------- // Filters // ----------------------------- applyFilters = async (req, res, _next) => { await ViewReportUtils.applyReportInteractiveQuery(req, res, this.services, 'filters', LoadType.ASYNC); }; applyColumns = async (req, res, _next) => { await ViewReportUtils.applyReportInteractiveQuery(req, res, this.services, 'columns', LoadType.ASYNC); }; resetColumns = async (req, res, next) => { try { const { id, reportId, tableId } = req.params; // Create the final querystring const finalQuery = ViewReportUtils.resetColumnsQueryString(req, { id, reportId, tableId }); // Redirect with new query string - query string will handle all rendered elements if (finalQuery) { res.redirect(`${req.baseUrl}?${finalQuery}`); } } catch (error) { req.body = { title: 'Failed to reset filters', error: new ErrorHandler(error).formatError(), ...(req.body && { ...req.body }), }; next(error); } }; } export { ViewAsyncReportController }; //# sourceMappingURL=controller.js.map