Fehler in der Ansicht

This commit is contained in:
Eduard Wisch 2026-02-11 16:47:01 +01:00
parent 6be50395e5
commit 10dbf420c3

View file

@ -4584,6 +4584,14 @@
self.showBusbarPopup(connectionId, e.clientX, e.clientY);
});
// Hutschiene (rail) click - show edit popup
$(document).off('click.rail').on('click.rail', '.schematic-rail', function(e) {
e.preventDefault();
e.stopPropagation();
var carrierId = $(this).data('carrier-id');
self.showCarrierPopup(carrierId, e.clientX, e.clientY);
});
// Terminal right-click - show output/cable dialog
$(document).off('contextmenu.terminal').on('contextmenu.terminal', '.schematic-terminal', function(e) {
e.preventDefault();
@ -4704,6 +4712,142 @@
$('.schematic-busbar-popup').remove();
},
showCarrierPopup: function(carrierId, x, y) {
var self = this;
this.hideCarrierPopup();
var carrier = this.carriers.find(function(c) { return String(c.id) === String(carrierId); });
if (!carrier) return;
var html = '<div class="schematic-carrier-popup" style="position:fixed;left:' + x + 'px;top:' + y + 'px;background:#2d2d44;border:1px solid #555;border-radius:6px;padding:10px;z-index:100002;min-width:180px;">';
html += '<div style="color:#fff;font-weight:bold;margin-bottom:8px;">Hutschiene</div>';
html += '<div style="color:#aaa;font-size:12px;margin-bottom:8px;">' + this.escapeHtml(carrier.label || 'Ohne Name') + ' (' + carrier.total_te + ' TE)</div>';
html += '<div style="display:flex;gap:8px;">';
html += '<button class="carrier-edit-btn" data-id="' + carrierId + '" style="flex:1;background:#3498db;color:#fff;border:none;border-radius:4px;padding:6px 10px;cursor:pointer;">Bearbeiten</button>';
html += '<button class="carrier-delete-btn" data-id="' + carrierId + '" style="flex:1;background:#e74c3c;color:#fff;border:none;border-radius:4px;padding:6px 10px;cursor:pointer;">Löschen</button>';
html += '</div></div>';
$('body').append(html);
$('.carrier-edit-btn').on('click', function() {
var id = $(this).data('id');
self.hideCarrierPopup();
self.showEditCarrierDialog(id);
});
$('.carrier-delete-btn').on('click', function() {
var id = $(this).data('id');
self.hideCarrierPopup();
self.deleteCarrier(id);
});
// Close on click outside
setTimeout(function() {
$(document).one('click', function() {
self.hideCarrierPopup();
});
}, 100);
},
hideCarrierPopup: function() {
$('.schematic-carrier-popup').remove();
},
showEditCarrierDialog: function(carrierId) {
var self = this;
var carrier = this.carriers.find(function(c) { return String(c.id) === String(carrierId); });
if (!carrier) return;
var html = '<div class="schematic-dialog-overlay" style="position:fixed;top:0;left:0;right:0;bottom:0;background:rgba(0,0,0,0.6);z-index:100000;"></div>';
html += '<div class="schematic-dialog" style="position:fixed;top:50%;left:50%;transform:translate(-50%,-50%);background:#2d2d44;border:1px solid #555;border-radius:8px;padding:20px;z-index:100001;min-width:300px;">';
html += '<h3 style="margin:0 0 15px 0;color:#fff;">Hutschiene bearbeiten</h3>';
// Label
html += '<div style="margin-bottom:12px;"><label style="display:block;color:#aaa;margin-bottom:4px;">Bezeichnung:</label>';
html += '<input type="text" class="dialog-carrier-label" value="' + this.escapeHtml(carrier.label || '') + '" placeholder="z.B. H1" style="width:100%;padding:8px;border:1px solid #555;border-radius:4px;background:#1e1e1e;color:#fff;box-sizing:border-box;"/></div>';
// Total TE
html += '<div style="margin-bottom:12px;"><label style="display:block;color:#aaa;margin-bottom:4px;">Breite (TE):</label>';
html += '<input type="number" class="dialog-carrier-te" value="' + (carrier.total_te || 12) + '" min="1" max="100" style="width:100%;padding:8px;border:1px solid #555;border-radius:4px;background:#1e1e1e;color:#fff;box-sizing:border-box;"/></div>';
// Buttons
html += '<div style="display:flex;gap:10px;margin-top:15px;">';
html += '<button class="dialog-carrier-save" style="flex:1;background:#27ae60;color:#fff;border:none;border-radius:4px;padding:10px;cursor:pointer;font-weight:bold;">Speichern</button>';
html += '<button class="dialog-carrier-cancel" style="flex:1;background:#555;color:#fff;border:none;border-radius:4px;padding:10px;cursor:pointer;">Abbrechen</button>';
html += '</div></div>';
$('body').append(html);
$('.dialog-carrier-save').on('click', function() {
var label = $('.dialog-carrier-label').val();
var totalTe = parseInt($('.dialog-carrier-te').val()) || 12;
self.updateCarrier(carrierId, label, totalTe);
self.closeDialog();
});
$('.dialog-carrier-cancel, .schematic-dialog-overlay').on('click', function() {
self.closeDialog();
});
},
updateCarrier: function(carrierId, label, totalTe) {
var self = this;
var baseUrl = $('body').data('base-url') || '';
$.ajax({
url: baseUrl + '/custom/kundenkarte/ajax/equipment_carrier.php',
method: 'POST',
data: {
action: 'update',
carrier_id: carrierId,
label: label,
total_te: totalTe,
token: KundenKarte.token
},
dataType: 'json',
success: function(response) {
if (response.success) {
self.loadData();
self.showMessage('Hutschiene aktualisiert', 'success');
} else {
self.showMessage('Fehler: ' + (response.error || 'Unbekannt'), 'error');
}
},
error: function() {
self.showMessage('Fehler beim Speichern', 'error');
}
});
},
deleteCarrier: function(carrierId) {
var self = this;
var baseUrl = $('body').data('base-url') || '';
this.showConfirmDialog('Hutschiene löschen', 'Diese Hutschiene und alle Equipments darauf wirklich löschen?', function() {
$.ajax({
url: baseUrl + '/custom/kundenkarte/ajax/equipment_carrier.php',
method: 'POST',
data: {
action: 'delete',
carrier_id: carrierId,
token: KundenKarte.token
},
dataType: 'json',
success: function(response) {
if (response.success) {
self.loadData();
self.showMessage('Hutschiene gelöscht', 'success');
} else {
self.showMessage('Fehler: ' + (response.error || 'Unbekannt'), 'error');
}
},
error: function() {
self.showMessage('Fehler beim Löschen', 'error');
}
});
});
},
showEditBusbarDialog: function(connectionId) {
var self = this;
var conn = this.connections.find(function(c) { return String(c.id) === String(connectionId); });
@ -5126,9 +5270,9 @@
html += '<rect class="schematic-rail-bg" x="' + (x - railOverhang) + '" y="' + railY + '" width="' + (width + railOverhang * 2) + '" height="' + self.RAIL_HEIGHT + '" ';
html += 'fill="' + self.COLORS.railBg + '" rx="2"/>';
// Rail (mit Überstand links und rechts)
// Rail (mit Überstand links und rechts) - klickbar für Bearbeitung
html += '<rect class="schematic-rail" data-carrier-id="' + carrier.id + '" x="' + (x - railOverhang) + '" y="' + (railY + 1) + '" width="' + (width + railOverhang * 2) + '" height="' + (self.RAIL_HEIGHT - 2) + '" ';
html += 'fill="' + self.COLORS.rail + '" rx="1"/>';
html += 'fill="' + self.COLORS.rail + '" rx="1" style="cursor:pointer;"/>';
// Rail label (links vom Überstand, centered with rail)
html += '<text x="' + (x - railOverhang - 7) + '" y="' + (railY + self.RAIL_HEIGHT / 2 + 4) + '" text-anchor="end" fill="#888" font-size="13">';
@ -5161,7 +5305,7 @@
html += 'fill="' + self.COLORS.railBg + '" rx="2"/>';
html += '<rect class="schematic-rail" data-carrier-id="' + carrier.id + '" x="' + (x - railOverhang) + '" y="' + (railY + 1) + '" width="' + (width + railOverhang * 2) + '" height="' + (self.RAIL_HEIGHT - 2) + '" ';
html += 'fill="' + self.COLORS.rail + '" rx="1"/>';
html += 'fill="' + self.COLORS.rail + '" rx="1" style="cursor:pointer;"/>';
html += '<text x="' + (x - railOverhang - 14) + '" y="' + (railY + self.RAIL_HEIGHT / 2 + 4) + '" text-anchor="end" fill="#888" font-size="15">';
html += self.escapeHtml(carrier.label || 'Hutschiene ' + (idx + 1));