refactoring

This commit is contained in:
frankknoll
2023-10-15 15:23:10 +02:00
parent d84bc82a8c
commit fb53822fdc
6 changed files with 74 additions and 76 deletions

View File

@@ -1,53 +1,16 @@
class PrrBySymptomTableView {
#prrBySymptomTable;
#downloadPrrBySymptomTableButton;
#prrBySymptom;
#vaccine;
#delegate;
constructor(prrBySymptomTableElement, downloadPrrBySymptomTableButton) {
this.#prrBySymptomTable = new PrrBySymptomTable(prrBySymptomTableElement);
this.#prrBySymptomTable.initialize();
this.#initializeButton(downloadPrrBySymptomTableButton);
this.#delegate = new PrrByKeyTableView(
new PrrBySymptomTable(prrBySymptomTableElement),
downloadPrrBySymptomTableButton,
'Vaccine',
PrrByVaccineProvider.getPrrBySymptom);
}
displayPrrBySymptomTable4Vaccine(vaccine) {
UIUtils.disableButton(this.#downloadPrrBySymptomTableButton);
PrrByVaccineProvider
.getPrrBySymptom(vaccine)
.then(prrBySymptom => {
this.#prrBySymptom = prrBySymptom;
this.#vaccine = vaccine;
this.#prrBySymptomTable.display(prrBySymptom);
UIUtils.enableButton(this.#downloadPrrBySymptomTableButton);
});
}
#initializeButton(downloadPrrBySymptomTableButton) {
this.#downloadPrrBySymptomTableButton = downloadPrrBySymptomTableButton;
UIUtils.disableButton(downloadPrrBySymptomTableButton);
downloadPrrBySymptomTableButton.addEventListener(
'click',
() => this.#downloadPrrBySymptom())
}
#downloadPrrBySymptom() {
UIUtils.downloadUrlAsFilename(
window.URL.createObjectURL(
new Blob(
[
PrrByKey2CsvConverter.convertPrrByKey2Csv(
{
heading: '# Vaccine: ' + this.#vaccine,
columns: {
keyColumn: 'Symptom',
prrColumn: 'Proportional Reporting Ratio > 1'
},
prrByKey: this.#prrBySymptom
})
],
{ type: 'text/csv' })),
this.#vaccine
);
this.#delegate.displayPrrByKeyTable4Value(vaccine);
}
}