This commit is contained in:
2026-02-13 12:06:46 +01:00
parent 39f7f9b733
commit 2c90ff8ddf
2 changed files with 12 additions and 18 deletions

View File

@@ -222,7 +222,7 @@ $racks = $sql->get("SELECT id, name FROM racks ORDER BY name", "", []);
<td class="actions">
<a href="?module=devices&action=edit&id=<?php echo $d['id']; ?>" class="button button-small">Bearbeiten</a>
<a href="?module=devices&action=delete&id=<?php echo (int)$d['id']; ?>" class="button button-small button-danger" onclick="return confirmDelete(event, <?php echo (int)$d['id']; ?>, <?php echo (int)$d['connection_count']; ?>, <?php echo (int)$d['port_count']; ?>, <?php echo (int)$d['module_count']; ?>)">Löschen</a>
<a href="?module=devices&action=delete&id=<?php echo (int)$d['id']; ?>" class="button button-small button-danger" onclick="return confirmDelete(this, <?php echo (int)$d['id']; ?>, <?php echo (int)$d['connection_count']; ?>, <?php echo (int)$d['port_count']; ?>, <?php echo (int)$d['module_count']; ?>)">Löschen</a>
</td>
</tr>
<?php endforeach; ?>
@@ -350,11 +350,7 @@ $racks = $sql->get("SELECT id, name FROM racks ORDER BY name", "", []);
</style>
<script>
function confirmDelete(event, id, connectionCount, portCount, moduleCount) {
if (event && typeof event.preventDefault === 'function') {
event.preventDefault();
}
function confirmDelete(link, id, connectionCount, portCount, moduleCount) {
if (confirm('Dieses Gerät wirklich löschen?')) {
const hasDependencies = (connectionCount > 0) || (portCount > 0) || (moduleCount > 0);
if (hasDependencies) {
@@ -372,15 +368,16 @@ function confirmDelete(event, id, connectionCount, portCount, moduleCount) {
if (!confirm(dependencyMessage)) {
return false;
}
window.location.href = '?module=devices&action=delete&id=' + encodeURIComponent(id) + '&force=1';
window.location.href = (link && link.href ? link.href : ('?module=devices&action=delete&id=' + encodeURIComponent(id))) + '&force=1';
return false;
}
window.location.href = '?module=devices&action=delete&id=' + encodeURIComponent(id);
return false;
return true;
}
return false;
}
</script>