Neue Verwaltung der Gruppenzuordnung 1:n

This commit is contained in:
concierge committed 2026-10-30 09:02:46 +01:00
1 parent fa02a7ade0
commit 02c017d53d
34 files changed
+1306 -251

No files matched your search

+1 -25
View File
@@ -52,14 +52,12 @@ function deleteGruppe(groupId) {
function openCreateGruppeModal() {
document.getElementById('gruppeAlias').value = '';
document.getElementById('gruppeAccount').value = '';
document.getElementById('createGruppeModal').showModal();
}
function closeCreateGruppeModal() {
document.getElementById('createGruppeModal').close();
document.getElementById('gruppeAlias').value = '';
document.getElementById('gruppeAccount').value = '';
}
function buildStateSelect(state) {
@@ -74,19 +72,6 @@ function buildStateSelect(state) {
return select;
}
function buildAccountSelect(accountId) {
const select = document.createElement('select');
const source = document.getElementById('gruppeAccount');
Array.from(source.options).forEach(option => {
const copy = document.createElement('option');
copy.value = option.value;
copy.textContent = option.textContent;
copy.selected = String(option.value) === String(accountId ?? '');
select.appendChild(copy);
});
return select;
}
function addGruppeRow(gruppe) {
const tbody = document.querySelector('#gruppenTable tbody');
const row = document.createElement('tr');
@@ -112,13 +97,6 @@ function addGruppeRow(gruppe) {
stateCell.appendChild(stateSelect);
row.appendChild(stateCell);
const accountCell = document.createElement('td');
const accountSelect = buildAccountSelect(gruppe.account_id);
accountSelect.addEventListener('change',
() => updateGruppe(gruppe.id, {account_id: accountSelect.value}));
accountCell.appendChild(accountSelect);
row.appendChild(accountCell);
const positionCell = document.createElement('td');
positionCell.className = 'group-position';
positionCell.textContent = formatPosition(gruppe.last_lat, gruppe.last_lon);
@@ -141,12 +119,11 @@ function addGruppeRow(gruppe) {
function createGruppe() {
const aliasname = document.getElementById('gruppeAlias').value;
const accountId = document.getElementById('gruppeAccount').value;
fetch(`${apiBase}/gruppen`, {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({aliasname, account_id: accountId})
body: JSON.stringify({aliasname})
}).then(r => r.json()).then(data => {
if (!data.success) {
showError(data);
@@ -155,7 +132,6 @@ function createGruppe() {
addGruppeRow({
id: data.id,
aliasname: aliasname,
account_id: accountId || null,
state: 'offen',
last_lat: null,
last_lon: null