enabling and disabling downloadPrrByVaccineTableButton

This commit is contained in:
frankknoll
2023-10-15 12:23:31 +02:00
parent c5c3b53eb8
commit 08f258979c
2 changed files with 28 additions and 3 deletions

View File

@@ -1,27 +1,36 @@
class PrrByVaccineTableView {
#prrByVaccineTable;
#downloadPrrByVaccineTableButton;
#prrByVaccine;
#symptom;
constructor(prrByVaccineTableElement, downloadPrrByVaccineTableButton) {
this.#prrByVaccineTable = new PrrByVaccineTable(prrByVaccineTableElement);
this.#prrByVaccineTable.initialize();
downloadPrrByVaccineTableButton.addEventListener(
'click',
() => this.#downloadPrrByVaccine())
this.#initializeButton(downloadPrrByVaccineTableButton);
}
displayPrrByVaccineTable4Symptom(symptom) {
UIUtils.disableButton(this.#downloadPrrByVaccineTableButton);
PrrByVaccineProvider
.getPrrByVaccine(symptom)
.then(prrByVaccine => {
this.#prrByVaccine = 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(

View File

@@ -1,5 +1,21 @@
class UIUtils {
static show(element) {
element.style.display = "block";
}
static hide(element) {
element.style.display = "none";
}
static disableButton(button) {
button.disabled = true;
}
static enableButton(button) {
button.disabled = false;
}
static instantiateTemplate(templateId) {
return document.getElementById(templateId).content.firstElementChild.cloneNode(true);
}