Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Paf 160 #133

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 9 additions & 10 deletions apps/paf/behaviours/additional-person-formatter.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
/* eslint-disable */
const _ = require('lodash');
const fieldsMap = require('../../../lib/ims-hof-fields-map.json');

module.exports = superclass => class extends superclass {
configure(req, res, next) {
const persons = req.sessionModel.get('persons');
Expand All @@ -8,20 +10,17 @@ module.exports = superclass => class extends superclass {

_.forEach(persons.aggregatedValues, i => {
console.log('Person :: ', i);
const peopleValue = i.fields.map(item => item.value !== '' ?
(item.field + ':' + item.value) : '');

// Remove person number value as this is not relevant for IMS
peopleValue.splice(0, 1);

const peopleValueFiltered = peopleValue.filter(entry => entry !== '');
const value = new Array();
i.fields.map(item => item.value !== '' ?
value.push({Key: _.find(fieldsMap.Fields, {HOF: item.field}).IMS,
StringValue: item.value}) : '');
jamiecarterHO marked this conversation as resolved.
Show resolved Hide resolved

additionalPeople.push('Person Added IS =' + peopleValueFiltered.join(', '));
additionalPeople.push(value);

req.sessionModel.set('additional-people-table', additionalPeople);
req.sessionModel.set('persons', additionalPeople);
});
} else {
req.sessionModel.unset('additional-people-table');
req.sessionModel.unset('persons');
}
return super.configure(req, res, next);
}
Expand Down
2 changes: 1 addition & 1 deletion kube/ims-resolver/ims-resolver-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ spec:
spec:
containers:
- name: ims-resolver
image: quay.io/ukhomeofficedigital/ims-resolver:91979bf3dd2eabee61f1b01385e07bba8e518abc
image: quay.io/ukhomeofficedigital/ims-resolver:0ed1c6fb5d703b75592081f53fdf583d7e20770e
imagePullPolicy: Always
envFrom:
- configMapRef:
Expand Down
40 changes: 19 additions & 21 deletions lib/add-allegation-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,57 +4,55 @@ const _ = require('lodash');
const fieldsMap = require('./ims-hof-fields-map.json');
const valuesMap = require('./ims-hof-values-map.json');

const eform = {
EformFields: [],
AdditionalPeople: [],
Attachments: []
};

const addFieldToEform = (fieldName, fieldValue) => {
const addFieldToEform = (eform, fieldName, fieldValue) => {
if (fieldName === 'images') {
eform.Attachments = fieldValue;
} else if (fieldName === 'txpermoreallholder') {
eform.AdditionalPeople.push({FieldName: fieldName, FieldValue: fieldValue});
eform.Attachements.push({url: fieldValue});
} else if (fieldName === 'tbwhoaddperson') {
eform.AdditionalPeople = fieldValue;
Comment on lines +9 to +11
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For attachments it needs to be eform.Attachments = fieldValue; here on line 9 as well as with additional people on line 11 otherwise that part of the array is also unnecessarily deep. I think it is that way on master branch right now from #106 or #119.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

basically both lines should be eform.Thing = fieldValue;

} else {
eform.EformFields.push({FieldName: fieldName, FieldValue: fieldValue});
}
};

const addField = (name, value) => {
const addField = (eform, name, value) => {
const imsName = _.find(fieldsMap.Fields, {HOF: name});
if ( imsName !== undefined && !(name === 'images')) {
const imsValue = _.find(valuesMap.Values, {HOF: value});
if (imsValue !== undefined ) {
addFieldToEform(imsName.IMS, imsValue.IMS);
addFieldToEform(eform, imsName.IMS, imsValue.IMS);
} else {
addFieldToEform(imsName.IMS, value);
addFieldToEform(eform, imsName.IMS, value);
}
}
if (name === 'images') {
addFieldToEform(name, value);
console.log('Value :: ', value);
addFieldToEform(eform, name, value);
}
};

const addGroup = value => {
addField(value, value);
};

const addAllegationData = data => {
const eform = {
EformFields: [],
AdditionalPeople: [],
Attachements: []
};

Object.entries(data).forEach(entry => {
const [key, value] = entry;
if (value !== '') {
if (key.includes('group')) {
const groups = Array.isArray(value) ? value : value.split(',');
groups.map(addGroup);
groups.map(value => {
addField(eform, value, value);
});
} else {
addField(key, value);
addField(eform, key, value);
}
}
});
return JSON.stringify(eform);
};


module.exports = {
addAllegationData
};
Loading