adding url params vaccine and symptom
This commit is contained in:
@@ -5,34 +5,25 @@ class PageInitializer {
|
||||
PageInitializer.#configureVaccine(vaccine);
|
||||
}
|
||||
|
||||
static #configureSymptom({ symptomSelectElement, prrByVaccineTableElement, downloadPrrByVaccineTableButton, keyColumnName }) {
|
||||
static #configureSymptom({ symptomSelectElement, selectSymptom, prrByVaccineTableElement, downloadPrrByVaccineTableButton, keyColumnName }) {
|
||||
const prrByVaccineTableView = new PrrByVaccineTableView(prrByVaccineTableElement, downloadPrrByVaccineTableButton, keyColumnName);
|
||||
PageInitializer.#initializeSelectElement(
|
||||
Select2.initializeSelectElement(
|
||||
{
|
||||
selectElement: symptomSelectElement,
|
||||
textOfOption2Select: selectSymptom,
|
||||
onValueSelected: (id, text) => prrByVaccineTableView.displayPrrByVaccineTable4Symptom(id, text),
|
||||
minimumInputLength: 0
|
||||
});
|
||||
}
|
||||
|
||||
static #configureVaccine({ vaccineSelectElement, prrBySymptomTableElement, downloadPrrBySymptomTableButton, valueName }) {
|
||||
static #configureVaccine({ vaccineSelectElement, selectVaccine, prrBySymptomTableElement, downloadPrrBySymptomTableButton, valueName }) {
|
||||
const prrBySymptomTableView = new PrrBySymptomTableView(prrBySymptomTableElement, downloadPrrBySymptomTableButton, valueName);
|
||||
PageInitializer.#initializeSelectElement(
|
||||
Select2.initializeSelectElement(
|
||||
{
|
||||
selectElement: vaccineSelectElement,
|
||||
onValueSelected: (id, text) => prrBySymptomTableView.displayPrrBySymptomTable4Vaccine(id ,text),
|
||||
textOfOption2Select: selectVaccine,
|
||||
onValueSelected: (id, text) => prrBySymptomTableView.displayPrrBySymptomTable4Vaccine(id, text),
|
||||
minimumInputLength: 0
|
||||
});
|
||||
}
|
||||
|
||||
static #initializeSelectElement({ selectElement, onValueSelected, minimumInputLength }) {
|
||||
selectElement.select2({ minimumInputLength: minimumInputLength });
|
||||
selectElement.on(
|
||||
'select2:select',
|
||||
function (event) {
|
||||
const id = event.params.data.id;
|
||||
const text = event.params.data.text;
|
||||
onValueSelected(id, text);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
45
docs/SymptomsCausedByDrugs/js/Select2.js
Normal file
45
docs/SymptomsCausedByDrugs/js/Select2.js
Normal file
@@ -0,0 +1,45 @@
|
||||
class Select2 {
|
||||
|
||||
// FK-TODO: rename onValueSelected to onSelectOptionHavingValueAndText
|
||||
static initializeSelectElement({ selectElement, textOfOption2Select, onValueSelected, minimumInputLength }) {
|
||||
selectElement.select2({ minimumInputLength: minimumInputLength });
|
||||
selectElement.on(
|
||||
'select2:select',
|
||||
function (event) {
|
||||
const id = event.params.data.id;
|
||||
const text = event.params.data.text;
|
||||
onValueSelected(id, text);
|
||||
});
|
||||
Select2.#selectOptionHavingText(selectElement, textOfOption2Select);
|
||||
}
|
||||
|
||||
static #selectOptionHavingText(selectElement, text) {
|
||||
const option = Select2.#getOptionHavingText(selectElement, text);
|
||||
if (option === undefined) {
|
||||
return;
|
||||
}
|
||||
Select2.#selectOption(selectElement, option);
|
||||
}
|
||||
|
||||
static #getOptionHavingText(selectElement, text) {
|
||||
if (text === null) {
|
||||
return undefined;
|
||||
}
|
||||
return Array
|
||||
.from(selectElement[0].options)
|
||||
.find(option => option.text == text);
|
||||
}
|
||||
|
||||
static #selectOption(selectElement, option) {
|
||||
selectElement.val(option.value).trigger('change');
|
||||
selectElement.trigger({
|
||||
type: 'select2:select',
|
||||
params: {
|
||||
data: {
|
||||
"id": option.value,
|
||||
"text": option.text
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user