@ministryofjustice/hmpps-digital-prison-reporting-frontend 4.22.2 → 4.22.4

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.
Files changed (53) hide show
  1. package/dpr/DprPollingStatusClass.mjs +2 -2
  2. package/dpr/components/_async/async-filters-form/types.d.js +1 -1
  3. package/dpr/components/_async/async-filters-form/types.d.js.map +1 -1
  4. package/dpr/components/_async/async-filters-form/types.d.ts +0 -1
  5. package/dpr/components/_catalogue/catalogue-list/utils.js +1 -1
  6. package/dpr/components/_catalogue/catalogue-list/utils.js.map +3 -3
  7. package/dpr/components/_catalogue/catalogue-list/utils.ts +2 -1
  8. package/dpr/components/_charts/utils.test.ts +0 -3
  9. package/dpr/components/bookmark-toggle/clientClass.mjs +6 -4
  10. package/dpr/components/bookmark-toggle/view.njk +1 -1
  11. package/dpr/components/user-reports/bookmarks/utils.js +1 -1
  12. package/dpr/components/user-reports/bookmarks/utils.js.map +3 -3
  13. package/dpr/components/user-reports/bookmarks/utils.ts +13 -3
  14. package/dpr/components/user-reports/requested/clientClass.mjs +19 -7
  15. package/dpr/components/user-reports/utils.js.map +2 -2
  16. package/dpr/components/user-reports/utils.test.ts +24 -24
  17. package/dpr/components/user-reports/utils.ts +2 -0
  18. package/dpr/components/user-reports/viewed/clientClass.mjs +4 -3
  19. package/dpr/middleware/setUpDprResources.js +1 -1
  20. package/dpr/middleware/setUpDprResources.js.map +3 -3
  21. package/dpr/middleware/setUpDprResources.test.ts +1 -0
  22. package/dpr/middleware/setUpDprResources.ts +3 -1
  23. package/dpr/routes/journeys/my-reports/bookmarks/controller.js +1 -1
  24. package/dpr/routes/journeys/my-reports/bookmarks/controller.js.map +3 -3
  25. package/dpr/routes/journeys/my-reports/bookmarks/controller.ts +6 -9
  26. package/dpr/routes/journeys/my-reports/bookmarks/routes.js +1 -1
  27. package/dpr/routes/journeys/my-reports/bookmarks/routes.js.map +2 -2
  28. package/dpr/routes/journeys/my-reports/bookmarks/routes.ts +0 -3
  29. package/dpr/routes/journeys/my-reports/bookmarks/service.js +3 -3
  30. package/dpr/routes/journeys/my-reports/bookmarks/service.js.map +3 -3
  31. package/dpr/routes/journeys/my-reports/bookmarks/service.ts +7 -4
  32. package/dpr/routes/journeys/my-reports/recently-viewed/controller.js +1 -1
  33. package/dpr/routes/journeys/my-reports/recently-viewed/controller.js.map +2 -2
  34. package/dpr/routes/journeys/my-reports/recently-viewed/controller.ts +2 -1
  35. package/dpr/routes/journeys/my-reports/recently-viewed/routes.js +1 -1
  36. package/dpr/routes/journeys/my-reports/recently-viewed/routes.js.map +2 -2
  37. package/dpr/routes/journeys/my-reports/recently-viewed/routes.ts +1 -1
  38. package/dpr/routes/journeys/my-reports/requested-reports/controller.js +1 -1
  39. package/dpr/routes/journeys/my-reports/requested-reports/controller.js.map +2 -2
  40. package/dpr/routes/journeys/my-reports/requested-reports/controller.ts +1 -1
  41. package/dpr/routes/journeys/my-reports/requested-reports/routes.js +1 -1
  42. package/dpr/routes/journeys/my-reports/requested-reports/routes.js.map +2 -2
  43. package/dpr/routes/journeys/my-reports/requested-reports/routes.ts +1 -1
  44. package/dpr/routes/journeys/my-reports/requested-reports/service.js +1 -1
  45. package/dpr/routes/journeys/my-reports/requested-reports/service.js.map +3 -3
  46. package/dpr/routes/journeys/my-reports/requested-reports/service.ts +37 -1
  47. package/dpr/routes/journeys/request-report/filters/utils.js +1 -1
  48. package/dpr/routes/journeys/request-report/filters/utils.js.map +2 -2
  49. package/dpr/routes/journeys/request-report/filters/utils.ts +3 -1
  50. package/dpr/routes/journeys/request-report/tests.cy.js +1 -1
  51. package/dpr/routes/journeys/request-report/tests.cy.js.map +2 -2
  52. package/dpr/routes/journeys/request-report/tests.cy.ts +22 -1
  53. package/package.json +1 -1
@@ -144,31 +144,31 @@ describe('AsyncRequestListUtils', () => {
144
144
  expect(result.meta?.length).toEqual(7)
145
145
 
146
146
  const v1Ready = <NodeJS.Dict<string>[]>result.tableData.rows[0]
147
- expect(v1Ready[3]!['html']).toContain(
147
+ expect(v1Ready[3]['html']).toContain(
148
148
  'http://localhost:3010/embedded/platform/dpr/view-report/async/report/request-examples/request-example-success/tblId_1729765628165/report',
149
149
  )
150
- expect(v1Ready[2]!['html']).toContain('FINISHED')
150
+ expect(v1Ready[2]['html']).toContain('FINISHED')
151
151
 
152
152
  const v1Failed = <NodeJS.Dict<string>[]>result.tableData.rows[1]
153
153
  const v1FailedRetryUrl =
154
154
  'http://localhost:3010/embedded/platform/async/report/request-examples/request-example-fail-status/request/exId_238947923'
155
- expect(v1Failed[2]!['html']).toContain('FAILED')
156
- expect(v1Failed[3]!['html']).toContain(v1FailedRetryUrl)
157
- expect(v1Failed[3]!['html']).toContain('remove')
155
+ expect(v1Failed[2]['html']).toContain('FAILED')
156
+ expect(v1Failed[3]['html']).toContain(v1FailedRetryUrl)
157
+ expect(v1Failed[3]['html']).toContain('remove')
158
158
 
159
159
  const v1Expired = <NodeJS.Dict<string>[]>result.tableData.rows[2]
160
160
  const v1ExpiredRetryUrl =
161
161
  'http://localhost:3010/embedded/platform/async/report/request-examples/request-example-expire/request?filters.field1=value1.3&filters.field3.start=2003-02-01&filters.field3.end=2006-05-04&sortColumn=field1&sortedAsc=true&filters.field2=value2.1'
162
- expect(v1Expired[2]!['html']).toContain('EXPIRED')
163
- expect(v1Expired[3]!['html']).toContain(v1ExpiredRetryUrl)
164
- expect(v1Expired[3]!['html']).toContain('remove')
162
+ expect(v1Expired[2]['html']).toContain('EXPIRED')
163
+ expect(v1Expired[3]['html']).toContain(v1ExpiredRetryUrl)
164
+ expect(v1Expired[3]['html']).toContain('remove')
165
165
 
166
166
  const v1Aborted = <NodeJS.Dict<string>[]>result.tableData.rows[3]
167
167
  const v1AbortedRetryUrl =
168
168
  'http://localhost:3010/embedded/platform/async/report/request-examples/request-example-success/request?filters.field1=value1.1&filters.field2=value2.3&filters.field3.start=2003-02-01&filters.field3.end=2006-05-04&filters.field7=2007-05-04&sortColumn=field1&sortedAsc=true&filters.field6=Value+6.1'
169
- expect(v1Aborted[2]!['html']).toContain('ABORTED')
170
- expect(v1Aborted[3]!['html']).toContain(v1AbortedRetryUrl)
171
- expect(v1Aborted[3]!['html']).toContain('remove')
169
+ expect(v1Aborted[2]['html']).toContain('ABORTED')
170
+ expect(v1Aborted[3]['html']).toContain(v1AbortedRetryUrl)
171
+ expect(v1Aborted[3]['html']).toContain('remove')
172
172
  })
173
173
 
174
174
  it('should return the render list with dashboards', async () => {
@@ -185,24 +185,24 @@ describe('AsyncRequestListUtils', () => {
185
185
  expect(result.meta?.length).toEqual(7)
186
186
 
187
187
  const v2Ready = <NodeJS.Dict<string>[]>result.tableData.rows[4]
188
- expect(v2Ready[3]!['html']).toContain(
188
+ expect(v2Ready[3]['html']).toContain(
189
189
  'http://localhost:3010/embedded/platform/async/dashboard/request-examples/test-dashboard-1/request/exId_238947923',
190
190
  )
191
- expect(v2Ready[2]!['html']).toContain('SUBMITTED')
191
+ expect(v2Ready[2]['html']).toContain('SUBMITTED')
192
192
 
193
193
  const v2Failed = <NodeJS.Dict<string>[]>result.tableData.rows[5]
194
194
  const v2FailedRetryUrl =
195
195
  'http://localhost:3010/embedded/platform/async/dashboard/request-examples/test-dashboard-2/request/exId_238947923'
196
- expect(v2Failed[2]!['html']).toContain('FAILED')
197
- expect(v2Failed[3]!['html']).toContain(v2FailedRetryUrl)
198
- expect(v2Failed[3]!['html']).toContain('remove')
196
+ expect(v2Failed[2]['html']).toContain('FAILED')
197
+ expect(v2Failed[3]['html']).toContain(v2FailedRetryUrl)
198
+ expect(v2Failed[3]['html']).toContain('remove')
199
199
 
200
200
  const v2Expired = <NodeJS.Dict<string>[]>result.tableData.rows[6]
201
201
  const v2ExpiredRetryUrl =
202
202
  'http://localhost:3010/embedded/platform/async/dashboard/request-examples/test-dashboard-3/request'
203
- expect(v2Expired[2]!['html']).toContain('EXPIRED')
204
- expect(v2Expired[3]!['html']).toContain(v2ExpiredRetryUrl)
205
- expect(v2Expired[3]!['html']).toContain('remove')
203
+ expect(v2Expired[2]['html']).toContain('EXPIRED')
204
+ expect(v2Expired[3]['html']).toContain(v2ExpiredRetryUrl)
205
+ expect(v2Expired[3]['html']).toContain('remove')
206
206
  })
207
207
  })
208
208
 
@@ -221,17 +221,17 @@ describe('AsyncRequestListUtils', () => {
221
221
  expect(result.meta?.length).toEqual(2)
222
222
 
223
223
  const v1Ready = <NodeJS.Dict<string>[]>result.tableData.rows[0]
224
- expect(v1Ready[3]!['html']).toContain(
224
+ expect(v1Ready[3]['html']).toContain(
225
225
  'http://localhost:3010/embedded/platform/async/report/request-examples/request-example-success/request/tblId_1729766362362/report',
226
226
  )
227
- expect(v1Ready[2]!['html']).toContain('READY')
227
+ expect(v1Ready[2]['html']).toContain('READY')
228
228
 
229
229
  const v1Expired = <NodeJS.Dict<string>[]>result.tableData.rows[1]
230
230
  const v1ExpiredRetryUrl =
231
231
  'http://localhost:3010/embedded/platform/async/report/request-examples/request-example-success/request?filters.field2=value2.3&filters.field3.start=2003-09-05&filters.field3.end=2007-05-01&filters.field7=2007-05-04&sortColumn=field1&sortedAsc=true&filters.field4=Inigo+Montoya'
232
- expect(v1Expired[2]!['html']).toContain('EXPIRED')
233
- expect(v1Expired[3]!['html']).toContain(v1ExpiredRetryUrl)
234
- expect(v1Expired[3]!['html']).toContain('remove')
232
+ expect(v1Expired[2]['html']).toContain('EXPIRED')
233
+ expect(v1Expired[3]['html']).toContain(v1ExpiredRetryUrl)
234
+ expect(v1Expired[3]['html']).toContain('remove')
235
235
  })
236
236
  })
237
237
  })
