{
"tool_response": {
"type": "update",
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/View\/semantic-explorer\/ontologie\/edit.php",
"content": "<?php\n\ndeclare(strict_types=1);\n\n\/\/ @responsibility: View für Ontologie-Klasse bearbeiten mit HTMX-Formular\n\nob_start();\n?>\n\n<nav class=\"breadcrumb\">\n <a href=\"\/\">Campus KI<\/a> »\n <a href=\"\/semantic-explorer\">Semantic Explorer<\/a> »\n <a href=\"\/semantic-explorer\/ontologie\">Ontologie<\/a> » <?= htmlspecialchars($class['name']) ?> » Bearbeiten\n<\/nav>\n\n<h1>Ontologie-Klasse bearbeiten<\/h1>\n\n<form id=\"ontology-form\" class=\"form\" style=\"max-width: 600px;\"\n hx-post=\"\/semantic-explorer\/ontologie\/<?= $class['id'] ?>\"\n hx-headers='{\"X-CSRF-TOKEN\": \"<?= $csrfToken ?>\"}'\n hx-disabled-elt=\"button[type=submit]\">\n <div class=\"form-group\">\n <label for=\"name\">Name *<\/label>\n <input type=\"text\" id=\"name\" name=\"name\" class=\"form-input\" required\n value=\"<?= htmlspecialchars($class['name']) ?>\">\n <\/div>\n\n <div class=\"form-group\">\n <label for=\"parent_class_id\">Uebergeordnete Klasse<\/label>\n <select id=\"parent_class_id\" name=\"parent_class_id\" class=\"form-select\">\n <option value=\"\">-- Keine (Root-Klasse) --<\/option>\n <?php foreach ($classes as $c): ?>\n <?php if ($c['id'] !== $class['id']): ?>\n <option value=\"<?= $c['id'] ?>\"\n <?= ($class['parent_class_id'] ?? '') == $c['id'] ? 'selected' : '' ?>><?= htmlspecialchars($c['name']) ?><\/option>\n <?php endif; ?>\n <?php endforeach; ?>\n <\/select>\n <\/div>\n\n <div class=\"form-group\">\n <label for=\"description\">Beschreibung<\/label>\n <textarea id=\"description\" name=\"description\" class=\"form-textarea\" rows=\"3\"><?= htmlspecialchars($class['description'] ?? '') ?><\/textarea>\n <\/div>\n\n <div class=\"form-group\">\n <label for=\"properties\">Properties (JSON)<\/label>\n <textarea id=\"properties\" name=\"properties\" class=\"form-textarea\" rows=\"4\"><?= htmlspecialchars($class['properties'] ?? '{}') ?><\/textarea>\n <small>z.B. {\"color\": \"string\", \"count\": \"integer\"}<\/small>\n <\/div>\n\n <div class=\"form-actions\">\n <button type=\"submit\" class=\"btn btn--primary\">Speichern<\/button>\n <a href=\"\/semantic-explorer\/ontologie\" class=\"btn\">Abbrechen<\/a>\n <button type=\"button\"\n class=\"btn btn--danger\"\n style=\"margin-left: auto;\"\n hx-post=\"\/semantic-explorer\/ontologie\/<?= $class['id'] ?>\/delete\"\n hx-headers='{\"X-CSRF-TOKEN\": \"<?= $csrfToken ?>\"}'\n hx-confirm=\"Klasse wirklich loeschen? Unterklassen muessen zuerst geloescht werden.\"\n hx-disabled-elt=\"this\">\n Loeschen\n <\/button>\n <\/div>\n<\/form>\n\n<?php $content = ob_get_clean(); ?>\n<?php require VIEW_PATH . '\/layout.php'; ?>\n",
"structuredPatch": [
{
"oldStart": 1,
"oldLines": 13,
"newStart": 1,
"newLines": 24,
"lines": [
"-<?php ob_start(); ?>",
"+<?php",
" ",
"+declare(strict_types=1);",
"+",
"+\/\/ @responsibility: View für Ontologie-Klasse bearbeiten mit HTMX-Formular",
"+",
"+ob_start();",
"+?>",
"+",
" <nav class=\"breadcrumb\">",
"+ <a href=\"\/\">Campus KI<\/a> »",
" <a href=\"\/semantic-explorer\">Semantic Explorer<\/a> »",
" <a href=\"\/semantic-explorer\/ontologie\">Ontologie<\/a> » <?= htmlspecialchars($class['name']) ?> » Bearbeiten",
" <\/nav>",
" ",
" <h1>Ontologie-Klasse bearbeiten<\/h1>",
" ",
"-<form id=\"ontology-form\" class=\"form\" style=\"max-width: 600px;\">",
"+<form id=\"ontology-form\" class=\"form\" style=\"max-width: 600px;\"",
"+ hx-post=\"\/semantic-explorer\/ontologie\/<?= $class['id'] ?>\"",
"+ hx-headers='{\"X-CSRF-TOKEN\": \"<?= $csrfToken ?>\"}'",
"+ hx-disabled-elt=\"button[type=submit]\">",
" <div class=\"form-group\">",
" <label for=\"name\">Name *<\/label>",
" <input type=\"text\" id=\"name\" name=\"name\" class=\"form-input\" required"
]
},
{
"oldStart": 41,
"oldLines": 58,
"newStart": 52,
"newLines": 17,
"lines": [
" <div class=\"form-actions\">",
" <button type=\"submit\" class=\"btn btn--primary\">Speichern<\/button>",
" <a href=\"\/semantic-explorer\/ontologie\" class=\"btn\">Abbrechen<\/a>",
"- <button type=\"button\" id=\"delete-btn\" class=\"btn btn--danger\" style=\"margin-left: auto;\">Loeschen<\/button>",
"+ <button type=\"button\"",
"+ class=\"btn btn--danger\"",
"+ style=\"margin-left: auto;\"",
"+ hx-post=\"\/semantic-explorer\/ontologie\/<?= $class['id'] ?>\/delete\"",
"+ hx-headers='{\"X-CSRF-TOKEN\": \"<?= $csrfToken ?>\"}'",
"+ hx-confirm=\"Klasse wirklich loeschen? Unterklassen muessen zuerst geloescht werden.\"",
"+ hx-disabled-elt=\"this\">",
"+ Loeschen",
"+ <\/button>",
" <\/div>",
" <\/form>",
"-<div id=\"form-message\" class=\"form-message\"><\/div>",
" ",
"-<script>",
"-document.getElementById('ontology-form').addEventListener('submit', async (e) => {",
"- e.preventDefault();",
"- const form = e.target;",
"- const formData = new FormData(form);",
"- const data = Object.fromEntries(formData.entries());",
"- if (data.parent_class_id === '') data.parent_class_id = null;",
"-",
"- try {",
"- data.properties = JSON.parse(data.properties || '{}');",
"- } catch (err) {",
"- document.getElementById('form-message').innerHTML =",
"- '<span class=\"form-message--error\">Fehler: Ungültiges JSON in Properties<\/span>';",
"- return;",
"- }",
"-",
"- const response = await fetch('\/semantic-explorer\/ontologie\/<?= $class['id'] ?>', {",
"- method: 'POST',",
"- headers: {'Content-Type': 'application\/json'},",
"- body: JSON.stringify(data)",
"- });",
"- const result = await response.json();",
"-",
"- if (result.success) {",
"- window.location.href = '\/semantic-explorer\/ontologie';",
"- } else {",
"- document.getElementById('form-message').innerHTML =",
"- '<span class=\"form-message--error\">Fehler: ' + result.error + '<\/span>';",
"- }",
"-});",
"-",
"-document.getElementById('delete-btn').addEventListener('click', async () => {",
"- if (!confirm('Klasse wirklich loeschen? Unterklassen muessen zuerst geloescht werden.')) return;",
"-",
"- const response = await fetch('\/semantic-explorer\/ontologie\/<?= $class['id'] ?>\/delete', {",
"- method: 'POST'",
"- });",
"- const result = await response.json();",
"-",
"- if (result.success) {",
"- window.location.href = '\/semantic-explorer\/ontologie';",
"- } else {",
"- document.getElementById('form-message').innerHTML =",
"- '<span class=\"form-message--error\">Fehler: ' + result.error + '<\/span>';",
"- }",
"-});",
"-<\/script>",
"-",
" <?php $content = ob_get_clean(); ?>",
" <?php require VIEW_PATH . '\/layout.php'; ?>"
]
}
],
"originalFile": "<?php ob_start(); ?>\n\n<nav class=\"breadcrumb\">\n <a href=\"\/semantic-explorer\">Semantic Explorer<\/a> »\n <a href=\"\/semantic-explorer\/ontologie\">Ontologie<\/a> » <?= htmlspecialchars($class['name']) ?> » Bearbeiten\n<\/nav>\n\n<h1>Ontologie-Klasse bearbeiten<\/h1>\n\n<form id=\"ontology-form\" class=\"form\" style=\"max-width: 600px;\">\n <div class=\"form-group\">\n <label for=\"name\">Name *<\/label>\n <input type=\"text\" id=\"name\" name=\"name\" class=\"form-input\" required\n value=\"<?= htmlspecialchars($class['name']) ?>\">\n <\/div>\n\n <div class=\"form-group\">\n <label for=\"parent_class_id\">Uebergeordnete Klasse<\/label>\n <select id=\"parent_class_id\" name=\"parent_class_id\" class=\"form-select\">\n <option value=\"\">-- Keine (Root-Klasse) --<\/option>\n <?php foreach ($classes as $c): ?>\n <?php if ($c['id'] !== $class['id']): ?>\n <option value=\"<?= $c['id'] ?>\"\n <?= ($class['parent_class_id'] ?? '') == $c['id'] ? 'selected' : '' ?>><?= htmlspecialchars($c['name']) ?><\/option>\n <?php endif; ?>\n <?php endforeach; ?>\n <\/select>\n <\/div>\n\n <div class=\"form-group\">\n <label for=\"description\">Beschreibung<\/label>\n <textarea id=\"description\" name=\"description\" class=\"form-textarea\" rows=\"3\"><?= htmlspecialchars($class['description'] ?? '') ?><\/textarea>\n <\/div>\n\n <div class=\"form-group\">\n <label for=\"properties\">Properties (JSON)<\/label>\n <textarea id=\"properties\" name=\"properties\" class=\"form-textarea\" rows=\"4\"><?= htmlspecialchars($class['properties'] ?? '{}') ?><\/textarea>\n <small>z.B. {\"color\": \"string\", \"count\": \"integer\"}<\/small>\n <\/div>\n\n <div class=\"form-actions\">\n <button type=\"submit\" class=\"btn btn--primary\">Speichern<\/button>\n <a href=\"\/semantic-explorer\/ontologie\" class=\"btn\">Abbrechen<\/a>\n <button type=\"button\" id=\"delete-btn\" class=\"btn btn--danger\" style=\"margin-left: auto;\">Loeschen<\/button>\n <\/div>\n<\/form>\n<div id=\"form-message\" class=\"form-message\"><\/div>\n\n<script>\ndocument.getElementById('ontology-form').addEventListener('submit', async (e) => {\n e.preventDefault();\n const form = e.target;\n const formData = new FormData(form);\n const data = Object.fromEntries(formData.entries());\n if (data.parent_class_id === '') data.parent_class_id = null;\n\n try {\n data.properties = JSON.parse(data.properties || '{}');\n } catch (err) {\n document.getElementById('form-message').innerHTML =\n '<span class=\"form-message--error\">Fehler: Ungültiges JSON in Properties<\/span>';\n return;\n }\n\n const response = await fetch('\/semantic-explorer\/ontologie\/<?= $class['id'] ?>', {\n method: 'POST',\n headers: {'Content-Type': 'application\/json'},\n body: JSON.stringify(data)\n });\n const result = await response.json();\n\n if (result.success) {\n window.location.href = '\/semantic-explorer\/ontologie';\n } else {\n document.getElementById('form-message').innerHTML =\n '<span class=\"form-message--error\">Fehler: ' + result.error + '<\/span>';\n }\n});\n\ndocument.getElementById('delete-btn').addEventListener('click', async () => {\n if (!confirm('Klasse wirklich loeschen? Unterklassen muessen zuerst geloescht werden.')) return;\n\n const response = await fetch('\/semantic-explorer\/ontologie\/<?= $class['id'] ?>\/delete', {\n method: 'POST'\n });\n const result = await response.json();\n\n if (result.success) {\n window.location.href = '\/semantic-explorer\/ontologie';\n } else {\n document.getElementById('form-message').innerHTML =\n '<span class=\"form-message--error\">Fehler: ' + result.error + '<\/span>';\n }\n});\n<\/script>\n\n<?php $content = ob_get_clean(); ?>\n<?php require VIEW_PATH . '\/layout.php'; ?>\n"
}
}