Etage ist Pflicht
Die Auswahlliste im Editor bot ein "-" an. Eine Automatik ohne Etage taucht aber in keinem der drei Reiter auf und ist danach nur noch in der Datenbank zu finden - anlegen und sofort verlieren. Der Eintrag ist weg, und der Zustand ist jetzt an drei Stellen unmoeglich statt nur unwahrscheinlich: die Liste kennt nur noch OG, EG und UG, saveAutomation lehnt alles andere mit einer Meldung ab statt still auf "" zurueckzufallen, und im Enum der Spalte gibt es den leeren Wert nicht mehr. Die Reihenfolge in der Liste ist jetzt OG, EG, UG wie bei den Reitern - damit trifft der Rueckfall auf den ersten Eintrag dieselbe Etage wie die Startseite. Kennt die Liste die Etage eines Datensatzes nicht, faellt sie darauf zurueck, statt leer stehen zu bleiben und beim Speichern "" zu schicken. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
+6
-3
@@ -155,11 +155,14 @@ $nutzdaten = json_encode([
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
<div class="form-floating">
|
<div class="form-floating">
|
||||||
|
<!-- Ohne Etage waere die Automatik in keinem der drei Reiter zu
|
||||||
|
sehen und nur noch in der Datenbank auffindbar. Reihenfolge wie
|
||||||
|
die Reiter, damit der Rueckfall auf den ersten Eintrag dieselbe
|
||||||
|
Etage trifft wie die Startseite. -->
|
||||||
<select class="form-select" id="autoFloor">
|
<select class="form-select" id="autoFloor">
|
||||||
<option value="">–</option>
|
|
||||||
<option value="UG">UG</option>
|
|
||||||
<option value="EG">EG</option>
|
|
||||||
<option value="OG">OG</option>
|
<option value="OG">OG</option>
|
||||||
|
<option value="EG">EG</option>
|
||||||
|
<option value="UG">UG</option>
|
||||||
</select>
|
</select>
|
||||||
<label for="autoFloor">Etage</label>
|
<label for="autoFloor">Etage</label>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ SET NAMES utf8mb4;
|
|||||||
CREATE TABLE IF NOT EXISTS `automations` (
|
CREATE TABLE IF NOT EXISTS `automations` (
|
||||||
`id` int(11) NOT NULL AUTO_INCREMENT,
|
`id` int(11) NOT NULL AUTO_INCREMENT,
|
||||||
`name` varchar(100) NOT NULL COMMENT 'Anzeigename, z.B. Kinder zu',
|
`name` varchar(100) NOT NULL COMMENT 'Anzeigename, z.B. Kinder zu',
|
||||||
`floor` enum('','UG','EG','OG') NOT NULL DEFAULT '' COMMENT 'Reiter in der Uebersicht',
|
`floor` enum('UG','EG','OG') NOT NULL DEFAULT 'OG' COMMENT 'Reiter in der Uebersicht. Ohne Etage waere die Automatik in keinem davon zu sehen, deshalb gibt es keinen leeren Wert',
|
||||||
`enabled` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Aktiv oder pausiert',
|
`enabled` tinyint(1) NOT NULL DEFAULT 1 COMMENT 'Aktiv oder pausiert',
|
||||||
`window_from` time NOT NULL DEFAULT '00:00:00' COMMENT 'Aktiver Zeitraum, Beginn',
|
`window_from` time NOT NULL DEFAULT '00:00:00' COMMENT 'Aktiver Zeitraum, Beginn',
|
||||||
`window_to` time NOT NULL DEFAULT '23:59:00' COMMENT 'Aktiver Zeitraum, Ende. Kleiner als window_from = ueber Mitternacht',
|
`window_to` time NOT NULL DEFAULT '23:59:00' COMMENT 'Aktiver Zeitraum, Ende. Kleiner als window_from = ueber Mitternacht',
|
||||||
|
|||||||
@@ -373,7 +373,14 @@ function fuelleFormular() {
|
|||||||
optionListe(sperre, autoLockouts.map(o => ({ value: o.value, text: o.label })),
|
optionListe(sperre, autoLockouts.map(o => ({ value: o.value, text: o.label })),
|
||||||
autoModel.lockout_secs);
|
autoModel.lockout_secs);
|
||||||
document.getElementById("autoName").value = autoModel.name;
|
document.getElementById("autoName").value = autoModel.name;
|
||||||
document.getElementById("autoFloor").value = autoModel.floor;
|
// Kennt die Liste die Etage nicht, bleibt eine Auswahlliste sonst leer
|
||||||
|
// stehen und schickt beim Speichern "" mit.
|
||||||
|
const etage = document.getElementById("autoFloor");
|
||||||
|
etage.value = autoModel.floor;
|
||||||
|
if (etage.selectedIndex < 0) {
|
||||||
|
etage.selectedIndex = 0;
|
||||||
|
autoModel.floor = etage.value;
|
||||||
|
}
|
||||||
document.getElementById("tSpanFrom").value = autoModel.window_from;
|
document.getElementById("tSpanFrom").value = autoModel.window_from;
|
||||||
document.getElementById("tSpanTo").value = autoModel.window_to;
|
document.getElementById("tSpanTo").value = autoModel.window_to;
|
||||||
document.getElementById("actFerien").checked = autoModel.on_vacation;
|
document.getElementById("actFerien").checked = autoModel.on_vacation;
|
||||||
|
|||||||
@@ -267,7 +267,9 @@ function emptyAutomation($floor)
|
|||||||
return [
|
return [
|
||||||
"id" => 0,
|
"id" => 0,
|
||||||
"name" => "",
|
"name" => "",
|
||||||
"floor" => $floor,
|
// Aufgerufen wird der Editor immer aus einem Etagenreiter. Fehlt die
|
||||||
|
// Angabe trotzdem, gilt dieselbe Etage wie auf der Startseite.
|
||||||
|
"floor" => in_array($floor, ["UG", "EG", "OG"], true) ? $floor : "OG",
|
||||||
"enabled" => true,
|
"enabled" => true,
|
||||||
"window_from" => "00:00",
|
"window_from" => "00:00",
|
||||||
"window_to" => "23:59",
|
"window_to" => "23:59",
|
||||||
@@ -370,8 +372,10 @@ function saveAutomation($data)
|
|||||||
throw new InvalidArgumentException("Bitte einen Namen vergeben.");
|
throw new InvalidArgumentException("Bitte einen Namen vergeben.");
|
||||||
}
|
}
|
||||||
$floor = strval($data["floor"] ?? "");
|
$floor = strval($data["floor"] ?? "");
|
||||||
if (!in_array($floor, ["", "UG", "EG", "OG"], true)) {
|
if (!in_array($floor, ["UG", "EG", "OG"], true)) {
|
||||||
$floor = "";
|
// Nicht stillschweigend auf "" zurueckfallen: die Automatik wuerde
|
||||||
|
// dann in keinem der drei Reiter mehr auftauchen.
|
||||||
|
throw new InvalidArgumentException("Bitte eine Etage wählen.");
|
||||||
}
|
}
|
||||||
$conditions = is_array($data["conditions"] ?? null) ? $data["conditions"] : [];
|
$conditions = is_array($data["conditions"] ?? null) ? $data["conditions"] : [];
|
||||||
$actions = is_array($data["actions"] ?? null) ? $data["actions"] : [];
|
$actions = is_array($data["actions"] ?? null) ? $data["actions"] : [];
|
||||||
|
|||||||
Reference in New Issue
Block a user