refactoring

This commit is contained in:
Frank Knoll
2024-07-14 10:26:36 +02:00
parent a9d76d36fa
commit 6d8592db65
2 changed files with 10 additions and 5 deletions

View File

@@ -11,7 +11,7 @@ class PageInitializer {
{ {
selectElement: symptomSelectElement, selectElement: symptomSelectElement,
textOfOption2Select: searchParam.get(), textOfOption2Select: searchParam.get(),
onValueSelected: (id, text) => { onSelectOptionHavingValueAndText: (id, text) => {
prrByVaccineTableView.displayPrrByVaccineTable4Symptom(id, text); prrByVaccineTableView.displayPrrByVaccineTable4Symptom(id, text);
searchParam.set(text); searchParam.set(text);
}, },
@@ -25,7 +25,7 @@ class PageInitializer {
{ {
selectElement: vaccineSelectElement, selectElement: vaccineSelectElement,
textOfOption2Select: searchParam.get(), textOfOption2Select: searchParam.get(),
onValueSelected: (id, text) => { onSelectOptionHavingValueAndText: (id, text) => {
prrBySymptomTableView.displayPrrBySymptomTable4Vaccine(id, text); prrBySymptomTableView.displayPrrBySymptomTable4Vaccine(id, text);
searchParam.set(text); searchParam.set(text);
}, },

View File

@@ -1,14 +1,19 @@
class Select2 { class Select2 {
// FK-TODO: rename onValueSelected to onSelectOptionHavingValueAndText static initializeSelectElement(
static initializeSelectElement({ selectElement, textOfOption2Select, onValueSelected, minimumInputLength }) { {
selectElement,
textOfOption2Select,
onSelectOptionHavingValueAndText,
minimumInputLength
}) {
selectElement.select2({ minimumInputLength: minimumInputLength }); selectElement.select2({ minimumInputLength: minimumInputLength });
selectElement.on( selectElement.on(
'select2:select', 'select2:select',
function (event) { function (event) {
const id = event.params.data.id; const id = event.params.data.id;
const text = event.params.data.text; const text = event.params.data.text;
onValueSelected(id, text); onSelectOptionHavingValueAndText(id, text);
}); });
Select2.#selectOptionHavingText(selectElement, textOfOption2Select); Select2.#selectOptionHavingText(selectElement, textOfOption2Select);
} }