@ministryofjustice/hmpps-digital-prison-reporting-frontend 4.4.0 → 4.4.2
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.
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const preBookmarkReportsByRoleId = async (userId, activeCaseLoadId, services, bookmarksByCaseload) => {
|
|
4
|
-
const bookmarks = bookmarksByCaseload[activeCaseLoadId];
|
|
3
|
+
const preBookmarkReportsByRoleId = async (userId, activeCaseLoadId, services, bookmarksByCaseload = {}) => {
|
|
4
|
+
const bookmarks = bookmarksByCaseload[activeCaseLoadId] || [];
|
|
5
5
|
// Add new automatic bookmarks
|
|
6
6
|
for (let index = 0; index < bookmarks.length; index += 1) {
|
|
7
7
|
const { reportId, variantId: id } = bookmarks[index];
|
|
@@ -9,9 +9,9 @@ const preBookmarkReportsByRoleId = async (
|
|
|
9
9
|
userId: string,
|
|
10
10
|
activeCaseLoadId: string,
|
|
11
11
|
services: Services,
|
|
12
|
-
bookmarksByCaseload: BookmarksByCaseload,
|
|
12
|
+
bookmarksByCaseload: BookmarksByCaseload = {},
|
|
13
13
|
) => {
|
|
14
|
-
const bookmarks: BookmarkStoreData[] = bookmarksByCaseload[activeCaseLoadId]
|
|
14
|
+
const bookmarks: BookmarkStoreData[] = bookmarksByCaseload[activeCaseLoadId] || []
|
|
15
15
|
|
|
16
16
|
// Add new automatic bookmarks
|
|
17
17
|
for (let index = 0; index < bookmarks.length; index += 1) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ministryofjustice/hmpps-digital-prison-reporting-frontend",
|
|
3
3
|
"description": "The Digital Prison Reporting Frontend contains templates and code to help display data effectively in UI applications.",
|
|
4
|
-
"version": "4.4.
|
|
4
|
+
"version": "4.4.2",
|
|
5
5
|
"main": "dpr/all.mjs",
|
|
6
6
|
"sass": "dpr/all.scss",
|
|
7
7
|
"engines": {
|
package/package.zip
CHANGED
|
Binary file
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
const getBookmarks = (activeCaseLoadId) => {
|
|
4
|
-
let bookmarks = [];
|
|
5
|
-
switch (activeCaseLoadId) {
|
|
6
|
-
case 'random-id':
|
|
7
|
-
bookmarks = [
|
|
8
|
-
{ reportId: 'test-report-1', variantId: 'variantId-16' },
|
|
9
|
-
{ reportId: 'test-report-1', variantId: 'variantId-15' },
|
|
10
|
-
];
|
|
11
|
-
break;
|
|
12
|
-
default:
|
|
13
|
-
bookmarks = [];
|
|
14
|
-
break;
|
|
15
|
-
}
|
|
16
|
-
return bookmarks;
|
|
17
|
-
};
|
|
18
|
-
exports.default = (services) => {
|
|
19
|
-
return async (req, res, next) => {
|
|
20
|
-
if (res.locals.user) {
|
|
21
|
-
const { activeCaseLoadId, uuid } = res.locals.user;
|
|
22
|
-
const newBookmarks = getBookmarks(activeCaseLoadId);
|
|
23
|
-
for (let index = 0; index < newBookmarks.length; index += 1) {
|
|
24
|
-
const { reportId, variantId: id } = newBookmarks[index];
|
|
25
|
-
// eslint-disable-next-line no-await-in-loop
|
|
26
|
-
await services.bookmarkService.addBookmark(uuid, reportId, id, 'report');
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
return next();
|
|
30
|
-
};
|
|
31
|
-
};
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { RequestHandler } from 'express'
|
|
2
|
-
import { Services } from '../types/Services'
|
|
3
|
-
import { BookmarkStoreData } from '../types/Bookmark'
|
|
4
|
-
|
|
5
|
-
const getBookmarks = (activeCaseLoadId: string) => {
|
|
6
|
-
let bookmarks: BookmarkStoreData[] = []
|
|
7
|
-
switch (activeCaseLoadId) {
|
|
8
|
-
case 'random-id':
|
|
9
|
-
bookmarks = [
|
|
10
|
-
{ reportId: 'test-report-1', variantId: 'variantId-16' },
|
|
11
|
-
{ reportId: 'test-report-1', variantId: 'variantId-15' },
|
|
12
|
-
]
|
|
13
|
-
break
|
|
14
|
-
default:
|
|
15
|
-
bookmarks = []
|
|
16
|
-
break
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
return bookmarks
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export default (services: Services): RequestHandler => {
|
|
23
|
-
return async (req, res, next) => {
|
|
24
|
-
if (res.locals.user) {
|
|
25
|
-
const { activeCaseLoadId, uuid } = res.locals.user
|
|
26
|
-
const newBookmarks = getBookmarks(activeCaseLoadId)
|
|
27
|
-
|
|
28
|
-
for (let index = 0; index < newBookmarks.length; index += 1) {
|
|
29
|
-
const { reportId, variantId: id } = newBookmarks[index]
|
|
30
|
-
// eslint-disable-next-line no-await-in-loop
|
|
31
|
-
await services.bookmarkService.addBookmark(uuid, reportId, id, 'report')
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return next()
|
|
35
|
-
}
|
|
36
|
-
}
|