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

4 x reports/exports should be prepared server side #1213

Merged
merged 18 commits into from
Mar 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
6bf5787
WIP - export Application Contacts - data is now generated server-side
darre1 Mar 8, 2021
b37fb66
Exercises - Handover - Added Refresh button to generate handover repo…
darre1 Mar 9, 2021
2b2ea47
handover report - use spread operator (easier to read!)
darre1 Mar 10, 2021
278668a
Exercises - Reasonable Adjustments report now generated server-side
darre1 Mar 10, 2021
64ff2c9
Bug Fix - Export handover report - data was being output in the wrong…
darre1 Mar 11, 2021
59f9f8a
Bug Fix - Export handover report - data was being output in the wrong…
darre1 Mar 11, 2021
16b4898
Merge branch 'develop' into 1100-exports-should-be-prepared-server-side
darre1 Mar 11, 2021
f97baba
npm install
darre1 Mar 11, 2021
1a7679a
Applications - Export Contacts - refactored code slightly to work wit…
darre1 Mar 11, 2021
9dc8166
removed unit tests for functions that are not longer present
darre1 Mar 11, 2021
8125ca8
removed unit test that now requires a back-end function call
darre1 Mar 11, 2021
532e15c
fixed broken pipeline
darre1 Mar 11, 2021
5b622de
fix pipeline
darre1 Mar 11, 2021
08a4715
Qualfying Test Responses - Export now uses a server-side endpoint
darre1 Mar 11, 2021
63fb34d
Merge branch 'develop' into 1100-exports-should-be-prepared-server-side
darre1 Mar 11, 2021
64791c7
Applications - Export contacts now working
darre1 Mar 11, 2021
e16546f
Export Qualifying Test Responses now working
darre1 Mar 11, 2021
e3c5bb1
Merge branch 'develop' into 1100-exports-should-be-prepared-server-side
warrensearle Mar 11, 2021
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
264 changes: 239 additions & 25 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
"lint": "vue-cli-service lint",
"lint-ci": "vue-cli-service lint --no-fix",
"test": "vue-cli-service test:unit",
"test-ci": "vue-cli-service test:unit --ci --runInBand"
"test-ci": "vue-cli-service test:unit --ci --runInBand --detectOpenHandles --forceExit"
},
"dependencies": {
"@ckeditor/ckeditor5-build-classic": "^16.0.0",
Expand All @@ -26,6 +26,7 @@
"@ministryofjustice/frontend": "0.0.17-alpha",
"@sentry/browser": "^5.30.0",
"@sentry/integrations": "^5.30.0",
"@vue/compiler-sfc": "^3.0.7",
"canvas": "^2.6.1",
"core-js": "^2.6.12",
"file-saver": "^2.0.5",
Expand Down
127 changes: 23 additions & 104 deletions src/views/Exercises/Show/Applications.vue
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
<script>
import Table from '@jac-uk/jac-kit/components/Table/Table';
import TableCell from '@jac-uk/jac-kit/components/Table/TableCell';
import * as filters from '@jac-uk/jac-kit/filters/filters';
import { functions } from '@/firebase';
import { downloadXLSX } from '@jac-uk/jac-kit/helpers/export';

export default {
Expand Down Expand Up @@ -97,126 +97,45 @@ export default {
},
},
methods: {
flattenCurrentLegalRole(equalityAndDiversitySurvey) {
if (!(equalityAndDiversitySurvey && equalityAndDiversitySurvey.currentLegalRole)) {
return '';
}

const roles = [];
equalityAndDiversitySurvey.currentLegalRole.forEach((role) => {
if (role === 'other-fee-paid-judicial-office-holder') {
roles.push(`other: ${ equalityAndDiversitySurvey.otherCurrentFeePaidJudicialOfficeHolderDetails }`);
} else if (role === 'other-salaried-judicial-office-holder') {
roles.push(`other: ${ equalityAndDiversitySurvey.otherCurrentSalariedJudicialOfficeHolderDetails}`);
} else if (role === 'other-current-legal-role') {
roles.push(`Other: ${ equalityAndDiversitySurvey.otherCurrentLegalRoleDetails }`);
} else {
roles.push(filters.lookup(role));
}
});

return roles.join('\n');
},
flattenProfessionalBackground(equalityAndDiversitySurvey) {
if (!(equalityAndDiversitySurvey && equalityAndDiversitySurvey.professionalBackground)) {
return '';
}
const roles = [];
equalityAndDiversitySurvey.professionalBackground.forEach((role) => {
if (role === 'other-professional-background') {
roles.push(`Other: ${ equalityAndDiversitySurvey.otherProfessionalBackgroundDetails }`);
} else {
roles.push(filters.lookup(role));
getTableData(params) {
return this.$store.dispatch(
'applications/bind',
{
exerciseId: this.exercise.id,
status: this.status,
...params,
}
});
return roles.join('\n');
},
attendedUKStateSchool(equalityAndDiversitySurvey) {
if (!(equalityAndDiversitySurvey && equalityAndDiversitySurvey.stateOrFeeSchool)) {
return '';
}
return filters.toYesNo(['uk-state-selective', 'uk-state-non-selective'].indexOf(equalityAndDiversitySurvey.stateOrFeeSchool) >= 0);
);
},
gatherContacts() {
const headers = [
'Reference number',
'Status',
'Name',
'Email',
'Phone number',
'Date of Birth',
'National Insurance Number',
'Gender',
'Disability',
'Ethnic Group',
'Current Legal Role',
'Professional Background',
'Held Fee-paid Judicial Role',
'Attended UK State School',
'First Generation Student',
'First Assessor Name',
'First Assessor Email',
'First Assessor Phone',
'Second Assessor Name',
'Second Assessor Email',
'Second Assessor Phone',
];
async gatherReportData() {
// fetch data
const response = await functions.httpsCallable('exportApplicationContactsData')({ exerciseId: this.exercise.id, status: this.status });

const reportData = [];

const contacts = this.applications.map((application) => {
return [
application.referenceNumber,
filters.lookup(application.status),
application.personalDetails.fullName,
application.personalDetails.email,
application.personalDetails.phone,
filters.formatDate(application.personalDetails.dateOfBirth),
filters.formatNIN(application.personalDetails.nationalInsuranceNumber),
filters.lookup(application.equalityAndDiversitySurvey.gender),
filters.toYesNo(filters.lookup(application.equalityAndDiversitySurvey.disability)),
filters.lookup(application.equalityAndDiversitySurvey.ethnicGroup),
this.flattenCurrentLegalRole(application.equalityAndDiversitySurvey),
this.flattenProfessionalBackground(application.equalityAndDiversitySurvey),
filters.heldFeePaidJudicialRole(application.equalityAndDiversitySurvey.feePaidJudicialRole),
filters.toYesNo(this.attendedUKStateSchool(application.equalityAndDiversitySurvey)),
filters.toYesNo(filters.lookup(application.equalityAndDiversitySurvey.firstGenerationStudent)),
application.firstAssessorFullName,
application.firstAssessorEmail,
application.firstAssessorPhone,
application.secondAssessorFullName,
application.secondAssessorEmail,
application.secondAssessorPhone,
];
// get headers
reportData.push(response.data.headers.map(header => header));

// get rows
response.data.rows.forEach((row) => {
reportData.push(Object.values(row).map(cell => cell));
});

return [
headers,
...contacts,
];
return reportData;
},
async exportContacts() {
const title = 'Contacts';
await this.getTableData({});
const data = this.gatherContacts();
const xlsxData = await this.gatherReportData();

downloadXLSX(
data,
xlsxData,
{
title: `${this.exercise.referenceNumber} ${title}`,
sheetName: title,
fileName: `${this.exercise.referenceNumber} - ${title}.xlsx`,
}
);
},
getTableData(params) {
return this.$store.dispatch(
'applications/bind',
{
exerciseId: this.exercise.id,
status: this.status,
...params,
}
);
},
},
};
</script>
Expand Down
Loading