hof 20.1.2 → 20.1.3

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.
@@ -25,6 +25,7 @@ This allows you to specify fields to loop over and add as objects to a parent ar
25
25
  ],
26
26
  removePrefix: 'storage-',
27
27
  combineValuesToSingleField: 'address',
28
+ groupOptional: true,
28
29
  returnTo: '/add-address'
29
30
  }),
30
31
  next: '/confirm'
@@ -35,5 +36,6 @@ Here are the fields you call this behaviour first to set config for it:
35
36
  `fieldsToGroup`: (Required) the fields being specified for an object, e.g. house number, street, postcode, that are grouped together,
36
37
  `removePrefix`: (Optional) a string which is used to remove consistent prefixes from a collection of fields that are grouped together,
37
38
  `combineValuesToSingleField`: (Optional) a new field that is created with its value being the concatenation of values of the fields specified in `fieldsToGroup`,
38
- `returnTo`: the next step if you want to add another object to this group
39
+ `groupOptional`: (Optional) set this to true if you want to land on the radio button question if all records in the group are deleted after creation,
40
+ `returnTo`: (Required) the next step if you want to add another object to this group
39
41
  ```
@@ -5,7 +5,7 @@ const path = require('path');
5
5
  const express = require('express');
6
6
 
7
7
  module.exports = config => {
8
- const { returnTo, groupName, fieldsToGroup, combineValuesToSingleField, removePrefix } = config;
8
+ const { returnTo, groupName, fieldsToGroup, combineValuesToSingleField, removePrefix, groupOptional } = config;
9
9
 
10
10
  if (removePrefix && typeof removePrefix !== 'string') {
11
11
  throw new Error('removePrefix is a string and is optional for loops');
@@ -71,7 +71,7 @@ module.exports = config => {
71
71
  });
72
72
  }
73
73
 
74
- const target = items.length ? req.form.options.route : returnTo;
74
+ const target = (items.length || groupOptional) ? req.form.options.route : returnTo;
75
75
  const action = req.params.action || '';
76
76
  res.redirect(path.join(req.baseUrl, target, action));
77
77
  }
@@ -84,7 +84,10 @@ module.exports = config => {
84
84
  validate: ['required'],
85
85
  options: [
86
86
  'yes', 'no'
87
- ]
87
+ ],
88
+ legend: {
89
+ className: 'visuallyhidden'
90
+ }
88
91
  }, req.form.options.fieldSettings);
89
92
 
90
93
  // add conditonal fork
@@ -95,9 +98,6 @@ module.exports = config => {
95
98
  condition: {
96
99
  field: field,
97
100
  value: 'yes'
98
- },
99
- legend: {
100
- className: 'visuallyhidden'
101
101
  }
102
102
  });
103
103
  next();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hof",
3
3
  "description": "A bootstrap for HOF projects",
4
- "version": "20.1.2",
4
+ "version": "20.1.3",
5
5
  "license": "MIT",
6
6
  "main": "index.js",
7
7
  "author": "HomeOffice",