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,41 +1,16 @@
class PrrByVaccineTableView {
#prrByVaccineTable;
#downloadPrrByVaccineTableButton;
#symptom;
#delegate;
constructor(prrByVaccineTableElement, downloadPrrByVaccineTableButton) {
this.#prrByVaccineTable = new PrrByVaccineTable(prrByVaccineTableElement);
this.#prrByVaccineTable.initialize();
this.#initializeButton(downloadPrrByVaccineTableButton);
this.#delegate = new PrrByKeyTableView(
new PrrByVaccineTable(prrByVaccineTableElement),
downloadPrrByVaccineTableButton,
'Symptom',
PrrByVaccineProvider.getPrrByVaccine);
}
displayPrrByVaccineTable4Symptom(symptom) {
UIUtils.disableButton(this.#downloadPrrByVaccineTableButton);
PrrByVaccineProvider
.getPrrByVaccine(symptom)
.then(prrByVaccine => {
this.#symptom = symptom;
this.#prrByVaccineTable.display(prrByVaccine);
UIUtils.enableButton(this.#downloadPrrByVaccineTableButton);
});
}
#initializeButton(downloadPrrByVaccineTableButton) {
this.#downloadPrrByVaccineTableButton = downloadPrrByVaccineTableButton;
UIUtils.disableButton(downloadPrrByVaccineTableButton);
downloadPrrByVaccineTableButton.addEventListener(
'click',
() => this.#downloadPrrByVaccine())
}
#downloadPrrByVaccine() {
UIUtils.downloadUrlAsFilename(
window.URL.createObjectURL(
new Blob(
[this.#prrByVaccineTable.getDisplayedTableAsCsv('# Symptom: ' + this.#symptom)],
{ type: 'text/csv' })),
this.#symptom
);
this.#delegate.displayPrrByKeyTable4Value(symptom);
}
}