diff --git a/docs/SymptomsCausedByVaccines/js/PrrByVaccineTableView.js b/docs/SymptomsCausedByVaccines/js/PrrByVaccineTableView.js index 5aa012c9d00..3c3fa9d0158 100644 --- a/docs/SymptomsCausedByVaccines/js/PrrByVaccineTableView.js +++ b/docs/SymptomsCausedByVaccines/js/PrrByVaccineTableView.js @@ -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( diff --git a/docs/UIUtils.js b/docs/UIUtils.js index bc113a0c328..4b939b18526 100644 --- a/docs/UIUtils.js +++ b/docs/UIUtils.js @@ -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); }