Skip to content

Commit

Permalink
Handover report export to XLSX
Browse files Browse the repository at this point in the history
  • Loading branch information
YaaL committed Aug 6, 2020
1 parent 7570b2c commit 1f56371
Show file tree
Hide file tree
Showing 6 changed files with 492 additions and 37 deletions.
177 changes: 174 additions & 3 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,19 @@
"@sentry/integrations": "^5.20.1",
"canvas": "^2.6.1",
"core-js": "^2.6.11",
"downloadjs": "^1.4.7",
"file-saver": "^2.0.2",
"firebaseui": "^4.6.1",
"govuk-frontend": "^3.8.0",
"html-docx-js": "^0.3.1",
"html2canvas": "^1.0.0-rc.5",
"jspdf": "^1.5.3",
"save-file": "^2.3.1",
"vue": "^2.6.11",
"vue-router": "^3.3.4",
"vuex": "^3.5.1",
"vuexfire": "^3.2.3"
"vuexfire": "^3.2.3",
"xlsx-populate": "^1.21.0"
},
"devDependencies": {
"@vue/cli-plugin-babel": "^3.12.1",
Expand Down
18 changes: 18 additions & 0 deletions src/helpers/export.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import XLSXPopulate from 'xlsx-populate';
import { save } from 'save-file';

const downloadXLSX = async (data, title, filename) => {
const workbook = await XLSXPopulate.fromBlankAsync();
const sheet = workbook.sheet(0);
sheet.name(title);

sheet.cell('A1').value(data);
sheet.row(1).style({ bold: true, fill: 'eeeeee' });

const blob = await workbook.outputAsync();
await save(blob, filename);
};

export {
downloadXLSX
};
7 changes: 7 additions & 0 deletions src/store/applications.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,9 @@ export default {
records: [],
},
getters: {
getById: (state) => (applicationId) => {
return getById(state.records, applicationId);
},
reasonableAdjustments(state) {
return reasonableAdjustmentsReport(state.records);
},
Expand All @@ -35,6 +38,10 @@ export default {
},
};

const getById = (applications, applicationId) => {
return applications.find(application => application.id === applicationId);
};

const reasonableAdjustmentsReport = (applications) => {
const report = {
totalCount: applications.length,
Expand Down
Loading

0 comments on commit 1f56371

Please sign in to comment.