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 { class PrrByVaccineTableView {
#prrByVaccineTable; #prrByVaccineTable;
#downloadPrrByVaccineTableButton;
#prrByVaccine; #prrByVaccine;
#symptom; #symptom;
constructor(prrByVaccineTableElement, downloadPrrByVaccineTableButton) { constructor(prrByVaccineTableElement, downloadPrrByVaccineTableButton) {
this.#prrByVaccineTable = new PrrByVaccineTable(prrByVaccineTableElement); this.#prrByVaccineTable = new PrrByVaccineTable(prrByVaccineTableElement);
this.#prrByVaccineTable.initialize(); this.#prrByVaccineTable.initialize();
downloadPrrByVaccineTableButton.addEventListener( this.#initializeButton(downloadPrrByVaccineTableButton);
'click',
() => this.#downloadPrrByVaccine())
} }
displayPrrByVaccineTable4Symptom(symptom) { displayPrrByVaccineTable4Symptom(symptom) {
UIUtils.disableButton(this.#downloadPrrByVaccineTableButton);
PrrByVaccineProvider PrrByVaccineProvider
.getPrrByVaccine(symptom) .getPrrByVaccine(symptom)
.then(prrByVaccine => { .then(prrByVaccine => {
this.#prrByVaccine = prrByVaccine; this.#prrByVaccine = prrByVaccine;
this.#symptom = symptom; this.#symptom = symptom;
this.#prrByVaccineTable.display(prrByVaccine); this.#prrByVaccineTable.display(prrByVaccine);
UIUtils.enableButton(this.#downloadPrrByVaccineTableButton);
}); });
} }
#initializeButton(downloadPrrByVaccineTableButton) {
this.#downloadPrrByVaccineTableButton = downloadPrrByVaccineTableButton;
UIUtils.disableButton(downloadPrrByVaccineTableButton);
downloadPrrByVaccineTableButton.addEventListener(
'click',
() => this.#downloadPrrByVaccine())
}
#downloadPrrByVaccine() { #downloadPrrByVaccine() {
UIUtils.downloadUrlAsFilename( UIUtils.downloadUrlAsFilename(
window.URL.createObjectURL( window.URL.createObjectURL(

View File

@@ -1,5 +1,21 @@
class UIUtils { 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) { static instantiateTemplate(templateId) {
return document.getElementById(templateId).content.firstElementChild.cloneNode(true); return document.getElementById(templateId).content.firstElementChild.cloneNode(true);
} }