refactoring

This commit is contained in:
Frank Knoll
2024-07-14 02:11:41 +02:00
parent b143949798
commit a8ec099c00
8 changed files with 54 additions and 45 deletions

View File

@@ -27,6 +27,7 @@
<link href="../forkMeOnGitHub.css" rel="stylesheet" type="text/css" />
<script src="../Utils.js"></script>
<script src="../UIUtils.js"></script>
<script src="../UrlUtils.js"></script>
<script src="../NumberWithBarElementFactory.js"></script>
<script src="./js/PrrByKey2CsvConverter.js"></script>
<script src="./js/PageInitializer.js"></script>
@@ -42,22 +43,18 @@
"DOMContentLoaded",
event => {
const name = 'Drug';
const symptomSearchParam = new SearchParam('symptom');
const vaccineSearchParam = new SearchParam('vaccine');
PageInitializer.initializePage(
{
symptom: {
symptomSelectElement: $('#symptomSelect'),
selectSymptom: symptomSearchParam.get(),
onSymptomSelected: symptom => symptomSearchParam.set(symptom),
searchParam: new SearchParam('symptom'),
prrByVaccineTableElement: $('#prrByVaccineTable'),
downloadPrrByVaccineTableButton: document.querySelector("#downloadPrrByVaccineTable"),
keyColumnName: name
},
vaccine: {
vaccineSelectElement: $('#vaccineSelect'),
selectVaccine: vaccineSearchParam.get(),
onVaccineSelected: vaccine => vaccineSearchParam.set(vaccine),
searchParam: new SearchParam('vaccine'),
prrBySymptomTableElement: $('#prrBySymptomTable'),
downloadPrrBySymptomTableButton: document.querySelector("#downloadPrrBySymptomTable"),
valueName: name

View File

@@ -5,29 +5,29 @@ class PageInitializer {
PageInitializer.#configureVaccine(vaccine);
}
static #configureSymptom({ symptomSelectElement, selectSymptom, onSymptomSelected, prrByVaccineTableElement, downloadPrrByVaccineTableButton, keyColumnName }) {
static #configureSymptom({ symptomSelectElement, searchParam, prrByVaccineTableElement, downloadPrrByVaccineTableButton, keyColumnName }) {
const prrByVaccineTableView = new PrrByVaccineTableView(prrByVaccineTableElement, downloadPrrByVaccineTableButton, keyColumnName);
Select2.initializeSelectElement(
{
selectElement: symptomSelectElement,
textOfOption2Select: selectSymptom,
textOfOption2Select: searchParam.get(),
onValueSelected: (id, text) => {
prrByVaccineTableView.displayPrrByVaccineTable4Symptom(id, text);
onSymptomSelected(text);
searchParam.set(text);
},
minimumInputLength: 0
});
}
static #configureVaccine({ vaccineSelectElement, selectVaccine, onVaccineSelected, prrBySymptomTableElement, downloadPrrBySymptomTableButton, valueName }) {
static #configureVaccine({ vaccineSelectElement, searchParam, prrBySymptomTableElement, downloadPrrBySymptomTableButton, valueName }) {
const prrBySymptomTableView = new PrrBySymptomTableView(prrBySymptomTableElement, downloadPrrBySymptomTableButton, valueName);
Select2.initializeSelectElement(
{
selectElement: vaccineSelectElement,
textOfOption2Select: selectVaccine,
textOfOption2Select: searchParam.get(),
onValueSelected: (id, text) => {
prrBySymptomTableView.displayPrrBySymptomTable4Vaccine(id, text);
onVaccineSelected(text);
searchParam.set(text);
},
minimumInputLength: 0
});

View File

@@ -33,7 +33,7 @@ class PrrByKeyTableView {
}
#downloadPrrByKey() {
UIUtils.downloadUrlAsFilename(
UrlUtils.downloadUrlAsFilename(
window.URL.createObjectURL(
new Blob(
[this.#prrByKeyTable.getDisplayedTableAsCsv(`# ${this.#valueName}: ${this.#text}`)],

View File

@@ -7,10 +7,10 @@ class SearchParam {
}
get() {
return UIUtils.getSearchParamOfCurrentUrl(this.#name);
return UrlUtils.getSearchParamOfCurrentUrl(this.#name);
}
set(value) {
UIUtils.setSearchParamOfCurrentUrl(this.#name, value);
UrlUtils.setSearchParamOfCurrentUrl(this.#name, value);
}
}