1
0
mirror of https://github.com/KubaPro010/fm-dx-webserver.git synced 2026-02-26 22:13:53 +01:00

plugins list hotfix

This commit is contained in:
Marek Farkaš
2025-02-09 18:27:12 +01:00
parent ceb6e1bd11
commit 05addcf82d
2 changed files with 22 additions and 29 deletions

View File

@@ -45,9 +45,25 @@ function populateFields(data, prefix = "") {
let id = `${prefix}${prefix ? "-" : ""}${key}`;
const $element = $(`#${id}`);
if (key === "plugins" && $element.is('select[multiple]')) {
if (Array.isArray(value)) {
$element.find('option').each(function() {
const $option = $(this);
const dataName = $option.data('name');
if (value.includes(dataName)) {
$option.prop('selected', true);
} else {
$option.prop('selected', false);
}
});
$element.trigger('change');
}
return;
}
if (typeof value === "object" && value !== null) {
if (Array.isArray(value)) {
// Handle arrays correctly
value.forEach((item, index) => {
const arrayId = `${id}-${index + 1}`;
const $arrayElement = $(`#${arrayId}`);
@@ -60,7 +76,6 @@ function populateFields(data, prefix = "") {
});
return;
} else {
// Handle nested objects
populateFields(value, id);
return;
}
@@ -107,7 +122,7 @@ function updateConfigData(data, prefix = "") {
data[key] = [];
const $selectedOptions = $element.find('option:selected');
$selectedOptions.each(function() {
const dataName = $(this).data('name');
const dataName = $(this).attr('data-name');
if (dataName) {
data[key].push(dataName);
}