feat: complete package 2 delete flows and package 3 port management
This commit is contained in:
@@ -233,11 +233,20 @@ $buildings = $sql->get("SELECT id, name FROM buildings ORDER BY name", "", []);
|
||||
|
||||
<script>
|
||||
function confirmDelete(id) {
|
||||
if (confirm('Dieses Stockwerk wirklich loeschen? Alle Raeume und Racks werden geloescht.')) {
|
||||
if (!confirm('Dieses Stockwerk wirklich loeschen?')) {
|
||||
return;
|
||||
}
|
||||
|
||||
const requestDelete = (forceDelete) => {
|
||||
const body = ['id=' + encodeURIComponent(id)];
|
||||
if (forceDelete) {
|
||||
body.push('force=1');
|
||||
}
|
||||
|
||||
fetch('?module=floors&action=delete', {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8' },
|
||||
body: 'id=' + encodeURIComponent(id)
|
||||
body: body.join('&')
|
||||
})
|
||||
.then((res) => res.json())
|
||||
.then((data) => {
|
||||
@@ -245,12 +254,22 @@ function confirmDelete(id) {
|
||||
window.location.reload();
|
||||
return;
|
||||
}
|
||||
|
||||
if (data && data.requires_force) {
|
||||
if (confirm(data.message || 'Abhaengige Daten ebenfalls loeschen?')) {
|
||||
requestDelete(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
alert((data && data.message) ? data.message : 'Loeschen fehlgeschlagen');
|
||||
})
|
||||
.catch(() => {
|
||||
alert('Loeschen fehlgeschlagen');
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
requestDelete(false);
|
||||
}
|
||||
</script>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user