|
|
@@ -0,0 +1,291 @@
|
|
|
+// UI-Update-Funktionen für Miete
|
|
|
+
|
|
|
+function updateAfterVorgangChange(data) {
|
|
|
+ // Hidden fields aktualisieren
|
|
|
+ document.getElementById('leftVorgangId').value = data.newLeftVorgangId || data.leftVorgangId;
|
|
|
+ document.getElementById('leftZeitraumId').value = data.newLeftZeitraumId || data.leftZeitraumId;
|
|
|
+
|
|
|
+ // Vorgang-Dropdown aktualisieren (falls erforderlich)
|
|
|
+ const vorgangSelect = document.getElementById('leftVorgangSelect');
|
|
|
+ if (vorgangSelect && (data.newLeftVorgangId || data.leftVorgangId)) {
|
|
|
+ const newVorgangId = data.newLeftVorgangId || data.leftVorgangId;
|
|
|
+ if (vorgangSelect.value !== newVorgangId) {
|
|
|
+ vorgangSelect.value = newVorgangId;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Zeitraum-Dropdown aktualisieren
|
|
|
+ const zeitraumSelect = document.getElementById('leftZeitraumSelect');
|
|
|
+ if (zeitraumSelect && (data.leftZeitraeumeOfSelected || data.leftZeitraeume)) {
|
|
|
+ zeitraumSelect.innerHTML = '';
|
|
|
+ const zeitraeume = data.leftZeitraeumeOfSelected || data.leftZeitraeume;
|
|
|
+ zeitraeume.forEach(zeitraum => {
|
|
|
+ const option = document.createElement('option');
|
|
|
+ option.value = zeitraum.id;
|
|
|
+ option.textContent = zeitraum.beginn + ' - ' + zeitraum.ende;
|
|
|
+ if (zeitraum.id === (data.newLeftZeitraumId || data.leftZeitraumId)) {
|
|
|
+ option.selected = true;
|
|
|
+ }
|
|
|
+ zeitraumSelect.appendChild(option);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
+ // Miete-spezifische Updates
|
|
|
+ updateMieteTables(data);
|
|
|
+}
|
|
|
+
|
|
|
+function updateAfterZeitraumChange(data) {
|
|
|
+ // Hidden field aktualisieren
|
|
|
+ document.getElementById('leftZeitraumId').value = data.newLeftZeitraumId || data.leftZeitraumId;
|
|
|
+
|
|
|
+ // Zeitraum-Dropdown aktualisieren (falls erforderlich)
|
|
|
+ const zeitraumSelect = document.getElementById('leftZeitraumSelect');
|
|
|
+ if (zeitraumSelect) {
|
|
|
+ const newZeitraumId = data.newLeftZeitraumId || data.leftZeitraumId;
|
|
|
+ if (zeitraumSelect.value !== newZeitraumId) {
|
|
|
+ zeitraumSelect.value = newZeitraumId;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Miete-spezifische Updates
|
|
|
+ updateMieteTables(data);
|
|
|
+}
|
|
|
+
|
|
|
+function updateMieteTables(data) {
|
|
|
+ // Wohnung-Tabelle aktualisieren
|
|
|
+ if (data.wohnungZeile) {
|
|
|
+ updateWohnungTable(data.wohnungZeile);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Miete-Tabelle aktualisieren
|
|
|
+ if (data.mieteZeile) {
|
|
|
+ updateMieteTable(data.mieteZeile);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Untermieter-Tabelle aktualisieren
|
|
|
+ if (data.untermieterZeilen) {
|
|
|
+ updateUntermieterTable(data.untermieterZeilen);
|
|
|
+ }
|
|
|
+
|
|
|
+ // Mitbewohner-Tabelle aktualisieren
|
|
|
+ if (data.mitbewohnerZeilen) {
|
|
|
+ updateMitbewohnerTable(data.mitbewohnerZeilen);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function updateWohnungTable(wohnungZeile) {
|
|
|
+ const wohnungContainer = document.querySelector('#wohnung-content .wohnung-grid-table');
|
|
|
+ if (!wohnungContainer) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Update der Tabellenzellen basierend auf der Template-Struktur
|
|
|
+ const rows = wohnungContainer.querySelectorAll('tr');
|
|
|
+
|
|
|
+ if (rows.length >= 2) {
|
|
|
+ // Erste Zeile
|
|
|
+ const firstRowCells = rows[0].querySelectorAll('.value-cell');
|
|
|
+ if (firstRowCells.length >= 5) {
|
|
|
+ firstRowCells[0].innerHTML = wohnungZeile.mietverhaeltnisHtml || '';
|
|
|
+ firstRowCells[1].innerHTML = wohnungZeile.flaecheHtml || '';
|
|
|
+ firstRowCells[2].innerHTML = wohnungZeile.badHtml || '';
|
|
|
+ firstRowCells[3].innerHTML = wohnungZeile.nameEigHtml || '';
|
|
|
+ firstRowCells[4].innerHTML = wohnungZeile.telefonEigHtml || '';
|
|
|
+ }
|
|
|
+
|
|
|
+ // Zweite Zeile
|
|
|
+ const secondRowCells = rows[1].querySelectorAll('.value-cell');
|
|
|
+ if (secondRowCells.length >= 4) {
|
|
|
+ secondRowCells[0].innerHTML = wohnungZeile.sozBauJnHtml || '';
|
|
|
+ secondRowCells[1].innerHTML = wohnungZeile.fertigDatHtml || '';
|
|
|
+ secondRowCells[2].innerHTML = wohnungZeile.heizungHtml || '';
|
|
|
+ secondRowCells[3].innerHTML = wohnungZeile.adresseEigHtml || '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Container-Klasse aktualisieren
|
|
|
+ const container = wohnungContainer.closest('div');
|
|
|
+ if (container && wohnungZeile.rowClass) {
|
|
|
+ container.className = wohnungZeile.rowClass;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function updateMieteTable(mieteZeile) {
|
|
|
+ const mieteContainer = document.querySelector('#miete-content .miete-grid-table');
|
|
|
+ if (!mieteContainer) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // Die Miete-Tabelle hat eine komplexe Struktur - wir aktualisieren nur die Werte
|
|
|
+ const tbody = mieteContainer.querySelector('tbody');
|
|
|
+ if (!tbody) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const rows = tbody.querySelectorAll('tr');
|
|
|
+
|
|
|
+ if (rows.length >= 9) {
|
|
|
+ // Erste Zeile: * Gesamtmiete, Heizung, Heizungspauschale
|
|
|
+ if (rows[0]) {
|
|
|
+ const row1Cells = rows[0].querySelectorAll('.value-cell, .pauschale-cell');
|
|
|
+ if (row1Cells.length >= 3) {
|
|
|
+ row1Cells[0].innerHTML = mieteZeile.gesamtmieteHtml || '';
|
|
|
+ row1Cells[1].innerHTML = mieteZeile.heizungHtml || '';
|
|
|
+ row1Cells[2].innerHTML = mieteZeile.heizungPauschaleHtml || '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Zweite Zeile: Zuschläge, Warmwasser, Warmwasserpauschale
|
|
|
+ if (rows[1]) {
|
|
|
+ const row2Cells = rows[1].querySelectorAll('.value-cell, .pauschale-cell');
|
|
|
+ if (row2Cells.length >= 3) {
|
|
|
+ row2Cells[0].innerHTML = mieteZeile.zuschlägeHtml || '';
|
|
|
+ row2Cells[1].innerHTML = mieteZeile.warmwasserHtml || '';
|
|
|
+ row2Cells[2].innerHTML = mieteZeile.warmwasserPauschaleHtml || '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Dritte Zeile: Art des Zuschlages, Kosten HH-Energie, Energiepauschale
|
|
|
+ if (rows[2]) {
|
|
|
+ const row3Cells = rows[2].querySelectorAll('.value-cell, .pauschale-cell');
|
|
|
+ if (row3Cells.length >= 3) {
|
|
|
+ row3Cells[0].innerHTML = mieteZeile.artZuschlagHtml || '';
|
|
|
+ row3Cells[1].innerHTML = mieteZeile.kostenHhEnergieHtml || '';
|
|
|
+ row3Cells[2].innerHTML = mieteZeile.energiePauschaleHtml || '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Vierte Zeile: Garage/Stellplatz, Stellplatzpauschale
|
|
|
+ if (rows[3]) {
|
|
|
+ const row4Cells = rows[3].querySelectorAll('.value-cell, .pauschale-cell');
|
|
|
+ if (row4Cells.length >= 2) {
|
|
|
+ row4Cells[0].innerHTML = mieteZeile.stellplatzHtml || '';
|
|
|
+ row4Cells[1].innerHTML = mieteZeile.stellplatzPauschaleHtml || '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Fünfte Zeile: Fernwärme, Möblierungszuschläge, Möblierungspauschale
|
|
|
+ if (rows[4]) {
|
|
|
+ const row5Cells = rows[4].querySelectorAll('.value-cell, .pauschale-cell');
|
|
|
+ if (row5Cells.length >= 3) {
|
|
|
+ row5Cells[0].innerHTML = mieteZeile.jhrlFernwaermeHtml || '';
|
|
|
+ row5Cells[1].innerHTML = mieteZeile.moeblierungszuschlagHtml || '';
|
|
|
+ row5Cells[2].innerHTML = mieteZeile.moeblierungPauschaleHtml || '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Sechste Zeile: Fernwarmwasser, Gewerbezuschläge, Gewerbepauschale, Gewerbefläche
|
|
|
+ if (rows[5]) {
|
|
|
+ const row6Cells = rows[5].querySelectorAll('.value-cell, .pauschale-cell, .gewerbefläche-cell');
|
|
|
+ if (row6Cells.length >= 4) {
|
|
|
+ row6Cells[0].innerHTML = mieteZeile.jhrlFernwarmwasserHtml || '';
|
|
|
+ row6Cells[1].innerHTML = mieteZeile.gewerbezuschlagHtml || '';
|
|
|
+ row6Cells[2].innerHTML = mieteZeile.gewerbePauschaleHtml || '';
|
|
|
+ row6Cells[3].innerHTML = mieteZeile.gewerbeflaecheHtml || '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Siebte Zeile: Fernwärme und -warmwasser, Untermietzuschläge
|
|
|
+ if (rows[6]) {
|
|
|
+ const row7Cells = rows[6].querySelectorAll('.value-cell');
|
|
|
+ if (row7Cells.length >= 2) {
|
|
|
+ row7Cells[0].innerHTML = mieteZeile.jhrlFernwUndWHtml || '';
|
|
|
+ row7Cells[1].innerHTML = mieteZeile.untermietzuschlagHtml || '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Achte Zeile: sonstige Zuschläge, sonstige Pauschale
|
|
|
+ if (rows[7]) {
|
|
|
+ const row8Cells = rows[7].querySelectorAll('.value-cell, .pauschale-cell');
|
|
|
+ if (row8Cells.length >= 2) {
|
|
|
+ row8Cells[0].innerHTML = mieteZeile.sonstZuschlagHtml || '';
|
|
|
+ row8Cells[1].innerHTML = mieteZeile.sonstPauschaleHtml || '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Neunte Zeile: Leistungen Dritter
|
|
|
+ if (rows[8]) {
|
|
|
+ const row9Cells = rows[8].querySelectorAll('.value-cell');
|
|
|
+ if (row9Cells.length >= 1) {
|
|
|
+ row9Cells[0].innerHTML = mieteZeile.leistungenDritterHtml || '';
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ // Container-Klasse aktualisieren
|
|
|
+ const container = mieteContainer.closest('div');
|
|
|
+ if (container && mieteZeile.rowClass) {
|
|
|
+ container.className = mieteZeile.rowClass;
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+function updateUntermieterTable(untermieterZeilen) {
|
|
|
+ const table = document.getElementById('untermieter-table');
|
|
|
+ if (!table) return;
|
|
|
+
|
|
|
+ const tbody = table.querySelector('tbody');
|
|
|
+ tbody.innerHTML = '';
|
|
|
+
|
|
|
+ untermieterZeilen.forEach(zeile => {
|
|
|
+ const tr = document.createElement('tr');
|
|
|
+ tr.className = zeile.rowClass || '';
|
|
|
+
|
|
|
+ // Symbol-Spalte
|
|
|
+ const symbolTd = document.createElement('td');
|
|
|
+ symbolTd.className = 'sym ' + (zeile.symbolClass || '');
|
|
|
+ symbolTd.textContent = zeile.symbol || '';
|
|
|
+ const ariaLabel = zeile.symbol === '+' ? 'Hinzugefügt' :
|
|
|
+ (zeile.symbol === '-' ? 'Gelöscht' :
|
|
|
+ (zeile.symbol === '!' ? 'Geändert' : 'Unverändert'));
|
|
|
+ symbolTd.setAttribute('aria-label', ariaLabel);
|
|
|
+ tr.appendChild(symbolTd);
|
|
|
+
|
|
|
+ // Alle Spalten entsprechend der Template-Struktur
|
|
|
+ const columns = ['nameHtml', 'vornameHtml', 'mieteHtml', 'flaecheHtml', 'sonstHtml',
|
|
|
+ 'heizungHtml', 'heizungPHtml', 'warmwasserHtml', 'warmwasserPHtml',
|
|
|
+ 'moeblierungHtml', 'moeblierungPHtml'];
|
|
|
+
|
|
|
+ columns.forEach(column => {
|
|
|
+ const td = document.createElement('td');
|
|
|
+ td.innerHTML = zeile[column] || '';
|
|
|
+ tr.appendChild(td);
|
|
|
+ });
|
|
|
+
|
|
|
+ tbody.appendChild(tr);
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+function updateMitbewohnerTable(mitbewohnerZeilen) {
|
|
|
+ const table = document.getElementById('mitbewohner-table');
|
|
|
+ if (!table) return;
|
|
|
+
|
|
|
+ const tbody = table.querySelector('tbody');
|
|
|
+ tbody.innerHTML = '';
|
|
|
+
|
|
|
+ mitbewohnerZeilen.forEach(zeile => {
|
|
|
+ const tr = document.createElement('tr');
|
|
|
+ tr.className = zeile.rowClass || '';
|
|
|
+
|
|
|
+ // Symbol-Spalte
|
|
|
+ const symbolTd = document.createElement('td');
|
|
|
+ symbolTd.className = 'sym ' + (zeile.symbolClass || '');
|
|
|
+ symbolTd.textContent = zeile.symbol || '';
|
|
|
+ const ariaLabel = zeile.symbol === '+' ? 'Hinzugefügt' :
|
|
|
+ (zeile.symbol === '-' ? 'Gelöscht' :
|
|
|
+ (zeile.symbol === '!' ? 'Geändert' : 'Unverändert'));
|
|
|
+ symbolTd.setAttribute('aria-label', ariaLabel);
|
|
|
+ tr.appendChild(symbolTd);
|
|
|
+
|
|
|
+ // Alle Spalten entsprechend der Template-Struktur
|
|
|
+ const columns = ['nameHtml', 'vornameHtml', 'entgeltHtml', 'sonstHtml',
|
|
|
+ 'heizungHtml', 'heizungPHtml', 'warmwasserHtml', 'warmwasserPHtml'];
|
|
|
+
|
|
|
+ columns.forEach(column => {
|
|
|
+ const td = document.createElement('td');
|
|
|
+ td.innerHTML = zeile[column] || '';
|
|
|
+ tr.appendChild(td);
|
|
|
+ });
|
|
|
+
|
|
|
+ tbody.appendChild(tr);
|
|
|
+ });
|
|
|
+}
|