@@ -311,6 +311,7 @@ export const updateExpiredStatus = async ({ req, res, services }: AsyncReportUti
311
311
 
312
312
  export const init = async ({ services, res, maxRows = 6 }: { services: Services; res: Response; maxRows?: number }) => {
313
313
  const { requestedReports, recentlyViewedReports, bookmarkingEnabled } = LocalsHelper.getValues(res)
314
+
314
315
  const requestedReportsList = await renderList({
315
316
  res,
316
317
  reportsData: requestedReports,
@@ -318,6 +319,7 @@ export const init = async ({ services, res, maxRows = 6 }: { services: Services;
318
319
  maxRows,
319
320
  type: 'requested',
320
321
  })
322
+
321
323
  const viewedReportsList = await renderList({
322
324
  res,
323
325
  reportsData: recentlyViewedReports,
@@ -11,7 +11,8 @@ class DprRecentlyViewedList extends DprPollingStatusClass {
11
11
  this.POLLING_FREQUENCY = '60000' // 1 min
12
12
 
13
13
  this.viewedList = document.getElementById('dpr-recently-viewed-component')
14
- this.viewedReportData = this.viewedList.getAttribute('data-request-data')
14
+ const viewedReportData = this.viewedList.getAttribute('data-request-data')
15
+ this.viewedReportData = viewedReportData ? JSON.parse(viewedReportData) : undefined
15
16
  this.csrfToken = this.viewedList.getAttribute('data-csrf-token')
16
17
  this.removeActions = document.querySelectorAll('.dpr-remove-viewed-report-button')
17
18
 
@@ -31,7 +32,7 @@ class DprRecentlyViewedList extends DprPollingStatusClass {
31
32
 
32
33
  async checkIsExpired() {
33
34
  await Promise.all(
34
- JSON.parse(this.viewedReportData).map(async (metaData) => {
35
+ this.viewedReportData.map(async (metaData) => {
35
36
  const { status, reportUrl } = metaData
36
37
  if (status !== 'EXPIRED') {
37
38
  const response = await this.getExpiredStatus(reportUrl, metaData, this.csrfToken)
@@ -57,7 +58,7 @@ class DprRecentlyViewedList extends DprPollingStatusClass {
57
58
  async removeItemFromList(executionId) {
58
59
  let response
59
60
  await fetch(`dpr/my-reports/recently-viewed/${executionId}`, {
60
- method: 'delete',
61
+ method: 'post',
61
62
  headers: {
62
63
  Accept: 'application/json',
63
64
  'Content-Type': 'application/json',
@@ -1,2 +1,2 @@
1
- "use strict";var y=Object.create;var d=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var F=(t,e)=>{for(var o in e)d(t,o,{get:e[o],enumerable:!0})},P=(t,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of w(e))!v.call(t,r)&&r!==o&&d(t,r,{get:()=>e[r],enumerable:!(i=E(e,r))||i.enumerable});return t};var S=(t,e,o)=>(o=t!=null?y(C(t)):{},P(e||!t||!t.__esModule?d(o,"default",{value:t,enumerable:!0}):o,t)),V=t=>P(d({},"__esModule",{value:!0}),t);var B={};F(B,{default:()=>A,errorRequestHandler:()=>h,populateDefinitions:()=>b,populateRequestedReports:()=>k,setupResources:()=>D});module.exports=V(B);var c=S(require("../utils/definitionUtils")),m=S(require("../utils/localsHelper"));const H=(t,e)=>t[e]?t[e].toString():null,Q=t=>H(t,"dataProductDefinitionsPath"),x=t=>{const e=Q(t);return e||null},h=t=>(e,o,i,r)=>e.status===401||e.status===403?i.render("dpr/routes/authError.njk",{layoutPath:t,message:"Sorry, there is a problem with authenticating your request"}):e.status>=400?i.render("dpr/routes/serviceProblem.njk",{layoutPath:t}):r(),D=(t,e,o)=>async(i,r,a)=>{I(i,r);try{return await b(t,i,r,o),await k(t,r),a()}catch(s){return h(e)(s,i,r,a)}},I=(t,e)=>{const o=t.flash("DPR_ERRORS");o&&o[0]&&(e.locals.validationErrors=JSON.parse(o[0]))},b=async(t,e,o,i)=>{const{token:r,dprUser:a}=m.default.getValues(o),s=x(e.query),n=e.body?.dataProductDefinitionsPath,l=s||n;l&&(o.locals.dpdPathFromQuery=!0);const g=i?.dataProductDefinitionsPath;g&&(o.locals.dpdPathFromConfig=!0),o.locals.definitionsPath=l||g,o.locals.pathSuffix=`?dataProductDefinitionsPath=${o.locals.definitionsPath}`;let u;r&&(u=await t.productCollectionStoreService.getSelectedProductCollectionId(a.id)),o.locals.definitions=await Promise.all([t.reportingService.getDefinitions(r,o.locals.definitionsPath),u&&t.productCollectionService.getProductCollection(r,u)]).then(([R,p])=>{if(p&&p){const q=p.products.map(f=>f.productId);return R.filter(f=>q.includes(f.id))}return R})??[]},k=async(t,e)=>{const{dprUser:o}=m.default.getValues(e);if(o.id){const{definitions:i,definitionsPath:r}=e.locals,a=await t.requestedReportService.getAllReports(o.id);e.locals.requestedReports=r?a.filter(n=>c.default.getCurrentVariantDefinition(i,n.reportId,n.id)):a;const s=await t.recentlyViewedService.getAllReports(o.id);if(e.locals.recentlyViewedReports=r?s.filter(n=>c.default.getCurrentVariantDefinition(i,n.reportId,n.id)):s,e.locals.downloadingEnabled=t.downloadPermissionService.enabled,e.locals.bookmarkingEnabled=t.bookmarkService.enabled,e.locals.collectionsEnabled=t.productCollectionService.enabled,e.locals.requestMissingEnabled=t.missingReportService.enabled,e.locals.saveDefaultsEnabled=t.defaultFilterValuesService.enabled,e.locals.bookmarkingEnabled){const n=await t.bookmarkService.getAllBookmarks(o.id);e.locals.bookmarks=r?n.filter(l=>c.default.getCurrentVariantDefinition(i,l.reportId,l.id)):n}}};var A=D;0&&(module.exports={errorRequestHandler,populateDefinitions,populateRequestedReports,setupResources});
1
+ "use strict";var y=Object.create;var d=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var F=(t,e)=>{for(var o in e)d(t,o,{get:e[o],enumerable:!0})},P=(t,e,o,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of w(e))!v.call(t,r)&&r!==o&&d(t,r,{get:()=>e[r],enumerable:!(i=E(e,r))||i.enumerable});return t};var S=(t,e,o)=>(o=t!=null?y(C(t)):{},P(e||!t||!t.__esModule?d(o,"default",{value:t,enumerable:!0}):o,t)),V=t=>P(d({},"__esModule",{value:!0}),t);var B={};F(B,{default:()=>A,errorRequestHandler:()=>h,populateDefinitions:()=>b,populateRequestedReports:()=>k,setupResources:()=>D});module.exports=V(B);var c=S(require("../utils/definitionUtils")),m=S(require("../utils/localsHelper"));const H=(t,e)=>t[e]?t[e].toString():null,Q=t=>H(t,"dataProductDefinitionsPath"),x=t=>{const e=Q(t);return e||null},h=t=>(e,o,i,r)=>e.status===401||e.status===403?i.render("dpr/routes/authError.njk",{layoutPath:t,message:"Sorry, there is a problem with authenticating your request"}):e.status>=400?i.render("dpr/routes/serviceProblem.njk",{layoutPath:t}):r(),D=(t,e,o)=>async(i,r,a)=>{I(i,r);try{return await b(t,i,r,o),await k(t,r),a()}catch(s){return h(e)(s,i,r,a)}},I=(t,e)=>{const o=t.flash("DPR_ERRORS");o&&o[0]&&(e.locals.validationErrors=JSON.parse(o[0]))},b=async(t,e,o,i)=>{const{token:r,dprUser:a}=m.default.getValues(o),s=x(e.query),n=e.body?.dataProductDefinitionsPath,l=s||n;l&&(o.locals.dpdPathFromQuery=!0);const R=i?.dataProductDefinitionsPath;R&&(o.locals.dpdPathFromConfig=!0),o.locals.definitionsPath=l||R,o.locals.pathSuffix=`?dataProductDefinitionsPath=${o.locals.definitionsPath}`;let u;r&&(u=await t.productCollectionStoreService.getSelectedProductCollectionId(a.id)),o.locals.definitions=await Promise.all([t.reportingService.getDefinitions(r,o.locals.definitionsPath),u&&t.productCollectionService.getProductCollection(r,u)]).then(([g,p])=>{if(p&&p){const q=p.products.map(f=>f.productId);return g.filter(f=>q.includes(f.id))}return g})??[]},k=async(t,e)=>{const{dprUser:o}=m.default.getValues(e);if(o.id){const{definitions:i,definitionsPath:r}=e.locals,a=await t.recentlyViewedService.getAllReports(o.id);await t.requestedReportService.cleanList(o.id,a);const s=await t.requestedReportService.getAllReports(o.id);if(e.locals.requestedReports=r?s.filter(n=>c.default.getCurrentVariantDefinition(i,n.reportId,n.id)):s,e.locals.recentlyViewedReports=r?a.filter(n=>c.default.getCurrentVariantDefinition(i,n.reportId,n.id)):a,e.locals.downloadingEnabled=t.downloadPermissionService.enabled,e.locals.bookmarkingEnabled=t.bookmarkService.enabled,e.locals.collectionsEnabled=t.productCollectionService.enabled,e.locals.requestMissingEnabled=t.missingReportService.enabled,e.locals.saveDefaultsEnabled=t.defaultFilterValuesService.enabled,e.locals.bookmarkingEnabled){const n=await t.bookmarkService.getAllBookmarks(o.id);e.locals.bookmarks=r?n.filter(l=>c.default.getCurrentVariantDefinition(i,l.reportId,l.id)):n}}};var A=D;0&&(module.exports={errorRequestHandler,populateDefinitions,populateRequestedReports,setupResources});
2
2
  //# sourceMappingURL=setUpDprResources.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/dpr/middleware/setUpDprResources.ts"],
4
- "sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { RequestHandler, Response, Request, ErrorRequestHandler, NextFunction } from 'express'\nimport type { ParsedQs } from 'qs'\nimport { HTTPError } from 'superagent'\nimport { Services } from '../types/Services'\nimport { RequestedReport, StoredReportData } from '../types/UserReports'\nimport DefinitionUtils from '../utils/definitionUtils'\nimport { BookmarkStoreData } from '../types/Bookmark'\nimport { DprConfig } from '../types/DprConfig'\nimport localsHelper from '../utils/localsHelper'\n\nconst getQueryParamAsString = (query: ParsedQs, name: string) => (query[name] ? query[name].toString() : null)\nconst getDefinitionsPath = (query: ParsedQs) => getQueryParamAsString(query, 'dataProductDefinitionsPath')\n\nconst deriveDefinitionsPath = (query: ParsedQs): string | null => {\n const definitionsPath = getDefinitionsPath(query)\n if (definitionsPath) {\n return definitionsPath\n }\n\n return null\n}\n\nexport const errorRequestHandler =\n (layoutPath: string): ErrorRequestHandler =>\n (error: HTTPError, _req: Request, res: Response, next: NextFunction) => {\n if (error.status === 401 || error.status === 403) {\n return res.render('dpr/routes/authError.njk', {\n layoutPath,\n message: 'Sorry, there is a problem with authenticating your request',\n })\n }\n if (error.status >= 400) {\n return res.render('dpr/routes/serviceProblem.njk', {\n layoutPath,\n })\n }\n return next()\n }\n\nexport const setupResources = (services: Services, layoutPath: string, config?: DprConfig): RequestHandler => {\n return async (req, res, next) => {\n populateValidationErrors(req, res)\n try {\n await populateDefinitions(services, req, res, config)\n await populateRequestedReports(services, res)\n return next()\n } catch (error) {\n return errorRequestHandler(layoutPath)(error, req, res, next)\n }\n }\n}\n\nconst populateValidationErrors = (req: Request, res: Response) => {\n const errors = req.flash(`DPR_ERRORS`)\n if (errors && errors[0]) {\n res.locals['validationErrors'] = JSON.parse(errors[0])\n }\n}\n\nexport const populateDefinitions = async (services: Services, req: Request, res: Response, config?: DprConfig) => {\n // Get the DPD path from the query\n const { token, dprUser } = localsHelper.getValues(res)\n\n const dpdPathFromQuery = deriveDefinitionsPath(req.query)\n const dpdPathFromBody = req.body?.dataProductDefinitionsPath\n const definitionsPathFromQuery = dpdPathFromQuery || dpdPathFromBody\n\n if (definitionsPathFromQuery) {\n res.locals['dpdPathFromQuery'] = true\n }\n\n // Get the DPD path from the config\n const dpdPathFromConfig = config?.dataProductDefinitionsPath\n if (dpdPathFromConfig) {\n res.locals['dpdPathFromConfig'] = true\n }\n\n // query takes presedence over config\n res.locals['definitionsPath'] = definitionsPathFromQuery || dpdPathFromConfig\n res.locals['pathSuffix'] = `?dataProductDefinitionsPath=${res.locals['definitionsPath']}`\n\n let selectedProductCollectionId: string | undefined\n if (token) {\n selectedProductCollectionId = await services.productCollectionStoreService.getSelectedProductCollectionId(\n dprUser.id,\n )\n }\n\n res.locals['definitions'] =\n (await Promise.all([\n services.reportingService.getDefinitions(token, res.locals['definitionsPath']),\n selectedProductCollectionId &&\n services.productCollectionService.getProductCollection(token, selectedProductCollectionId),\n ]).then(([defs, selectedProductCollection]) => {\n if (selectedProductCollection && selectedProductCollection) {\n const productIds = selectedProductCollection.products.map((product) => product.productId)\n return defs.filter((def) => productIds.includes(def.id))\n }\n return defs\n })) ?? []\n}\n\nexport const populateRequestedReports = async (services: Services, res: Response) => {\n const { dprUser } = localsHelper.getValues(res)\n if (dprUser.id) {\n const { definitions, definitionsPath } = res.locals\n\n const requested = await services.requestedReportService.getAllReports(dprUser.id)\n res.locals['requestedReports'] = !definitionsPath\n ? requested\n : requested.filter((report: RequestedReport) => {\n return DefinitionUtils.getCurrentVariantDefinition(definitions, report.reportId, report.id)\n })\n\n const recent = await services.recentlyViewedService.getAllReports(dprUser.id)\n res.locals['recentlyViewedReports'] = !definitionsPath\n ? recent\n : recent.filter((report: StoredReportData) => {\n return DefinitionUtils.getCurrentVariantDefinition(definitions, report.reportId, report.id)\n })\n\n res.locals['downloadingEnabled'] = services.downloadPermissionService.enabled\n res.locals['bookmarkingEnabled'] = services.bookmarkService.enabled\n res.locals['collectionsEnabled'] = services.productCollectionService.enabled\n res.locals['requestMissingEnabled'] = services.missingReportService.enabled\n res.locals['saveDefaultsEnabled'] = services.defaultFilterValuesService.enabled\n\n if (res.locals['bookmarkingEnabled']) {\n const bookmarks = await services.bookmarkService.getAllBookmarks(dprUser.id)\n res.locals['bookmarks'] = !definitionsPath\n ? bookmarks\n : bookmarks.filter((bookmark: BookmarkStoreData) => {\n return DefinitionUtils.getCurrentVariantDefinition(definitions, bookmark.reportId, bookmark.id)\n })\n }\n }\n}\n\nexport default setupResources\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,wBAAAC,EAAA,wBAAAC,EAAA,6BAAAC,EAAA,mBAAAC,IAAA,eAAAC,EAAAP,GAMA,IAAAQ,EAA4B,uCAG5BC,EAAyB,oCAEzB,MAAMC,EAAwB,CAACC,EAAiBC,IAAkBD,EAAMC,CAAI,EAAID,EAAMC,CAAI,EAAE,SAAS,EAAI,KACnGC,EAAsBF,GAAoBD,EAAsBC,EAAO,4BAA4B,EAEnGG,EAAyBH,GAAmC,CAChE,MAAMI,EAAkBF,EAAmBF,CAAK,EAChD,OAAII,GAIG,IACT,EAEaZ,EACVa,GACD,CAACC,EAAkBC,EAAeC,EAAeC,IAC3CH,EAAM,SAAW,KAAOA,EAAM,SAAW,IACpCE,EAAI,OAAO,2BAA4B,CAC5C,WAAAH,EACA,QAAS,4DACX,CAAC,EAECC,EAAM,QAAU,IACXE,EAAI,OAAO,gCAAiC,CACjD,WAAAH,CACF,CAAC,EAEII,EAAK,EAGHd,EAAiB,CAACe,EAAoBL,EAAoBM,IAC9D,MAAOC,EAAKJ,EAAKC,IAAS,CAC/BI,EAAyBD,EAAKJ,CAAG,EACjC,GAAI,CACF,aAAMf,EAAoBiB,EAAUE,EAA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C,CACZ,EAEa7B,EAA2B,MAAOgB,EAAoBF,IAAkB,CACnF,KAAM,CAAE,QAAAQ,CAAQ,EAAI,EAAAC,QAAa,UAAUT,CAAG,EAC9C,GAAIQ,EAAQ,GAAI,CACd,KAAM,CAAE,YAAAY,EAAa,gBAAAxB,CAAgB,EAAII,EAAI,OAEvCqB,EAAY,MAAMnB,EAAS,uBAAuB,cAAcM,EAAQ,EAAE,EAChFR,EAAI,OAAO,iBAAuBJ,EAE9ByB,EAAU,OAAQC,GACT,EAAAC,QAAgB,4BAA4BH,EAAaE,EAAO,SAAUA,EAAO,EAAE,CAC3F,EAHDD,EAKJ,MAAMG,EAAS,MAAMtB,EAAS,sBAAsB,cAAcM,EAAQ,EAAE,EAa5E,GAZAR,EAAI,OAAO,sBAA4BJ,EAEnC4B,EAAO,OAAQF,GACN,EAAAC,QAAgB,4BAA4BH,EAAaE,EAAO,SAAUA,EAAO,EAAE,CAC3F,EAHDE,EAKJxB,EAAI,OAAO,mBAAwBE,EAAS,0BAA0B,QACtEF,EAAI,OAAO,mBAAwBE,EAAS,gBAAgB,QAC5DF,EAAI,OAAO,mBAAwBE,EAAS,yBAAyB,QACrEF,EAAI,OAAO,sBAA2BE,EAAS,qBAAqB,QACpEF,EAAI,OAAO,oBAAyBE,EAAS,2BAA2B,QAEpEF,EAAI,OAAO,mBAAuB,CACpC,MAAMyB,EAAY,MAAMvB,EAAS,gBAAgB,gBAAgBM,EAAQ,EAAE,EAC3ER,EAAI,OAAO,UAAgBJ,EAEvB6B,EAAU,OAAQC,GACT,EAAAH,QAAgB,4BAA4BH,EAAaM,EAAS,SAAUA,EAAS,EAAE,CAC/F,EAHDD,CAIN,CACF,CACF,EAEA,IAAO1C,EAAQI",
6
- "names": ["setUpDprResources_exports", "__export", "setUpDprResources_default", "errorRequestHandler", "populateDefinitions", "populateRequestedReports", "setupResources", "__toCommonJS", "import_definitionUtils", "import_localsHelper", "getQueryParamAsString", "query", "name", "getDefinitionsPath", "deriveDefinitionsPath", "definitionsPath", "layoutPath", "error", "_req", "res", "next", "services", "config", "req", "populateValidationErrors", "errors", "token", "dprUser", "localsHelper", "dpdPathFromQuery", "dpdPathFromBody", "definitionsPathFromQuery", "dpdPathFromConfig", "selectedProductCollectionId", "defs", "selectedProductCollection", "productIds", "product", "def", "definitions", "requested", "report", "DefinitionUtils", "recent", "bookmarks", "bookmark"]
4
+ "sourcesContent": ["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport { RequestHandler, Response, Request, ErrorRequestHandler, NextFunction } from 'express'\nimport type { ParsedQs } from 'qs'\nimport { HTTPError } from 'superagent'\nimport { Services } from '../types/Services'\nimport { RequestedReport, StoredReportData } from '../types/UserReports'\nimport DefinitionUtils from '../utils/definitionUtils'\nimport { BookmarkStoreData } from '../types/Bookmark'\nimport { DprConfig } from '../types/DprConfig'\nimport localsHelper from '../utils/localsHelper'\n\nconst getQueryParamAsString = (query: ParsedQs, name: string) => (query[name] ? query[name].toString() : null)\nconst getDefinitionsPath = (query: ParsedQs) => getQueryParamAsString(query, 'dataProductDefinitionsPath')\n\nconst deriveDefinitionsPath = (query: ParsedQs): string | null => {\n const definitionsPath = getDefinitionsPath(query)\n if (definitionsPath) {\n return definitionsPath\n }\n\n return null\n}\n\nexport const errorRequestHandler =\n (layoutPath: string): ErrorRequestHandler =>\n (error: HTTPError, _req: Request, res: Response, next: NextFunction) => {\n if (error.status === 401 || error.status === 403) {\n return res.render('dpr/routes/authError.njk', {\n layoutPath,\n message: 'Sorry, there is a problem with authenticating your request',\n })\n }\n if (error.status >= 400) {\n return res.render('dpr/routes/serviceProblem.njk', {\n layoutPath,\n })\n }\n return next()\n }\n\nexport const setupResources = (services: Services, layoutPath: string, config?: DprConfig): RequestHandler => {\n return async (req, res, next) => {\n populateValidationErrors(req, res)\n try {\n await populateDefinitions(services, req, res, config)\n await populateRequestedReports(services, res)\n return next()\n } catch (error) {\n return errorRequestHandler(layoutPath)(error, req, res, next)\n }\n }\n}\n\nconst populateValidationErrors = (req: Request, res: Response) => {\n const errors = req.flash(`DPR_ERRORS`)\n if (errors && errors[0]) {\n res.locals['validationErrors'] = JSON.parse(errors[0])\n }\n}\n\nexport const populateDefinitions = async (services: Services, req: Request, res: Response, config?: DprConfig) => {\n // Get the DPD path from the query\n const { token, dprUser } = localsHelper.getValues(res)\n\n const dpdPathFromQuery = deriveDefinitionsPath(req.query)\n const dpdPathFromBody = req.body?.dataProductDefinitionsPath\n const definitionsPathFromQuery = dpdPathFromQuery || dpdPathFromBody\n\n if (definitionsPathFromQuery) {\n res.locals['dpdPathFromQuery'] = true\n }\n\n // Get the DPD path from the config\n const dpdPathFromConfig = config?.dataProductDefinitionsPath\n if (dpdPathFromConfig) {\n res.locals['dpdPathFromConfig'] = true\n }\n\n // query takes presedence over config\n res.locals['definitionsPath'] = definitionsPathFromQuery || dpdPathFromConfig\n res.locals['pathSuffix'] = `?dataProductDefinitionsPath=${res.locals['definitionsPath']}`\n\n let selectedProductCollectionId: string | undefined\n if (token) {\n selectedProductCollectionId = await services.productCollectionStoreService.getSelectedProductCollectionId(\n dprUser.id,\n )\n }\n\n res.locals['definitions'] =\n (await Promise.all([\n services.reportingService.getDefinitions(token, res.locals['definitionsPath']),\n selectedProductCollectionId &&\n services.productCollectionService.getProductCollection(token, selectedProductCollectionId),\n ]).then(([defs, selectedProductCollection]) => {\n if (selectedProductCollection && selectedProductCollection) {\n const productIds = selectedProductCollection.products.map((product) => product.productId)\n return defs.filter((def) => productIds.includes(def.id))\n }\n return defs\n })) ?? []\n}\n\nexport const populateRequestedReports = async (services: Services, res: Response) => {\n const { dprUser } = localsHelper.getValues(res)\n if (dprUser.id) {\n const { definitions, definitionsPath } = res.locals\n\n const recent = await services.recentlyViewedService.getAllReports(dprUser.id)\n await services.requestedReportService.cleanList(dprUser.id, recent)\n const requested = await services.requestedReportService.getAllReports(dprUser.id)\n\n res.locals['requestedReports'] = !definitionsPath\n ? requested\n : requested.filter((report: RequestedReport) => {\n return DefinitionUtils.getCurrentVariantDefinition(definitions, report.reportId, report.id)\n })\n\n res.locals['recentlyViewedReports'] = !definitionsPath\n ? recent\n : recent.filter((report: StoredReportData) => {\n return DefinitionUtils.getCurrentVariantDefinition(definitions, report.reportId, report.id)\n })\n\n res.locals['downloadingEnabled'] = services.downloadPermissionService.enabled\n res.locals['bookmarkingEnabled'] = services.bookmarkService.enabled\n res.locals['collectionsEnabled'] = services.productCollectionService.enabled\n res.locals['requestMissingEnabled'] = services.missingReportService.enabled\n res.locals['saveDefaultsEnabled'] = services.defaultFilterValuesService.enabled\n\n if (res.locals['bookmarkingEnabled']) {\n const bookmarks = await services.bookmarkService.getAllBookmarks(dprUser.id)\n res.locals['bookmarks'] = !definitionsPath\n ? bookmarks\n : bookmarks.filter((bookmark: BookmarkStoreData) => {\n return DefinitionUtils.getCurrentVariantDefinition(definitions, bookmark.reportId, bookmark.id)\n })\n }\n }\n}\n\nexport default setupResources\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,wBAAAC,EAAA,wBAAAC,EAAA,6BAAAC,EAAA,mBAAAC,IAAA,eAAAC,EAAAP,GAMA,IAAAQ,EAA4B,uCAG5BC,EAAyB,oCAEzB,MAAMC,EAAwB,CAACC,EAAiBC,IAAkBD,EAAMC,CAAI,EAAID,EAAMC,CAAI,EAAE,SAAS,EAAI,KACnGC,EAAsBF,GAAoBD,EAAsBC,EAAO,4BAA4B,EAEnGG,EAAyBH,GAAmC,CAChE,MAAMI,EAAkBF,EAAmBF,CAAK,EAChD,OAAII,GAIG,IACT,EAEaZ,EACVa,GACD,CAACC,EAAkBC,EAAeC,EAAeC,IAC3CH,EAAM,SAAW,KAAOA,EAAM,SAAW,IACpCE,EAAI,OAAO,2BAA4B,CAC5C,WAAAH,EACA,QAAS,4DACX,CAAC,EAECC,EAAM,QAAU,IACXE,EAAI,OAAO,gCAAiC,CACjD,WAAAH,CACF,CAAC,EAEII,EAAK,EAGHd,EAAiB,CAACe,E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,CACF,EAEA,IAAO1C,EAAQI",
6
+ "names": ["setUpDprResources_exports", "__export", "setUpDprResources_default", "errorRequestHandler", "populateDefinitions", "populateRequestedReports", "setupResources", "__toCommonJS", "import_definitionUtils", "import_localsHelper", "getQueryParamAsString", "query", "name", "getDefinitionsPath", "deriveDefinitionsPath", "definitionsPath", "layoutPath", "error", "_req", "res", "next", "services", "config", "req", "populateValidationErrors", "errors", "token", "dprUser", "localsHelper", "dpdPathFromQuery", "dpdPathFromBody", "definitionsPathFromQuery", "dpdPathFromConfig", "selectedProductCollectionId", "defs", "selectedProductCollection", "productIds", "product", "def", "definitions", "recent", "requested", "report", "DefinitionUtils", "bookmarks", "bookmark"]
7
7
  }
@@ -31,6 +31,7 @@ describe('setUpDprResources', () => {
31
31
  beforeEach(() => {
32
32
  requestedReportService = {
33
33
  getAllReports: jest.fn().mockReturnValueOnce([]),
34
+ cleanList: jest.fn(),
34
35
  } as unknown as RequestedReportService
35
36
 
36
37
  recentlyViewedService = {
@@ -106,14 +106,16 @@ export const populateRequestedReports = async (services: Services, res: Response
106
106
  if (dprUser.id) {
107
107
  const { definitions, definitionsPath } = res.locals
108
108
 
109
+ const recent = await services.recentlyViewedService.getAllReports(dprUser.id)
110
+ await services.requestedReportService.cleanList(dprUser.id, recent)
109
111
  const requested = await services.requestedReportService.getAllReports(dprUser.id)
112
+
110
113
  res.locals['requestedReports'] = !definitionsPath
111
114
  ? requested
112
115
  : requested.filter((report: RequestedReport) => {
113
116
  return DefinitionUtils.getCurrentVariantDefinition(definitions, report.reportId, report.id)
114
117
  })
115
118
 
116
- const recent = await services.recentlyViewedService.getAllReports(dprUser.id)
117
119
  res.locals['recentlyViewedReports'] = !definitionsPath
118
120
  ? recent
119
121
  : recent.filter((report: StoredReportData) => {
@@ -1,2 +1,2 @@
1
- "use strict";var m=Object.create;var a=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var k=Object.getOwnPropertyNames;var v=Object.getPrototypeOf,u=Object.prototype.hasOwnProperty;var y=(o,e)=>{for(var r in e)a(o,r,{get:e[r],enumerable:!0})},n=(o,e,r,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let t of k(e))!u.call(o,t)&&t!==r&&a(o,t,{get:()=>e[t],enumerable:!(s=p(e,t))||s.enumerable});return o};var h=(o,e,r)=>(r=o!=null?m(v(o)):{},n(e||!o||!o.__esModule?a(r,"default",{value:o,enumerable:!0}):r,o)),S=o=>n(a({},"__esModule",{value:!0}),o);var f={};y(f,{BookmarkController:()=>d,default:()=>b});module.exports=S(f);var c=h(require("../../../../utils/localsHelper"));class d{constructor(e,r){this.POST=async(e,r)=>{const{dprUser:s}=c.default.getValues(r),{reportId:t,id:i,reportType:l}=e.body;await this.services.bookmarkService.addBookmark(s.id,t,i,l),r.end()};this.DELETE=async(e,r)=>{const{dprUser:s}=c.default.getValues(r),{id:t,reportId:i}=e.body;await this.services.bookmarkService.removeBookmark(s.id,t,i),r.end()};this.layoutPath=e,this.services=r}}var b=d;0&&(module.exports={BookmarkController});
1
+ "use strict";var k=Object.create;var i=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var u=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var y=(e,r)=>{for(var o in r)i(e,o,{get:r[o],enumerable:!0})},d=(e,r,o,s)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of v(r))!h.call(e,t)&&t!==o&&i(e,t,{get:()=>r[t],enumerable:!(s=n(r,t))||s.enumerable});return e};var S=(e,r,o)=>(o=e!=null?k(u(e)):{},d(r||!e||!e.__esModule?i(o,"default",{value:e,enumerable:!0}):o,e)),f=e=>d(i({},"__esModule",{value:!0}),e);var g={};y(g,{BookmarkController:()=>a,default:()=>b});module.exports=f(g);var l=S(require("../../../../utils/localsHelper"));class a{constructor(r,o){this.POST=async(r,o)=>{const{dprUser:s}=l.default.getValues(o),{reportId:t,id:c,reportType:m,type:p}=r.body;p==="add"?await this.services.bookmarkService.addBookmark(s.id,t,c,m):await this.services.bookmarkService.removeBookmark(s.id,c,t),o.end()};this.layoutPath=r,this.services=o}}var b=a;0&&(module.exports={BookmarkController});
2
2
  //# sourceMappingURL=controller.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/dpr/routes/journeys/my-reports/bookmarks/controller.ts"],
4
- "sourcesContent": ["import { RequestHandler } from 'express'\nimport { Services } from '../../../../types/Services'\nimport LocalsHelper from '../../../../utils/localsHelper'\n\nclass BookmarkController {\n layoutPath: string\n\n services: Services\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.services = services\n }\n\n POST: RequestHandler = async (req, res) => {\n const { dprUser } = LocalsHelper.getValues(res)\n const { reportId, id, reportType } = req.body\n await this.services.bookmarkService.addBookmark(dprUser.id, reportId, id, reportType)\n res.end()\n }\n\n DELETE: RequestHandler = async (req, res) => {\n const { dprUser } = LocalsHelper.getValues(res)\n const { id, reportId } = req.body\n await this.services.bookmarkService.removeBookmark(dprUser.id, id, reportId)\n res.end()\n }\n}\n\nexport { BookmarkController }\nexport default BookmarkController\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAEA,IAAAK,EAAyB,6CAEzB,MAAMH,CAAmB,CAKvB,YAAYI,EAAoBC,EAAoB,CAKpD,UAAuB,MAAOC,EAAKC,IAAQ,CACzC,KAAM,CAAE,QAAAC,CAAQ,EAAI,EAAAC,QAAa,UAAUF,CAAG,EACxC,CAAE,SAAAG,EAAU,GAAAC,EAAI,WAAAC,CAAW,EAAIN,EAAI,KACzC,MAAM,KAAK,SAAS,gBAAgB,YAAYE,EAAQ,GAAIE,EAAUC,EAAIC,CAAU,EACpFL,EAAI,IAAI,CACV,EAEA,YAAyB,MAAOD,EAAKC,IAAQ,CAC3C,KAAM,CAAE,QAAAC,CAAQ,EAAI,EAAAC,QAAa,UAAUF,CAAG,EACxC,CAAE,GAAAI,EAAI,SAAAD,CAAS,EAAIJ,EAAI,KAC7B,MAAM,KAAK,SAAS,gBAAgB,eAAeE,EAAQ,GAAIG,EAAID,CAAQ,EAC3EH,EAAI,IAAI,CACV,EAhBE,KAAK,WAAaH,EAClB,KAAK,SAAWC,CAClB,CAeF,CAGA,IAAOJ,EAAQD",
6
- "names": ["controller_exports", "__export", "BookmarkController", "controller_default", "__toCommonJS", "import_localsHelper", "layoutPath", "services", "req", "res", "dprUser", "LocalsHelper", "reportId", "id", "reportType"]
4
+ "sourcesContent": ["import { RequestHandler } from 'express'\nimport { Services } from '../../../../types/Services'\nimport LocalsHelper from '../../../../utils/localsHelper'\n\nclass BookmarkController {\n layoutPath: string\n\n services: Services\n\n constructor(layoutPath: string, services: Services) {\n this.layoutPath = layoutPath\n this.services = services\n }\n\n POST: RequestHandler = async (req, res) => {\n const { dprUser } = LocalsHelper.getValues(res)\n const { reportId, id, reportType, type } = req.body\n if (type === 'add') {\n await this.services.bookmarkService.addBookmark(dprUser.id, reportId, id, reportType)\n } else {\n await this.services.bookmarkService.removeBookmark(dprUser.id, id, reportId)\n }\n res.end()\n }\n}\n\nexport { BookmarkController }\nexport default BookmarkController\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,wBAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAEA,IAAAK,EAAyB,6CAEzB,MAAMH,CAAmB,CAKvB,YAAYI,EAAoBC,EAAoB,CAKpD,UAAuB,MAAOC,EAAKC,IAAQ,CACzC,KAAM,CAAE,QAAAC,CAAQ,EAAI,EAAAC,QAAa,UAAUF,CAAG,EACxC,CAAE,SAAAG,EAAU,GAAAC,EAAI,WAAAC,EAAY,KAAAC,CAAK,EAAIP,EAAI,KAC3CO,IAAS,MACX,MAAM,KAAK,SAAS,gBAAgB,YAAYL,EAAQ,GAAIE,EAAUC,EAAIC,CAAU,EAEpF,MAAM,KAAK,SAAS,gBAAgB,eAAeJ,EAAQ,GAAIG,EAAID,CAAQ,EAE7EH,EAAI,IAAI,CACV,EAbE,KAAK,WAAaH,EAClB,KAAK,SAAWC,CAClB,CAYF,CAGA,IAAOJ,EAAQD",
6
+ "names": ["controller_exports", "__export", "BookmarkController", "controller_default", "__toCommonJS", "import_localsHelper", "layoutPath", "services", "req", "res", "dprUser", "LocalsHelper", "reportId", "id", "reportType", "type"]
7
7
  }
@@ -14,15 +14,12 @@ class BookmarkController {
14
14
 
15
15
  POST: RequestHandler = async (req, res) => {
16
16
  const { dprUser } = LocalsHelper.getValues(res)
17
- const { reportId, id, reportType } = req.body
18
- await this.services.bookmarkService.addBookmark(dprUser.id, reportId, id, reportType)
19
- res.end()
20
- }
21
-
22
- DELETE: RequestHandler = async (req, res) => {
23
- const { dprUser } = LocalsHelper.getValues(res)
24
- const { id, reportId } = req.body
25
- await this.services.bookmarkService.removeBookmark(dprUser.id, id, reportId)
17
+ const { reportId, id, reportType, type } = req.body
18
+ if (type === 'add') {
19
+ await this.services.bookmarkService.addBookmark(dprUser.id, reportId, id, reportType)
20
+ } else {
21
+ await this.services.bookmarkService.removeBookmark(dprUser.id, id, reportId)
22
+ }
26
23
  res.end()
27
24
  }
28
25
  }
@@ -1,2 +1,2 @@
1
- "use strict";var f=Object.create;var m=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var S=Object.getPrototypeOf,d=Object.prototype.hasOwnProperty;var g=(r,o)=>{for(var t in o)m(r,t,{get:o[t],enumerable:!0})},i=(r,o,t,e)=>{if(o&&typeof o=="object"||typeof o=="function")for(let s of E(o))!d.call(r,s)&&s!==t&&m(r,s,{get:()=>o[s],enumerable:!(e=a(o,s))||e.enumerable});return r};var n=(r,o,t)=>(t=r!=null?f(S(r)):{},i(o||!r||!r.__esModule?m(t,"default",{value:r,enumerable:!0}):t,r)),k=r=>i(m({},"__esModule",{value:!0}),r);var x={};g(x,{default:()=>v,routes:()=>c});module.exports=k(x);var u=require("express"),l=n(require("./controller")),p=n(require("./list/routes"));function c({layoutPath:r,services:o}){const t=(0,u.Router)({mergeParams:!0}),e=new l.default(r,o);return t.post("/",e.POST),t.delete("/",e.DELETE),t.use("/list",(0,p.default)({layoutPath:r,services:o})),t}var v=c;0&&(module.exports={routes});
1
+ "use strict";var f=Object.create;var m=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var v=(r,o)=>{for(var t in o)m(r,t,{get:o[t],enumerable:!0})},i=(r,o,t,s)=>{if(o&&typeof o=="object"||typeof o=="function")for(let e of S(o))!k.call(r,e)&&e!==t&&m(r,e,{get:()=>o[e],enumerable:!(s=a(o,e))||s.enumerable});return r};var n=(r,o,t)=>(t=r!=null?f(g(r)):{},i(o||!r||!r.__esModule?m(t,"default",{value:r,enumerable:!0}):t,r)),x=r=>i(m({},"__esModule",{value:!0}),r);var R={};v(R,{default:()=>P,routes:()=>c});module.exports=x(R);var u=require("express"),l=n(require("./controller")),p=n(require("./list/routes"));function c({layoutPath:r,services:o}){const t=(0,u.Router)({mergeParams:!0}),s=new l.default(r,o);return t.post("/",s.POST),t.use("/list",(0,p.default)({layoutPath:r,services:o})),t}var P=c;0&&(module.exports={routes});
2
2
  //# sourceMappingURL=routes.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/dpr/routes/journeys/my-reports/bookmarks/routes.ts"],
4
- "sourcesContent": ["/* eslint-disable no-param-reassign */\nimport { Router } from 'express'\nimport { Services } from '../../../../types/Services'\nimport BookmarkController from './controller'\nimport listRoutes from './list/routes'\n\nexport function routes({ layoutPath, services }: { layoutPath: string; services: Services }) {\n const router = Router({ mergeParams: true })\n\n const controller = new BookmarkController(layoutPath, services)\n\n router.post('/', controller.POST)\n router.delete('/', controller.DELETE)\n\n router.use(`/list`, listRoutes({ layoutPath, services }))\n return router\n}\n\nexport default routes\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,WAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAuB,mBAEvBC,EAA+B,2BAC/BC,EAAuB,4BAEhB,SAASJ,EAAO,CAAE,WAAAK,EAAY,SAAAC,CAAS,EAA+C,CAC3F,MAAMC,KAAS,UAAO,CAAE,YAAa,EAAK,CAAC,EAErCC,EAAa,IAAI,EAAAC,QAAmBJ,EAAYC,CAAQ,EAE9D,OAAAC,EAAO,KAAK,IAAKC,EAAW,IAAI,EAChCD,EAAO,OAAO,IAAKC,EAAW,MAAM,EAEpCD,EAAO,IAAI,WAAS,EAAAG,SAAW,CAAE,WAAAL,EAAY,SAAAC,CAAS,CAAC,CAAC,EACjDC,CACT,CAEA,IAAOR,EAAQC",
4
+ "sourcesContent": ["/* eslint-disable no-param-reassign */\nimport { Router } from 'express'\nimport { Services } from '../../../../types/Services'\nimport BookmarkController from './controller'\nimport listRoutes from './list/routes'\n\nexport function routes({ layoutPath, services }: { layoutPath: string; services: Services }) {\n const router = Router({ mergeParams: true })\n\n const controller = new BookmarkController(layoutPath, services)\n router.post('/', controller.POST)\n router.use(`/list`, listRoutes({ layoutPath, services }))\n return router\n}\n\nexport default routes\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,WAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAuB,mBAEvBC,EAA+B,2BAC/BC,EAAuB,4BAEhB,SAASJ,EAAO,CAAE,WAAAK,EAAY,SAAAC,CAAS,EAA+C,CAC3F,MAAMC,KAAS,UAAO,CAAE,YAAa,EAAK,CAAC,EAErCC,EAAa,IAAI,EAAAC,QAAmBJ,EAAYC,CAAQ,EAC9D,OAAAC,EAAO,KAAK,IAAKC,EAAW,IAAI,EAChCD,EAAO,IAAI,WAAS,EAAAG,SAAW,CAAE,WAAAL,EAAY,SAAAC,CAAS,CAAC,CAAC,EACjDC,CACT,CAEA,IAAOR,EAAQC",
6
6
  "names": ["routes_exports", "__export", "routes_default", "routes", "__toCommonJS", "import_express", "import_controller", "import_routes", "layoutPath", "services", "router", "controller", "BookmarkController", "listRoutes"]
7
7
  }
@@ -8,10 +8,7 @@ export function routes({ layoutPath, services }: { layoutPath: string; services:
8
8
  const router = Router({ mergeParams: true })
9
9
 
10
10
  const controller = new BookmarkController(layoutPath, services)
11
-
12
11
  router.post('/', controller.POST)
13
- router.delete('/', controller.DELETE)
14
-
15
12
  router.use(`/list`, listRoutes({ layoutPath, services }))
16
13
  return router
17
14
  }
@@ -1,5 +1,5 @@
1
- "use strict";var S=Object.create;var k=Object.defineProperty;var B=Object.getOwnPropertyDescriptor;var $=Object.getOwnPropertyNames;var C=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var y=(a,s)=>{for(var o in s)k(a,o,{get:s[o],enumerable:!0})},f=(a,s,o,t)=>{if(s&&typeof s=="object"||typeof s=="function")for(let e of $(s))!v.call(a,e)&&e!==o&&k(a,e,{get:()=>s[e],enumerable:!(t=B(s,e))||t.enumerable});return a};var p=(a,s,o)=>(o=a!=null?S(C(a)):{},f(s||!a||!a.__esModule?k(o,"default",{value:a,enumerable:!0}):o,a)),R=a=>f(k({},"__esModule",{value:!0}),a);var x={};y(x,{BookmarkService:()=>m,default:()=>w});module.exports=R(x);var u=p(require("../../../../services/reportStoreService")),h=p(require("../../../../utils/logger"));class m extends u.default{constructor(o,t){super(o);this.isBookmarked=async(o,t,e)=>{if(!this.enabled)return!1;const r=await this.getState(e),i=this.isBookmarkedCheck(r,o,t);let n;return i&&(n=this.getBookmark(r,o,t)),n?.automatic?void 0:i};this.isBookmarkedCheck=(o,t,e)=>o.bookmarks.some(r=>r.id===t&&r.reportId===e);this.getBookmark=(o,t,e)=>o.bookmarks.find(r=>r.id===t&&r.reportId===e);this.enabled=!!t.bookmarking,this.enabled||h.default.info("Bookmarking: disabled ")}async getAllBookmarks(o){return this.enabled?(await this.getState(o)).bookmarks:[]}async addBookmark(o,t,e,r,i){if(!this.enabled)return;const n=await this.getState(o);this.isBookmarkedCheck(n,e,t)||n.bookmarks.unshift({reportId:t,id:e,type:r,automatic:i}),await this.saveState(o,n)}async removeBookmark(o,t,e){if(!this.enabled)return;const r=await this.getState(o),i=r.bookmarks.findIndex(n=>n.id===t&&n.reportId===e);i>=0&&r.bookmarks.splice(i,1),await this.saveState(o,r)}async createBookMarkToggleHtml({userConfig:o,reportId:t,id:e,csrfToken:r,ctxId:i,reportType:n,isMissing:d}){let g="Add bookmark",l=!1,b=null;if(o?.bookmarks){const c=this.getBookmark(o,e,t);c&&(b="checked",g="Remove bookmark",l=!!c.automatic)}return l||d?"":`<button class='dpr-bookmark dpr-bookmark-table' data-dpr-module='bookmark-toggle'>
2
- <input class='bookmark-input' type='checkbox' id='${t}-${e}-${i}' data-report-id='${t}' data-id='${e}' data-report-type='${n}' data-csrf-token='${r}' ${b} />
1
+ "use strict";var $=Object.create;var k=Object.defineProperty;var C=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var y=Object.getPrototypeOf,R=Object.prototype.hasOwnProperty;var w=(a,n)=>{for(var o in n)k(a,o,{get:n[o],enumerable:!0})},f=(a,n,o,t)=>{if(n&&typeof n=="object"||typeof n=="function")for(let e of v(n))!R.call(a,e)&&e!==o&&k(a,e,{get:()=>n[e],enumerable:!(t=C(n,e))||t.enumerable});return a};var p=(a,n,o)=>(o=a!=null?$(y(a)):{},f(n||!a||!a.__esModule?k(o,"default",{value:a,enumerable:!0}):o,a)),x=a=>f(k({},"__esModule",{value:!0}),a);var V={};w(V,{BookmarkService:()=>m,default:()=>T});module.exports=x(V);var u=p(require("../../../../services/reportStoreService")),h=p(require("../../../../utils/logger"));class m extends u.default{constructor(o,t){super(o);this.isBookmarked=async(o,t,e)=>{if(!this.enabled)return!1;const r=await this.getState(e),i=this.isBookmarkedCheck(r,o,t);let s;return i&&(s=this.getBookmark(r,o,t)),s?.automatic?void 0:i};this.isBookmarkedCheck=(o,t,e)=>o.bookmarks.some(r=>r.id===t&&r.reportId===e);this.getBookmark=(o,t,e)=>o.bookmarks.find(r=>r.id===t&&r.reportId===e);this.enabled=!!t.bookmarking,this.enabled||h.default.info("Bookmarking: disabled ")}async getAllBookmarks(o){return this.enabled?(await this.getState(o)).bookmarks:[]}async addBookmark(o,t,e,r,i){if(!this.enabled)return;const s=await this.getState(o);this.isBookmarkedCheck(s,e,t)||s.bookmarks.unshift({reportId:t,id:e,type:r,automatic:i}),await this.saveState(o,s)}async removeBookmark(o,t,e){if(!this.enabled)return;const r=await this.getState(o),i=r.bookmarks.findIndex(s=>s.id===t&&s.reportId===e);i>=0&&r.bookmarks.splice(i,1),await this.saveState(o,r)}async createBookMarkToggleHtml({userConfig:o,reportId:t,id:e,csrfToken:r,ctxId:i,reportType:s,isMissing:d,nestedBaseUrl:B}){let g="Add bookmark",l=!1,b=null;if(o?.bookmarks){const c=this.getBookmark(o,e,t);c&&(b="checked",g="Remove bookmark",l=!!c.automatic)}const S=`<button class='dpr-bookmark dpr-bookmark-table' data-dpr-module='bookmark-toggle'>
2
+ <input class='bookmark-input' type='checkbox' id='${t}-${e}-${i}' data-report-id='${t}' data-id='${e}' data-report-type='${s}' data-csrf-token='${r}' data-base-url='${B}' ${b} />
3
3
  <label tabindex='0' id='${e}-${t}-${i}-bookmark-label' for='${t}-${e}-${i}'><span class='dpr-bookmark-label govuk-body-s'>${g}</span></label>
4
- </button>`}}var w=m;0&&(module.exports={BookmarkService});
4
+ </button>`;return l||d?"":S}}var T=m;0&&(module.exports={BookmarkService});
5
5
  //# sourceMappingURL=service.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/dpr/routes/journeys/my-reports/bookmarks/service.ts"],
4
- "sourcesContent": ["import ReportStoreService from '../../../../services/reportStoreService'\nimport ReportDataStore from '../../../../data/reportDataStore'\nimport { ReportType } from '../../../../types/UserReports'\nimport { ReportStoreConfig } from '../../../../types/ReportStore'\nimport logger from '../../../../utils/logger'\nimport { BookmarkStoreData } from '../../../../types/Bookmark'\nimport { ServiceFeatureConfig } from '../../../../types/DprConfig'\n\nclass BookmarkService extends ReportStoreService {\n enabled: boolean\n\n constructor(reportDataStore: ReportDataStore, serviceFeatureConfig: ServiceFeatureConfig) {\n super(reportDataStore)\n this.enabled = Boolean(serviceFeatureConfig.bookmarking)\n if (!this.enabled) logger.info(`Bookmarking: disabled `)\n }\n\n async getAllBookmarks(userId: string): Promise<BookmarkStoreData[]> {\n if (!this.enabled) return []\n\n const userConfig = await this.getState(userId)\n return userConfig.bookmarks\n }\n\n async addBookmark(\n userId: string,\n reportId: string,\n id: string,\n type: ReportType,\n automatic?: boolean,\n ): Promise<void> {\n if (!this.enabled) return\n\n const userConfig = await this.getState(userId)\n if (!this.isBookmarkedCheck(userConfig, id, reportId)) {\n userConfig.bookmarks.unshift({ reportId, id, type, automatic })\n }\n await this.saveState(userId, userConfig)\n }\n\n async removeBookmark(userId: string, id: string, reportId: string): Promise<void> {\n if (!this.enabled) return\n\n const userConfig = await this.getState(userId)\n const index = userConfig.bookmarks.findIndex((bookmark) => {\n const bmVarId = bookmark.id\n return bmVarId === id && bookmark.reportId === reportId\n })\n if (index >= 0) {\n userConfig.bookmarks.splice(index, 1)\n }\n await this.saveState(userId, userConfig)\n }\n\n isBookmarked = async (id: string, reportId: string, userId: string): Promise<boolean | undefined> => {\n if (!this.enabled) return false\n\n const userConfig = await this.getState(userId)\n const isBookmarked = this.isBookmarkedCheck(userConfig, id, reportId)\n let bookmark\n if (isBookmarked) {\n bookmark = this.getBookmark(userConfig, id, reportId)\n }\n\n return bookmark?.automatic ? undefined : isBookmarked\n }\n\n private isBookmarkedCheck = (userConfig: ReportStoreConfig, id: string, reportId: string): boolean => {\n return userConfig.bookmarks.some((bookmark) => {\n const bmVarId = bookmark.id\n return bmVarId === id && bookmark.reportId === reportId\n })\n }\n\n private getBookmark = (userConfig: ReportStoreConfig, id: string, reportId: string) => {\n return userConfig.bookmarks.find((bookmark) => {\n const bmVarId = bookmark.id\n return bmVarId === id && bookmark.reportId === reportId\n })\n }\n\n async createBookMarkToggleHtml({\n userConfig,\n reportId,\n id,\n csrfToken,\n ctxId,\n reportType,\n isMissing,\n }: {\n userConfig: ReportStoreConfig\n reportId: string\n id: string\n csrfToken: string\n ctxId: string\n reportType: ReportType\n isMissing: boolean\n }) {\n let tooltip = 'Add bookmark'\n let automatic = false\n let checked = null\n if (userConfig?.bookmarks) {\n const bookmark = this.getBookmark(userConfig, id, reportId)\n if (bookmark) {\n checked = 'checked'\n tooltip = 'Remove bookmark'\n automatic = Boolean(bookmark.automatic)\n }\n }\n\n return automatic || isMissing\n ? ''\n : `<button class='dpr-bookmark dpr-bookmark-table' data-dpr-module='bookmark-toggle'>\n <input class='bookmark-input' type='checkbox' id='${reportId}-${id}-${ctxId}' data-report-id='${reportId}' data-id='${id}' data-report-type='${reportType}' data-csrf-token='${csrfToken}' ${checked} />\n <label tabindex='0' id='${id}-${reportId}-${ctxId}-bookmark-label' for='${reportId}-${id}-${ctxId}'><span class='dpr-bookmark-label govuk-body-s'>${tooltip}</span></label>\n</button>`\n }\n}\n\nexport { BookmarkService }\nexport default BookmarkService\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAA+B,sDAI/BC,EAAmB,uCAInB,MAAMJ,UAAwB,EAAAK,OAAmB,CAG/C,YAAYC,EAAkCC,EAA4C,CACxF,MAAMD,CAAe,EA0CvB,kBAAe,MAAOE,EAAYC,EAAkBC,IAAiD,CACnG,GAAI,CAAC,KAAK,QAAS,MAAO,GAE1B,MAAMC,EAAa,MAAM,KAAK,SAASD,CAAM,EACvCE,EAAe,KAAK,kBAAkBD,EAAYH,EAAIC,CAAQ,EACpE,IAAII,EACJ,OAAID,IACFC,EAAW,KAAK,YAAYF,EAAYH,EAAIC,CAAQ,GAG/CI,G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AME,EAAW,KAAK,YAAYF,EAAYH,EAAIC,CAAQ,EACtDI,IACFU,EAAU,UACVD,EAAU,kBACVN,EAAY,EAAQH,EAAS,UAEjC,CAEA,OAAOG,GAAaK,EAChB,GACA;AAAA,sDAC8CZ,CAAQ,IAAID,CAAE,IAAIW,CAAK,qBAAqBV,CAAQ,cAAcD,CAAE,uBAAuBY,CAAU,sBAAsBF,CAAS,KAAKK,CAAO;AAAA,4BAC1Kf,CAAE,IAAIC,CAAQ,IAAIU,CAAK,yBAAyBV,CAAQ,IAAID,CAAE,IAAIW,CAAK,mDAAmDG,CAAO;AAAA,UAE3J,CACF,CAGA,IAAOrB,EAAQD",
6
- "names": ["service_exports", "__export", "BookmarkService", "service_default", "__toCommonJS", "import_reportStoreService", "import_logger", "ReportStoreService", "reportDataStore", "serviceFeatureConfig", "id", "reportId", "userId", "userConfig", "isBookmarked", "bookmark", "logger", "type", "automatic", "index", "csrfToken", "ctxId", "reportType", "isMissing", "tooltip", "checked"]
4
+ "sourcesContent": ["import ReportStoreService from '../../../../services/reportStoreService'\nimport ReportDataStore from '../../../../data/reportDataStore'\nimport { ReportType } from '../../../../types/UserReports'\nimport { ReportStoreConfig } from '../../../../types/ReportStore'\nimport logger from '../../../../utils/logger'\nimport { BookmarkStoreData } from '../../../../types/Bookmark'\nimport { ServiceFeatureConfig } from '../../../../types/DprConfig'\n\nclass BookmarkService extends ReportStoreService {\n enabled: boolean\n\n constructor(reportDataStore: ReportDataStore, serviceFeatureConfig: ServiceFeatureConfig) {\n super(reportDataStore)\n this.enabled = Boolean(serviceFeatureConfig.bookmarking)\n if (!this.enabled) logger.info(`Bookmarking: disabled `)\n }\n\n async getAllBookmarks(userId: string): Promise<BookmarkStoreData[]> {\n if (!this.enabled) return []\n\n const userConfig = await this.getState(userId)\n return userConfig.bookmarks\n }\n\n async addBookmark(\n userId: string,\n reportId: string,\n id: string,\n type: ReportType,\n automatic?: boolean,\n ): Promise<void> {\n if (!this.enabled) return\n\n const userConfig = await this.getState(userId)\n if (!this.isBookmarkedCheck(userConfig, id, reportId)) {\n userConfig.bookmarks.unshift({ reportId, id, type, automatic })\n }\n await this.saveState(userId, userConfig)\n }\n\n async removeBookmark(userId: string, id: string, reportId: string): Promise<void> {\n if (!this.enabled) return\n\n const userConfig = await this.getState(userId)\n const index = userConfig.bookmarks.findIndex((bookmark) => {\n const bmVarId = bookmark.id\n return bmVarId === id && bookmark.reportId === reportId\n })\n if (index >= 0) {\n userConfig.bookmarks.splice(index, 1)\n }\n await this.saveState(userId, userConfig)\n }\n\n isBookmarked = async (id: string, reportId: string, userId: string): Promise<boolean | undefined> => {\n if (!this.enabled) return false\n\n const userConfig = await this.getState(userId)\n const isBookmarked = this.isBookmarkedCheck(userConfig, id, reportId)\n let bookmark\n if (isBookmarked) {\n bookmark = this.getBookmark(userConfig, id, reportId)\n }\n\n return bookmark?.automatic ? undefined : isBookmarked\n }\n\n private isBookmarkedCheck = (userConfig: ReportStoreConfig, id: string, reportId: string): boolean => {\n return userConfig.bookmarks.some((bookmark) => {\n const bmVarId = bookmark.id\n return bmVarId === id && bookmark.reportId === reportId\n })\n }\n\n private getBookmark = (userConfig: ReportStoreConfig, id: string, reportId: string) => {\n return userConfig.bookmarks.find((bookmark) => {\n const bmVarId = bookmark.id\n return bmVarId === id && bookmark.reportId === reportId\n })\n }\n\n async createBookMarkToggleHtml({\n userConfig,\n reportId,\n id,\n csrfToken,\n ctxId,\n reportType,\n isMissing,\n nestedBaseUrl,\n }: {\n userConfig: ReportStoreConfig\n reportId: string\n id: string\n csrfToken: string\n ctxId: string\n reportType: ReportType\n isMissing: boolean\n nestedBaseUrl: string | undefined\n }) {\n let tooltip = 'Add bookmark'\n let automatic = false\n let checked = null\n\n if (userConfig?.bookmarks) {\n const bookmark = this.getBookmark(userConfig, id, reportId)\n if (bookmark) {\n checked = 'checked'\n tooltip = 'Remove bookmark'\n automatic = Boolean(bookmark.automatic)\n }\n }\n\n const bookmarkButton = `<button class='dpr-bookmark dpr-bookmark-table' data-dpr-module='bookmark-toggle'>\n <input class='bookmark-input' type='checkbox' id='${reportId}-${id}-${ctxId}' data-report-id='${reportId}' data-id='${id}' data-report-type='${reportType}' data-csrf-token='${csrfToken}' data-base-url='${nestedBaseUrl}' ${checked} />\n <label tabindex='0' id='${id}-${reportId}-${ctxId}-bookmark-label' for='${reportId}-${id}-${ctxId}'><span class='dpr-bookmark-label govuk-body-s'>${tooltip}</span></label>\n</button>`\n\n return automatic || isMissing ? '' : bookmarkButton\n }\n}\n\nexport { BookmarkService }\nexport default BookmarkService\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAAA,IAAAK,EAA+B,sDAI/BC,EAAmB,uCAInB,MAAMJ,UAAwB,EAAAK,OAAmB,CAG/C,YAAYC,EAAkCC,EAA4C,CACxF,MAAMD,CAAe,EA0CvB,kBAAe,MAAOE,EAAYC,EAAkBC,IAAiD,CACnG,GAAI,CAAC,KAAK,QAAS,MAAO,GAE1B,MAAMC,EAAa,MAAM,KAAK,SAASD,CAAM,EACvCE,EAAe,KAAK,kBAAkBD,EAAYH,EAAIC,CAAQ,EACpE,IAAII,EACJ,OAAID,IACFC,EAAW,KAAK,YAAYF,EAAYH,EAAIC,CAAQ,GAG/CI,GAAU,UAAY,OAAYD,CAC3C,EAEA,KAAQ,kBAAoB,CAACD,EAA+BH,EAAYC,IAC/DE,EAAW,UAAU,KAAME,GAChBA,EAAS,KACNL,GAAMK,EAAS,WAAaJ,CAChD,EAGH,KAAQ,YAAc,CAACE,EAA+BH,EAAYC,IACzDE,EAAW,UAAU,KAAME,GAChBA,EAAS,KACNL,GAAMK,EAAS,WAAaJ,CAChD,EAjED,KAAK,QAAU,EAAQF,EAAqB,YACvC,KAAK,SAAS,EAAAO,QAAO,KAAK,wBAAwB,CACzD,CAEA,MAAM,gBAAgBJ,EAA8C,CAClE,OAAK,KAAK,SAES,MAAM,K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zJ,OAAOP,GAAaK,EAAY,GAAKI,CACvC,CACF,CAGA,IAAOxB,EAAQD",
6
+ "names": ["service_exports", "__export", "BookmarkService", "service_default", "__toCommonJS", "import_reportStoreService", "import_logger", "ReportStoreService", "reportDataStore", "serviceFeatureConfig", "id", "reportId", "userId", "userConfig", "isBookmarked", "bookmark", "logger", "type", "automatic", "index", "csrfToken", "ctxId", "reportType", "isMissing", "nestedBaseUrl", "tooltip", "checked", "bookmarkButton"]
7
7
  }
@@ -87,6 +87,7 @@ class BookmarkService extends ReportStoreService {
87
87
  ctxId,
88
88
  reportType,
89
89
  isMissing,
90
+ nestedBaseUrl,
90
91
  }: {
91
92
  userConfig: ReportStoreConfig
92
93
  reportId: string
@@ -95,10 +96,12 @@ class BookmarkService extends ReportStoreService {
95
96
  ctxId: string
96
97
  reportType: ReportType
97
98
  isMissing: boolean
99
+ nestedBaseUrl: string | undefined
98
100
  }) {
99
101
  let tooltip = 'Add bookmark'
100
102
  let automatic = false
101
103
  let checked = null
104
+
102
105
  if (userConfig?.bookmarks) {
103
106
  const bookmark = this.getBookmark(userConfig, id, reportId)
104
107
  if (bookmark) {
@@ -108,12 +111,12 @@ class BookmarkService extends ReportStoreService {
108
111
  }
109
112
  }
110
113
 
111
- return automatic || isMissing
112
- ? ''
113
- : `<button class='dpr-bookmark dpr-bookmark-table' data-dpr-module='bookmark-toggle'>
114
- <input class='bookmark-input' type='checkbox' id='${reportId}-${id}-${ctxId}' data-report-id='${reportId}' data-id='${id}' data-report-type='${reportType}' data-csrf-token='${csrfToken}' ${checked} />
114
+ const bookmarkButton = `<button class='dpr-bookmark dpr-bookmark-table' data-dpr-module='bookmark-toggle'>
115
+ <input class='bookmark-input' type='checkbox' id='${reportId}-${id}-${ctxId}' data-report-id='${reportId}' data-id='${id}' data-report-type='${reportType}' data-csrf-token='${csrfToken}' data-base-url='${nestedBaseUrl}' ${checked} />
115
116
  <label tabindex='0' id='${id}-${reportId}-${ctxId}-bookmark-label' for='${reportId}-${id}-${ctxId}'><span class='dpr-bookmark-label govuk-body-s'>${tooltip}</span></label>
116
117
  </button>`
118
+
119
+ return automatic || isMissing ? '' : bookmarkButton
117
120
  }
118
121
  }
119
122
 
@@ -1,2 +1,2 @@
1
- "use strict";var n=Object.create;var i=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var m=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var u=(e,r)=>{for(var s in r)i(e,s,{get:r[s],enumerable:!0})},a=(e,r,s,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of d(r))!v.call(e,t)&&t!==s&&i(e,t,{get:()=>r[t],enumerable:!(o=p(r,t))||o.enumerable});return e};var R=(e,r,s)=>(s=e!=null?n(m(e)):{},a(r||!e||!e.__esModule?i(s,"default",{value:e,enumerable:!0}):s,e)),f=e=>a(i({},"__esModule",{value:!0}),e);var w={};u(w,{RecentlyViewedReportsController:()=>c,default:()=>S});module.exports=f(w);var l=R(require("../../../../utils/localsHelper"));class c{constructor(r){this.DELETE=async(r,s)=>{const{dprUser:o}=l.default.getValues(s),{id:t}=r.params;await this.services.recentlyViewedService.removeReport(t,o.id),s.end()};this.services=r}}var S=c;0&&(module.exports={RecentlyViewedReportsController});
1
+ "use strict";var d=Object.create;var o=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var v=Object.getOwnPropertyNames;var n=Object.getPrototypeOf,m=Object.prototype.hasOwnProperty;var R=(e,r)=>{for(var s in r)o(e,s,{get:r[s],enumerable:!0})},a=(e,r,s,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of v(r))!m.call(e,t)&&t!==s&&o(e,t,{get:()=>r[t],enumerable:!(i=l(r,t))||i.enumerable});return e};var u=(e,r,s)=>(s=e!=null?d(n(e)):{},a(r||!e||!e.__esModule?o(s,"default",{value:e,enumerable:!0}):s,e)),S=e=>a(o({},"__esModule",{value:!0}),e);var w={};R(w,{RecentlyViewedReportsController:()=>c,default:()=>f});module.exports=S(w);var p=u(require("../../../../utils/localsHelper"));class c{constructor(r){this.POST=async(r,s)=>{const{dprUser:i}=p.default.getValues(s),{id:t}=r.params;await this.services.recentlyViewedService.removeReport(t,i.id),await this.services.requestedReportService.removeReport(t,i.id),s.end()};this.services=r}}var f=c;0&&(module.exports={RecentlyViewedReportsController});
2
2
  //# sourceMappingURL=controller.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/dpr/routes/journeys/my-reports/recently-viewed/controller.ts"],
4
- "sourcesContent": ["import { RequestHandler } from 'express'\nimport { Services } from '../../../../types/Services'\nimport LocalsHelper from '../../../../utils/localsHelper'\n\nclass RecentlyViewedReportsController {\n services: Services\n\n constructor(services: Services) {\n this.services = services\n }\n\n DELETE: RequestHandler = async (req, res) => {\n const { dprUser } = LocalsHelper.getValues(res)\n const { id } = req.params\n await this.services.recentlyViewedService.removeReport(id, dprUser.id)\n res.end()\n }\n}\n\nexport { RecentlyViewedReportsController }\nexport default RecentlyViewedReportsController\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAEA,IAAAK,EAAyB,6CAEzB,MAAMH,CAAgC,CAGpC,YAAYI,EAAoB,CAIhC,YAAyB,MAAOC,EAAKC,IAAQ,CAC3C,KAAM,CAAE,QAAAC,CAAQ,EAAI,EAAAC,QAAa,UAAUF,CAAG,EACxC,CAAE,GAAAG,CAAG,EAAIJ,EAAI,OACnB,MAAM,KAAK,SAAS,sBAAsB,aAAaI,EAAIF,EAAQ,EAAE,EACrED,EAAI,IAAI,CACV,EARE,KAAK,SAAWF,CAClB,CAQF,CAGA,IAAOH,EAAQD",
4
+ "sourcesContent": ["import { RequestHandler } from 'express'\nimport { Services } from '../../../../types/Services'\nimport LocalsHelper from '../../../../utils/localsHelper'\n\nclass RecentlyViewedReportsController {\n services: Services\n\n constructor(services: Services) {\n this.services = services\n }\n\n POST: RequestHandler = async (req, res) => {\n const { dprUser } = LocalsHelper.getValues(res)\n const { id } = req.params\n await this.services.recentlyViewedService.removeReport(id, dprUser.id)\n await this.services.requestedReportService.removeReport(id, dprUser.id)\n res.end()\n }\n}\n\nexport { RecentlyViewedReportsController }\nexport default RecentlyViewedReportsController\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qCAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAEA,IAAAK,EAAyB,6CAEzB,MAAMH,CAAgC,CAGpC,YAAYI,EAAoB,CAIhC,UAAuB,MAAOC,EAAKC,IAAQ,CACzC,KAAM,CAAE,QAAAC,CAAQ,EAAI,EAAAC,QAAa,UAAUF,CAAG,EACxC,CAAE,GAAAG,CAAG,EAAIJ,EAAI,OACnB,MAAM,KAAK,SAAS,sBAAsB,aAAaI,EAAIF,EAAQ,EAAE,EACrE,MAAM,KAAK,SAAS,uBAAuB,aAAaE,EAAIF,EAAQ,EAAE,EACtED,EAAI,IAAI,CACV,EATE,KAAK,SAAWF,CAClB,CASF,CAGA,IAAOH,EAAQD",
6
6
  "names": ["controller_exports", "__export", "RecentlyViewedReportsController", "controller_default", "__toCommonJS", "import_localsHelper", "services", "req", "res", "dprUser", "LocalsHelper", "id"]
7
7
  }
@@ -9,10 +9,11 @@ class RecentlyViewedReportsController {
9
9
  this.services = services
10
10
  }
11
11
 
12
- DELETE: RequestHandler = async (req, res) => {
12
+ POST: RequestHandler = async (req, res) => {
13
13
  const { dprUser } = LocalsHelper.getValues(res)
14
14
  const { id } = req.params
15
15
  await this.services.recentlyViewedService.removeReport(id, dprUser.id)
16
+ await this.services.requestedReportService.removeReport(id, dprUser.id)
16
17
  res.end()
17
18
  }
18
19
  }
@@ -1,2 +1,2 @@
1
- "use strict";var f=Object.create;var s=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var g=(e,r)=>{for(var t in r)s(e,t,{get:r[t],enumerable:!0})},l=(e,r,t,i)=>{if(r&&typeof r=="object"||typeof r=="function")for(let o of d(r))!E.call(e,o)&&o!==t&&s(e,o,{get:()=>r[o],enumerable:!(i=a(r,o))||i.enumerable});return e};var m=(e,r,t)=>(t=e!=null?f(R(e)):{},l(r||!e||!e.__esModule?s(t,"default",{value:e,enumerable:!0}):t,e)),v=e=>l(s({},"__esModule",{value:!0}),e);var x={};g(x,{default:()=>w,routes:()=>p});module.exports=v(x);var n=require("express"),u=m(require("./controller")),c=m(require("./list/routes"));function p({layoutPath:e,services:r}){const t=(0,n.Router)({mergeParams:!0}),i=new u.default(r);return t.delete("/:id",i.DELETE),t.use("/list",(0,c.default)({layoutPath:e,services:r})),t}var w=p;0&&(module.exports={routes});
1
+ "use strict";var f=Object.create;var i=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty;var S=(r,t)=>{for(var e in t)i(r,e,{get:t[e],enumerable:!0})},m=(r,t,e,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of R(t))!P.call(r,o)&&o!==e&&i(r,o,{get:()=>t[o],enumerable:!(s=a(t,o))||s.enumerable});return r};var n=(r,t,e)=>(e=r!=null?f(d(r)):{},m(t||!r||!r.__esModule?i(e,"default",{value:r,enumerable:!0}):e,r)),g=r=>m(i({},"__esModule",{value:!0}),r);var w={};S(w,{default:()=>v,routes:()=>c});module.exports=g(w);var u=require("express"),l=n(require("./controller")),p=n(require("./list/routes"));function c({layoutPath:r,services:t}){const e=(0,u.Router)({mergeParams:!0}),s=new l.default(t);return e.post("/:id",s.POST),e.use("/list",(0,p.default)({layoutPath:r,services:t})),e}var v=c;0&&(module.exports={routes});
2
2
  //# sourceMappingURL=routes.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/dpr/routes/journeys/my-reports/recently-viewed/routes.ts"],
4
- "sourcesContent": ["/* eslint-disable no-param-reassign */\nimport { Router } from 'express'\nimport { Services } from '../../../../types/Services'\nimport RecentlyViewedReportsController from './controller'\nimport listRoutes from './list/routes'\n\nexport function routes({ layoutPath, services }: { layoutPath: string; services: Services }) {\n const router = Router({ mergeParams: true })\n\n const controller = new RecentlyViewedReportsController(services)\n router.delete('/:id', controller.DELETE)\n router.use(`/list`, listRoutes({ layoutPath, services }))\n\n return router\n}\n\nexport default routes\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,WAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAuB,mBAEvBC,EAA4C,2BAC5CC,EAAuB,4BAEhB,SAASJ,EAAO,CAAE,WAAAK,EAAY,SAAAC,CAAS,EAA+C,CAC3F,MAAMC,KAAS,UAAO,CAAE,YAAa,EAAK,CAAC,EAErCC,EAAa,IAAI,EAAAC,QAAgCH,CAAQ,EAC/D,OAAAC,EAAO,OAAO,OAAQC,EAAW,MAAM,EACvCD,EAAO,IAAI,WAAS,EAAAG,SAAW,CAAE,WAAAL,EAAY,SAAAC,CAAS,CAAC,CAAC,EAEjDC,CACT,CAEA,IAAOR,EAAQC",
4
+ "sourcesContent": ["/* eslint-disable no-param-reassign */\nimport { Router } from 'express'\nimport { Services } from '../../../../types/Services'\nimport RecentlyViewedReportsController from './controller'\nimport listRoutes from './list/routes'\n\nexport function routes({ layoutPath, services }: { layoutPath: string; services: Services }) {\n const router = Router({ mergeParams: true })\n\n const controller = new RecentlyViewedReportsController(services)\n router.post('/:id', controller.POST)\n router.use(`/list`, listRoutes({ layoutPath, services }))\n\n return router\n}\n\nexport default routes\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,WAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAuB,mBAEvBC,EAA4C,2BAC5CC,EAAuB,4BAEhB,SAASJ,EAAO,CAAE,WAAAK,EAAY,SAAAC,CAAS,EAA+C,CAC3F,MAAMC,KAAS,UAAO,CAAE,YAAa,EAAK,CAAC,EAErCC,EAAa,IAAI,EAAAC,QAAgCH,CAAQ,EAC/D,OAAAC,EAAO,KAAK,OAAQC,EAAW,IAAI,EACnCD,EAAO,IAAI,WAAS,EAAAG,SAAW,CAAE,WAAAL,EAAY,SAAAC,CAAS,CAAC,CAAC,EAEjDC,CACT,CAEA,IAAOR,EAAQC",
6
6
  "names": ["routes_exports", "__export", "routes_default", "routes", "__toCommonJS", "import_express", "import_controller", "import_routes", "layoutPath", "services", "router", "controller", "RecentlyViewedReportsController", "listRoutes"]
7
7
  }
@@ -8,7 +8,7 @@ export function routes({ layoutPath, services }: { layoutPath: string; services:
8
8
  const router = Router({ mergeParams: true })
9
9
 
10
10
  const controller = new RecentlyViewedReportsController(services)
11
- router.delete('/:id', controller.DELETE)
11
+ router.post('/:id', controller.POST)
12
12
  router.use(`/list`, listRoutes({ layoutPath, services }))
13
13
 
14
14
  return router
@@ -1,2 +1,2 @@
1
- "use strict";var d=Object.create;var i=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var n=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var u=(e,r)=>{for(var s in r)i(e,s,{get:r[s],enumerable:!0})},a=(e,r,s,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of m(r))!v.call(e,t)&&t!==s&&i(e,t,{get:()=>r[t],enumerable:!(o=l(r,t))||o.enumerable});return e};var R=(e,r,s)=>(s=e!=null?d(n(e)):{},a(r||!e||!e.__esModule?i(s,"default",{value:e,enumerable:!0}):s,e)),f=e=>a(i({},"__esModule",{value:!0}),e);var S={};u(S,{RequestedReportsController:()=>c,default:()=>q});module.exports=f(S);var p=R(require("../../../../utils/localsHelper"));class c{constructor(r){this.DELETE=async(r,s)=>{const{dprUser:o}=p.default.getValues(s),{id:t}=r.params;await this.services.requestedReportService.removeReport(t,o.id),s.end()};this.services=r}}var q=c;0&&(module.exports={RequestedReportsController});
1
+ "use strict";var d=Object.create;var i=Object.defineProperty;var l=Object.getOwnPropertyDescriptor;var m=Object.getOwnPropertyNames;var n=Object.getPrototypeOf,v=Object.prototype.hasOwnProperty;var u=(e,r)=>{for(var s in r)i(e,s,{get:r[s],enumerable:!0})},a=(e,r,s,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let t of m(r))!v.call(e,t)&&t!==s&&i(e,t,{get:()=>r[t],enumerable:!(o=l(r,t))||o.enumerable});return e};var R=(e,r,s)=>(s=e!=null?d(n(e)):{},a(r||!e||!e.__esModule?i(s,"default",{value:e,enumerable:!0}):s,e)),S=e=>a(i({},"__esModule",{value:!0}),e);var q={};u(q,{RequestedReportsController:()=>c,default:()=>f});module.exports=S(q);var p=R(require("../../../../utils/localsHelper"));class c{constructor(r){this.POST=async(r,s)=>{const{dprUser:o}=p.default.getValues(s),{id:t}=r.params;await this.services.requestedReportService.removeReport(t,o.id),s.end()};this.services=r}}var f=c;0&&(module.exports={RequestedReportsController});
2
2
  //# sourceMappingURL=controller.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/dpr/routes/journeys/my-reports/requested-reports/controller.ts"],
4
- "sourcesContent": ["import { RequestHandler } from 'express'\nimport { Services } from '../../../../types/Services'\nimport LocalsHelper from '../../../../utils/localsHelper'\n\nclass RequestedReportsController {\n services: Services\n\n constructor(services: Services) {\n this.services = services\n }\n\n DELETE: RequestHandler = async (req, res) => {\n const { dprUser } = LocalsHelper.getValues(res)\n const { id } = req.params\n await this.services.requestedReportService.removeReport(id, dprUser.id)\n res.end()\n }\n}\n\nexport { RequestedReportsController }\nexport default RequestedReportsController\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gCAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAEA,IAAAK,EAAyB,6CAEzB,MAAMH,CAA2B,CAG/B,YAAYI,EAAoB,CAIhC,YAAyB,MAAOC,EAAKC,IAAQ,CAC3C,KAAM,CAAE,QAAAC,CAAQ,EAAI,EAAAC,QAAa,UAAUF,CAAG,EACxC,CAAE,GAAAG,CAAG,EAAIJ,EAAI,OACnB,MAAM,KAAK,SAAS,uBAAuB,aAAaI,EAAIF,EAAQ,EAAE,EACtED,EAAI,IAAI,CACV,EARE,KAAK,SAAWF,CAClB,CAQF,CAGA,IAAOH,EAAQD",
4
+ "sourcesContent": ["import { RequestHandler } from 'express'\nimport { Services } from '../../../../types/Services'\nimport LocalsHelper from '../../../../utils/localsHelper'\n\nclass RequestedReportsController {\n services: Services\n\n constructor(services: Services) {\n this.services = services\n }\n\n POST: RequestHandler = async (req, res) => {\n const { dprUser } = LocalsHelper.getValues(res)\n const { id } = req.params\n await this.services.requestedReportService.removeReport(id, dprUser.id)\n res.end()\n }\n}\n\nexport { RequestedReportsController }\nexport default RequestedReportsController\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gCAAAE,EAAA,YAAAC,IAAA,eAAAC,EAAAJ,GAEA,IAAAK,EAAyB,6CAEzB,MAAMH,CAA2B,CAG/B,YAAYI,EAAoB,CAIhC,UAAuB,MAAOC,EAAKC,IAAQ,CACzC,KAAM,CAAE,QAAAC,CAAQ,EAAI,EAAAC,QAAa,UAAUF,CAAG,EACxC,CAAE,GAAAG,CAAG,EAAIJ,EAAI,OACnB,MAAM,KAAK,SAAS,uBAAuB,aAAaI,EAAIF,EAAQ,EAAE,EACtED,EAAI,IAAI,CACV,EARE,KAAK,SAAWF,CAClB,CAQF,CAGA,IAAOH,EAAQD",
6
6
  "names": ["controller_exports", "__export", "RequestedReportsController", "controller_default", "__toCommonJS", "import_localsHelper", "services", "req", "res", "dprUser", "LocalsHelper", "id"]
7
7
  }
@@ -9,7 +9,7 @@ class RequestedReportsController {
9
9
  this.services = services
10
10
  }
11
11
 
12
- DELETE: RequestHandler = async (req, res) => {
12
+ POST: RequestHandler = async (req, res) => {
13
13
  const { dprUser } = LocalsHelper.getValues(res)
14
14
  const { id } = req.params
15
15
  await this.services.requestedReportService.removeReport(id, dprUser.id)
@@ -1,2 +1,2 @@
1
- "use strict";var f=Object.create;var i=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var d=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,E=Object.prototype.hasOwnProperty;var g=(r,e)=>{for(var t in e)i(r,t,{get:e[t],enumerable:!0})},u=(r,e,t,s)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of d(e))!E.call(r,o)&&o!==t&&i(r,o,{get:()=>e[o],enumerable:!(s=a(e,o))||s.enumerable});return r};var m=(r,e,t)=>(t=r!=null?f(R(r)):{},u(e||!r||!r.__esModule?i(t,"default",{value:r,enumerable:!0}):t,r)),v=r=>u(i({},"__esModule",{value:!0}),r);var P={};g(P,{default:()=>x,routes:()=>c});module.exports=v(P);var l=require("express"),n=m(require("./controller")),p=m(require("./list/routes"));function c({layoutPath:r,services:e}){const t=(0,l.Router)({mergeParams:!0}),s=new n.default(e);return t.delete("/:id",s.DELETE),t.use("/list",(0,p.default)({layoutPath:r,services:e})),t}var x=c;0&&(module.exports={routes});
1
+ "use strict";var f=Object.create;var i=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var R=Object.getOwnPropertyNames;var d=Object.getPrototypeOf,P=Object.prototype.hasOwnProperty;var S=(r,t)=>{for(var o in t)i(r,o,{get:t[o],enumerable:!0})},u=(r,t,o,s)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of R(t))!P.call(r,e)&&e!==o&&i(r,e,{get:()=>t[e],enumerable:!(s=a(t,e))||s.enumerable});return r};var m=(r,t,o)=>(o=r!=null?f(d(r)):{},u(t||!r||!r.__esModule?i(o,"default",{value:r,enumerable:!0}):o,r)),g=r=>u(i({},"__esModule",{value:!0}),r);var x={};S(x,{default:()=>v,routes:()=>c});module.exports=g(x);var n=require("express"),l=m(require("./controller")),p=m(require("./list/routes"));function c({layoutPath:r,services:t}){const o=(0,n.Router)({mergeParams:!0}),s=new l.default(t);return o.post("/:id",s.POST),o.use("/list",(0,p.default)({layoutPath:r,services:t})),o}var v=c;0&&(module.exports={routes});
2
2
  //# sourceMappingURL=routes.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/dpr/routes/journeys/my-reports/requested-reports/routes.ts"],
4
- "sourcesContent": ["/* eslint-disable no-param-reassign */\nimport { Router } from 'express'\nimport { Services } from '../../../../types/Services'\nimport RequestedReportsController from './controller'\nimport listRoutes from './list/routes'\n\nexport function routes({ layoutPath, services }: { layoutPath: string; services: Services }) {\n const router = Router({ mergeParams: true })\n\n const controller = new RequestedReportsController(services)\n router.delete('/:id', controller.DELETE)\n\n router.use(`/list`, listRoutes({ layoutPath, services }))\n return router\n}\n\nexport default routes\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,WAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAuB,mBAEvBC,EAAuC,2BACvCC,EAAuB,4BAEhB,SAASJ,EAAO,CAAE,WAAAK,EAAY,SAAAC,CAAS,EAA+C,CAC3F,MAAMC,KAAS,UAAO,CAAE,YAAa,EAAK,CAAC,EAErCC,EAAa,IAAI,EAAAC,QAA2BH,CAAQ,EAC1D,OAAAC,EAAO,OAAO,OAAQC,EAAW,MAAM,EAEvCD,EAAO,IAAI,WAAS,EAAAG,SAAW,CAAE,WAAAL,EAAY,SAAAC,CAAS,CAAC,CAAC,EACjDC,CACT,CAEA,IAAOR,EAAQC",
4
+ "sourcesContent": ["/* eslint-disable no-param-reassign */\nimport { Router } from 'express'\nimport { Services } from '../../../../types/Services'\nimport RequestedReportsController from './controller'\nimport listRoutes from './list/routes'\n\nexport function routes({ layoutPath, services }: { layoutPath: string; services: Services }) {\n const router = Router({ mergeParams: true })\n\n const controller = new RequestedReportsController(services)\n router.post('/:id', controller.POST)\n\n router.use(`/list`, listRoutes({ layoutPath, services }))\n return router\n}\n\nexport default routes\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,EAAA,WAAAC,IAAA,eAAAC,EAAAJ,GACA,IAAAK,EAAuB,mBAEvBC,EAAuC,2BACvCC,EAAuB,4BAEhB,SAASJ,EAAO,CAAE,WAAAK,EAAY,SAAAC,CAAS,EAA+C,CAC3F,MAAMC,KAAS,UAAO,CAAE,YAAa,EAAK,CAAC,EAErCC,EAAa,IAAI,EAAAC,QAA2BH,CAAQ,EAC1D,OAAAC,EAAO,KAAK,OAAQC,EAAW,IAAI,EAEnCD,EAAO,IAAI,WAAS,EAAAG,SAAW,CAAE,WAAAL,EAAY,SAAAC,CAAS,CAAC,CAAC,EACjDC,CACT,CAEA,IAAOR,EAAQC",
6
6
  "names": ["routes_exports", "__export", "routes_default", "routes", "__toCommonJS", "import_express", "import_controller", "import_routes", "layoutPath", "services", "router", "controller", "RequestedReportsController", "listRoutes"]
7
7
  }