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.

46 lines (42 loc) 1.69 kB
'use strict'; var utils = require('../../utils.js'); var ErrorHandler = require('../../../../../utils/ErrorHandler/ErrorHandler.js'); var UserReports = require('../../../../../types/UserReports.js'); class ViewAsyncReportController { layoutPath; services; constructor(layoutPath, services) { this.layoutPath = layoutPath; this.services = services; } // ----------------------------- // Filters // ----------------------------- applyFilters = async (req, res, _next) => { await utils.default.applyReportInteractiveQuery(req, res, this.services, 'filters', UserReports.LoadType.ASYNC); }; applyColumns = async (req, res, _next) => { await utils.default.applyReportInteractiveQuery(req, res, this.services, 'columns', UserReports.LoadType.ASYNC); }; resetColumns = async (req, res, next) => { try { const { id, reportId, tableId } = req.params; // Create the final querystring const finalQuery = utils.default.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.ErrorHandler(error).formatError(), ...(req.body && { ...req.body }), }; next(error); } }; } exports.ViewAsyncReportController = ViewAsyncReportController; //# sourceMappingURL=controller.js.map