enabling and disabling downloadPrrByVaccineTableButton
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user