adding downloadPrrBySymptomTableButton

This commit is contained in:
frankknoll
2023-10-15 14:39:16 +02:00
parent f066966f20
commit ae425cf723
3 changed files with 45 additions and 5 deletions

View File

@@ -48,7 +48,8 @@
},
vaccine: {
vaccineSelectElement: $('#vaccineSelect'),
prrBySymptomTableElement: $('#prrBySymptomTable')
prrBySymptomTableElement: $('#prrBySymptomTable'),
downloadPrrBySymptomTableButton: document.querySelector("#downloadPrrBySymptomTable")
}
}
);
@@ -17811,6 +17812,7 @@
</tr>
</thead>
</table>
<button id="downloadPrrBySymptomTable">Download</button>
</div>
</div>
</div>

View File

@@ -15,8 +15,8 @@ class PageInitializer {
});
}
static #configureVaccine({ vaccineSelectElement, prrBySymptomTableElement }) {
const prrBySymptomTableView = new PrrBySymptomTableView(prrBySymptomTableElement);
static #configureVaccine({ vaccineSelectElement, prrBySymptomTableElement, downloadPrrBySymptomTableButton }) {
const prrBySymptomTableView = new PrrBySymptomTableView(prrBySymptomTableElement, downloadPrrBySymptomTableButton);
PageInitializer.#initializeSelectElement(
{
selectElement: vaccineSelectElement,

View File

@@ -1,15 +1,53 @@
class PrrBySymptomTableView {
#prrBySymptomTable;
#downloadPrrBySymptomTableButton;
#prrBySymptom;
#vaccine;
constructor(prrBySymptomTableElement) {
constructor(prrBySymptomTableElement, downloadPrrBySymptomTableButton) {
this.#prrBySymptomTable = new PrrBySymptomTable(prrBySymptomTableElement);
this.#prrBySymptomTable.initialize();
this.#initializeButton(downloadPrrBySymptomTableButton);
}
displayPrrBySymptomTable4Vaccine(vaccine) {
UIUtils.disableButton(this.#downloadPrrBySymptomTableButton);
PrrByVaccineProvider
.getPrrBySymptom(vaccine)
.then(prrBySymptom => this.#prrBySymptomTable.display(prrBySymptom));
.then(prrBySymptom => {
this.#prrBySymptom = prrBySymptom;
this.#vaccine = vaccine;
this.#prrBySymptomTable.display(prrBySymptom);
UIUtils.enableButton(this.#downloadPrrBySymptomTableButton);
});
}
#initializeButton(downloadPrrBySymptomTableButton) {
this.#downloadPrrBySymptomTableButton = downloadPrrBySymptomTableButton;
UIUtils.disableButton(downloadPrrBySymptomTableButton);
downloadPrrBySymptomTableButton.addEventListener(
'click',
() => this.#downloadPrrBySymptom())
}
#downloadPrrBySymptom() {
UIUtils.downloadUrlAsFilename(
window.URL.createObjectURL(
new Blob(
[
PrrByKey2CsvConverter.convertPrrByKey2Csv(
{
heading: '# Vaccine: ' + this.#vaccine,
columns: {
keyColumn: 'Symptom',
prrColumn: 'Proportional Reporting Ratio > 1'
},
prrByKey: this.#prrBySymptom
})
],
{ type: 'text/csv' })),
this.#vaccine
);
}
}