refactoring

This commit is contained in:
Frank Knoll
2024-07-14 21:39:49 +02:00
parent c9b76253ff
commit d1d9d29651
5 changed files with 6 additions and 7 deletions

View File

@@ -28,6 +28,8 @@
<script src="../Utils.js"></script>
<script src="../UIUtils.js"></script>
<script src="../UrlUtils.js"></script>
<script src="../URLSearchParam.js"></script>
<script src="../Select2.js"></script>
<script src="../NumberWithBarElementFactory.js"></script>
<script src="./js/PrrByKey2CsvConverter.js"></script>
<script src="./js/PageInitializer.js"></script>
@@ -36,8 +38,6 @@
<script src="./js/PrrByKeyTableView.js"></script>
<script src="./js/PrrByVaccineTableView.js"></script>
<script src="./js/PrrBySymptomTableView.js"></script>
<script src="./js/URLSearchParam.js"></script>
<script src="./js/Select2.js"></script>
<script>
document.addEventListener(
"DOMContentLoaded",

View File

@@ -1,50 +0,0 @@
class Select2 {
static initializeSelectElement(
{
selectElement,
textOfOption2Select,
onSelectOptionHavingValueAndText,
minimumInputLength
}) {
selectElement.select2({ minimumInputLength: minimumInputLength });
selectElement.on(
'select2:select',
function (event) {
const id = event.params.data.id;
const text = event.params.data.text;
onSelectOptionHavingValueAndText(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
}
}
});
}
}

View File

@@ -1,16 +0,0 @@
class URLSearchParam {
#name;
constructor(name) {
this.#name = name;
}
get() {
return UrlUtils.getSearchParamOfCurrentUrl(this.#name);
}
set(value) {
UrlUtils.setSearchParamOfCurrentUrl(this.#name, value);
}
}