refactoring

This commit is contained in:
frankknoll
2023-10-15 14:55:10 +02:00
parent ae425cf723
commit d3589104ea
2 changed files with 15 additions and 11 deletions

View File

@@ -3,6 +3,7 @@ class PrrByVaccineTable {
#tableElement; #tableElement;
#table; #table;
#sumPrrs; #sumPrrs;
#prrByVaccine;
constructor(tableElement) { constructor(tableElement) {
this.#tableElement = tableElement; this.#tableElement = tableElement;
@@ -13,10 +14,23 @@ class PrrByVaccineTable {
} }
display(prrByVaccine) { display(prrByVaccine) {
this.#prrByVaccine = prrByVaccine;
const vaccine_prr_pairs = Object.entries(prrByVaccine); const vaccine_prr_pairs = Object.entries(prrByVaccine);
this.#setTableRows(vaccine_prr_pairs); this.#setTableRows(vaccine_prr_pairs);
} }
getDisplayedTableAsCsv(heading) {
return PrrByKey2CsvConverter.convertPrrByKey2Csv(
{
heading: heading,
columns: {
keyColumn: 'Vaccine',
prrColumn: 'Proportional Reporting Ratio'
},
prrByKey: this.#prrByVaccine
});
}
#createEmptyTable() { #createEmptyTable() {
return this.#tableElement.DataTable( return this.#tableElement.DataTable(
{ {

View File

@@ -35,17 +35,7 @@ class PrrByVaccineTableView {
UIUtils.downloadUrlAsFilename( UIUtils.downloadUrlAsFilename(
window.URL.createObjectURL( window.URL.createObjectURL(
new Blob( new Blob(
[ [this.#prrByVaccineTable.getDisplayedTableAsCsv('# Symptom: ' + this.#symptom)],
PrrByKey2CsvConverter.convertPrrByKey2Csv(
{
heading: '# Symptom: ' + this.#symptom,
columns: {
keyColumn: 'Vaccine',
prrColumn: 'Proportional Reporting Ratio'
},
prrByKey: this.#prrByVaccine
})
],
{ type: 'text/csv' })), { type: 'text/csv' })),
this.#symptom this.#symptom
); );