refactoring
This commit is contained in:
@@ -47,6 +47,7 @@
|
|||||||
symptom: {
|
symptom: {
|
||||||
symptomSelectElement: $('#symptomSelect'),
|
symptomSelectElement: $('#symptomSelect'),
|
||||||
selectSymptom: UIUtils.getSearchParam(urlSearchParams, 'symptom', null),
|
selectSymptom: UIUtils.getSearchParam(urlSearchParams, 'symptom', null),
|
||||||
|
onSymptomSelected: symptom => UIUtils.setSearchParamOfCurrentUrl('symptom', symptom),
|
||||||
prrByVaccineTableElement: $('#prrByVaccineTable'),
|
prrByVaccineTableElement: $('#prrByVaccineTable'),
|
||||||
downloadPrrByVaccineTableButton: document.querySelector("#downloadPrrByVaccineTable"),
|
downloadPrrByVaccineTableButton: document.querySelector("#downloadPrrByVaccineTable"),
|
||||||
keyColumnName: name
|
keyColumnName: name
|
||||||
@@ -54,6 +55,7 @@
|
|||||||
vaccine: {
|
vaccine: {
|
||||||
vaccineSelectElement: $('#vaccineSelect'),
|
vaccineSelectElement: $('#vaccineSelect'),
|
||||||
selectVaccine: UIUtils.getSearchParam(urlSearchParams, 'vaccine', null),
|
selectVaccine: UIUtils.getSearchParam(urlSearchParams, 'vaccine', null),
|
||||||
|
onVaccineSelected: vaccine => UIUtils.setSearchParamOfCurrentUrl('vaccine', vaccine),
|
||||||
prrBySymptomTableElement: $('#prrBySymptomTable'),
|
prrBySymptomTableElement: $('#prrBySymptomTable'),
|
||||||
downloadPrrBySymptomTableButton: document.querySelector("#downloadPrrBySymptomTable"),
|
downloadPrrBySymptomTableButton: document.querySelector("#downloadPrrBySymptomTable"),
|
||||||
valueName: name
|
valueName: name
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ class PageInitializer {
|
|||||||
PageInitializer.#configureVaccine(vaccine);
|
PageInitializer.#configureVaccine(vaccine);
|
||||||
}
|
}
|
||||||
|
|
||||||
static #configureSymptom({ symptomSelectElement, selectSymptom, prrByVaccineTableElement, downloadPrrByVaccineTableButton, keyColumnName }) {
|
static #configureSymptom({ symptomSelectElement, selectSymptom, onSymptomSelected, prrByVaccineTableElement, downloadPrrByVaccineTableButton, keyColumnName }) {
|
||||||
const prrByVaccineTableView = new PrrByVaccineTableView(prrByVaccineTableElement, downloadPrrByVaccineTableButton, keyColumnName);
|
const prrByVaccineTableView = new PrrByVaccineTableView(prrByVaccineTableElement, downloadPrrByVaccineTableButton, keyColumnName);
|
||||||
Select2.initializeSelectElement(
|
Select2.initializeSelectElement(
|
||||||
{
|
{
|
||||||
@@ -13,15 +13,13 @@ class PageInitializer {
|
|||||||
textOfOption2Select: selectSymptom,
|
textOfOption2Select: selectSymptom,
|
||||||
onValueSelected: (id, text) => {
|
onValueSelected: (id, text) => {
|
||||||
prrByVaccineTableView.displayPrrByVaccineTable4Symptom(id, text);
|
prrByVaccineTableView.displayPrrByVaccineTable4Symptom(id, text);
|
||||||
const url = new URL(window.location.href);
|
onSymptomSelected(text);
|
||||||
url.searchParams.set('symptom', text);
|
|
||||||
window.history.replaceState(null, "", url);
|
|
||||||
},
|
},
|
||||||
minimumInputLength: 0
|
minimumInputLength: 0
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static #configureVaccine({ vaccineSelectElement, selectVaccine, prrBySymptomTableElement, downloadPrrBySymptomTableButton, valueName }) {
|
static #configureVaccine({ vaccineSelectElement, selectVaccine, onVaccineSelected, prrBySymptomTableElement, downloadPrrBySymptomTableButton, valueName }) {
|
||||||
const prrBySymptomTableView = new PrrBySymptomTableView(prrBySymptomTableElement, downloadPrrBySymptomTableButton, valueName);
|
const prrBySymptomTableView = new PrrBySymptomTableView(prrBySymptomTableElement, downloadPrrBySymptomTableButton, valueName);
|
||||||
Select2.initializeSelectElement(
|
Select2.initializeSelectElement(
|
||||||
{
|
{
|
||||||
@@ -29,9 +27,7 @@ class PageInitializer {
|
|||||||
textOfOption2Select: selectVaccine,
|
textOfOption2Select: selectVaccine,
|
||||||
onValueSelected: (id, text) => {
|
onValueSelected: (id, text) => {
|
||||||
prrBySymptomTableView.displayPrrBySymptomTable4Vaccine(id, text);
|
prrBySymptomTableView.displayPrrBySymptomTable4Vaccine(id, text);
|
||||||
const url = new URL(window.location.href);
|
onVaccineSelected(text);
|
||||||
url.searchParams.set('vaccine', text);
|
|
||||||
window.history.replaceState(null, "", url);
|
|
||||||
},
|
},
|
||||||
minimumInputLength: 0
|
minimumInputLength: 0
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -38,6 +38,12 @@ class UIUtils {
|
|||||||
return UIUtils.getSearchParam(urlParams, searchParam, 'NO').toUpperCase() == 'YES';
|
return UIUtils.getSearchParam(urlParams, searchParam, 'NO').toUpperCase() == 'YES';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static setSearchParamOfCurrentUrl(nameOfSearchParam, valueOfSearchParam) {
|
||||||
|
const url = new URL(window.location.href);
|
||||||
|
url.searchParams.set(nameOfSearchParam, valueOfSearchParam);
|
||||||
|
window.history.replaceState(null, "", url);
|
||||||
|
}
|
||||||
|
|
||||||
static downloadUrlAsFilename(url, filename) {
|
static downloadUrlAsFilename(url, filename) {
|
||||||
const a = document.createElement('a');
|
const a = document.createElement('a');
|
||||||
a.setAttribute('href', url);
|
a.setAttribute('href', url);
|
||||||
|
|||||||
Reference in New Issue
Block a user