@ministryofjustice/hmpps-digital-prison-reporting-frontend 3.22.2 → 3.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.
@@ -971,7 +971,9 @@ class BookmarkToggle extends DprClientClass {
971
971
  }),
972
972
  })
973
973
  .then(() => {
974
- window.location.reload();
974
+ if (!window.location.href.includes('/report')) {
975
+ window.location.reload();
976
+ }
975
977
  })
976
978
  .catch((error) => console.error('Error:', error));
977
979
  }
@@ -4,10 +4,18 @@ exports.default = {
4
4
  mapReportsList: (res, services) => {
5
5
  const { definitions, csrfToken } = res.locals;
6
6
  const pathSuffix = res.locals.pathSuffix || '';
7
- const allVariants = definitions.flatMap((def) => {
7
+ const sortedDefinitions = definitions.sort((a, b) => {
8
+ if (a.name < b.name)
9
+ return -1;
10
+ if (a.name > b.name)
11
+ return 1;
12
+ return 0;
13
+ });
14
+ const sortedVariants = sortedDefinitions.flatMap((def) => {
8
15
  const { id: reportId, name: reportName, description: reportDescription } = def;
9
16
  const { variants } = def;
10
- return variants.map((variant) => {
17
+ return variants
18
+ .map((variant) => {
11
19
  const { id: variantId, name: variantName, description: variantDescription } = variant;
12
20
  return {
13
21
  reportName,
@@ -17,17 +25,15 @@ exports.default = {
17
25
  variantDescription,
18
26
  reportDescription,
19
27
  };
28
+ })
29
+ .sort((a, b) => {
30
+ if (a.variantName < b.variantName)
31
+ return -1;
32
+ if (a.variantName > b.variantName)
33
+ return 1;
34
+ return 0;
20
35
  });
21
36
  });
22
- const sortedVariants = allVariants.sort((a, b) => {
23
- if (a.variantName < b.variantName) {
24
- return -1;
25
- }
26
- if (a.variantName > b.variantName) {
27
- return 1;
28
- }
29
- return 0;
30
- });
31
37
  const rows = sortedVariants.map((v) => {
32
38
  const { variantId, variantName, variantDescription, reportName, reportId, reportDescription } = v;
33
39
  return [
@@ -18,30 +18,35 @@ export default {
18
18
  const { definitions, csrfToken } = res.locals
19
19
  const pathSuffix = res.locals.pathSuffix || ''
20
20
 
21
- const allVariants = definitions.flatMap((def: components['schemas']['ReportDefinitionSummary']) => {
21
+ const sortedDefinitions = definitions.sort(
22
+ (a: components['schemas']['ReportDefinitionSummary'], b: components['schemas']['ReportDefinitionSummary']) => {
23
+ if (a.name < b.name) return -1
24
+ if (a.name > b.name) return 1
25
+ return 0
26
+ },
27
+ )
28
+
29
+ const sortedVariants = sortedDefinitions.flatMap((def: components['schemas']['ReportDefinitionSummary']) => {
22
30
  const { id: reportId, name: reportName, description: reportDescription } = def
23
31
  const { variants } = def
24
- return variants.map((variant) => {
25
- const { id: variantId, name: variantName, description: variantDescription } = variant
26
- return {
27
- reportName,
28
- reportId,
29
- variantId,
30
- variantName,
31
- variantDescription,
32
- reportDescription,
33
- }
34
- })
35
- })
36
32
 
37
- const sortedVariants = allVariants.sort((a: variantData, b: variantData) => {
38
- if (a.variantName < b.variantName) {
39
- return -1
40
- }
41
- if (a.variantName > b.variantName) {
42
- return 1
43
- }
44
- return 0
33
+ return variants
34
+ .map((variant) => {
35
+ const { id: variantId, name: variantName, description: variantDescription } = variant
36
+ return {
37
+ reportName,
38
+ reportId,
39
+ variantId,
40
+ variantName,
41
+ variantDescription,
42
+ reportDescription,
43
+ }
44
+ })
45
+ .sort((a: variantData, b: variantData) => {
46
+ if (a.variantName < b.variantName) return -1
47
+ if (a.variantName > b.variantName) return 1
48
+ return 0
49
+ })
45
50
  })
46
51
 
47
52
  const rows = sortedVariants.map((v: variantData) => {
@@ -52,8 +52,8 @@ class BookmarkService extends userStoreService_1.default {
52
52
  const checked = this.isBookmarked(variantId) ? 'checked' : null;
53
53
  const tooltip = !checked ? 'Add Bookmark' : 'Remove Bookmark';
54
54
  return `<div class='dpr-bookmark dpr-bookmark-tooltip dpr-bookmark-table' tooltip="${tooltip}">
55
- <input class="bookmark-input" aria-label="bookmark toggle" type='checkbox' id='${variantId}-${id}' data-report-id='${reportId}' data-variant-id='${variantId}' data-csrf-token='${csrfToken}' ${checked} />
56
- <label id="${variantId}-${reportId}-bookmark-label" for='${variantId}-${id}'><span class="dpr-visually-hidden">Bookmark toggle</span></label>
55
+ <input class="bookmark-input" aria-label="bookmark toggle" type='checkbox' id='${reportId}-${variantId}-${id}' data-report-id='${reportId}' data-variant-id='${variantId}' data-csrf-token='${csrfToken}' ${checked} />
56
+ <label id="${variantId}-${reportId}-bookmark-label" for='${reportId}-${variantId}-${id}'><span class="dpr-visually-hidden">Bookmark toggle</span></label>
57
57
  </div>`;
58
58
  }
59
59
  }
@@ -60,8 +60,8 @@ export default class BookmarkService extends UserStoreService {
60
60
  const checked = this.isBookmarked(variantId) ? 'checked' : null
61
61
  const tooltip = !checked ? 'Add Bookmark' : 'Remove Bookmark'
62
62
  return `<div class='dpr-bookmark dpr-bookmark-tooltip dpr-bookmark-table' tooltip="${tooltip}">
63
- <input class="bookmark-input" aria-label="bookmark toggle" type='checkbox' id='${variantId}-${id}' data-report-id='${reportId}' data-variant-id='${variantId}' data-csrf-token='${csrfToken}' ${checked} />
64
- <label id="${variantId}-${reportId}-bookmark-label" for='${variantId}-${id}'><span class="dpr-visually-hidden">Bookmark toggle</span></label>
63
+ <input class="bookmark-input" aria-label="bookmark toggle" type='checkbox' id='${reportId}-${variantId}-${id}' data-report-id='${reportId}' data-variant-id='${variantId}' data-csrf-token='${csrfToken}' ${checked} />
64
+ <label id="${variantId}-${reportId}-bookmark-label" for='${reportId}-${variantId}-${id}'><span class="dpr-visually-hidden">Bookmark toggle</span></label>
65
65
  </div>`
66
66
  }
67
67
  }
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": "3.22.2",
4
+ "version": "3.22.4",
5
5
  "main": "dpr/assets/js/all.mjs",
6
6
  "sass": "dpr/all.scss",
7
7
  "engines": {
package/package.zip CHANGED
Binary file