{
"tool_response": {
"type": "update",
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/src\/View\/content\/edit.php",
"content": "<?php\n\ndeclare(strict_types=1);\n\n\/\/ @responsibility: Edit-Formular für Content-Aufträge mit HTMX-Submit\n\nob_start();\n?>\n\n<nav class=\"breadcrumb\">\n <a href=\"\/content\">Content Studio<\/a> » <a href=\"\/content\/<?= $order['id'] ?>\">Auftrag #<?= $order['id'] ?><\/a> » Bearbeiten\n<\/nav>\n\n<h1>Auftrag bearbeiten<\/h1>\n\n<form id=\"order-form\" class=\"form\" style=\"max-width: 600px;\"\n hx-put=\"\/api\/v1\/content\/<?= $order['id'] ?>\"\n hx-headers='{\"X-CSRF-TOKEN\": \"<?= $csrfToken ?>\"}'\n hx-target=\"#form-message\"\n hx-swap=\"innerHTML\">\n <div class=\"form-group\">\n <label for=\"title\">Titel *<\/label>\n <input type=\"text\" id=\"title\" name=\"title\" class=\"form-input\" required\n value=\"<?= htmlspecialchars($order['title']) ?>\">\n <\/div>\n <div class=\"form-group\">\n <label for=\"briefing\">Briefing *<\/label>\n <textarea id=\"briefing\" name=\"briefing\" class=\"form-textarea\" rows=\"6\" required><?= htmlspecialchars($order['briefing']) ?><\/textarea>\n <\/div>\n <div class=\"form-group\">\n <label for=\"author_profile_id\">Autorenprofil<\/label>\n <select id=\"author_profile_id\" name=\"author_profile_id\" class=\"form-select\">\n <option value=\"\">-- Kein Profil --<\/option>\n <?php foreach ($profiles ?? [] as $profile): ?>\n <option value=\"<?= $profile['id'] ?>\" <?= ($order['author_profile_id'] ?? '') == $profile['id'] ? 'selected' : '' ?>><?= htmlspecialchars($profile['name']) ?><\/option>\n <?php endforeach; ?>\n <\/select>\n <\/div>\n <div class=\"form-group\">\n <label for=\"contract_id\">Contract<\/label>\n <select id=\"contract_id\" name=\"contract_id\" class=\"form-select\">\n <option value=\"\">-- Kein Contract --<\/option>\n <?php foreach ($contracts ?? [] as $contract): ?>\n <option value=\"<?= $contract['id'] ?>\" <?= ($order['contract_id'] ?? '') == $contract['id'] ? 'selected' : '' ?>><?= htmlspecialchars($contract['name']) ?><\/option>\n <?php endforeach; ?>\n <\/select>\n <\/div>\n <div class=\"form-group\">\n <label for=\"structure_id\">Struktur<\/label>\n <select id=\"structure_id\" name=\"structure_id\" class=\"form-select\">\n <option value=\"\">-- Keine Struktur --<\/option>\n <?php foreach ($structures ?? [] as $structure): ?>\n <option value=\"<?= $structure['id'] ?>\" <?= ($order['structure_id'] ?? '') == $structure['id'] ? 'selected' : '' ?>><?= htmlspecialchars($structure['name']) ?><\/option>\n <?php endforeach; ?>\n <\/select>\n <\/div>\n <div class=\"form-actions\">\n <button type=\"submit\" class=\"btn btn--primary\">\n <span class=\"htmx-indicator\">Speichern...<\/span>\n <span class=\"htmx-content\">Speichern<\/span>\n <\/button>\n <a href=\"\/content\/<?= $order['id'] ?>\" class=\"btn\">Abbrechen<\/a>\n <\/div>\n<\/form>\n<div id=\"form-message\" class=\"form-message\"><\/div>\n\n<?php $content = ob_get_clean(); ?>\n<?php require VIEW_PATH . '\/layout.php'; ?>\n",
"structuredPatch": [
{
"oldStart": 1,
"oldLines": 12,
"newStart": 1,
"newLines": 23,
"lines": [
"-<?php ob_start(); ?>",
"+<?php",
" ",
"+declare(strict_types=1);",
"+",
"+\/\/ @responsibility: Edit-Formular für Content-Aufträge mit HTMX-Submit",
"+",
"+ob_start();",
"+?>",
"+",
" <nav class=\"breadcrumb\">",
" <a href=\"\/content\">Content Studio<\/a> » <a href=\"\/content\/<?= $order['id'] ?>\">Auftrag #<?= $order['id'] ?><\/a> » Bearbeiten",
" <\/nav>",
" ",
" <h1>Auftrag bearbeiten<\/h1>",
" ",
"-<form id=\"order-form\" class=\"form\" style=\"max-width: 600px;\">",
"+<form id=\"order-form\" class=\"form\" style=\"max-width: 600px;\"",
"+ hx-put=\"\/api\/v1\/content\/<?= $order['id'] ?>\"",
"+ hx-headers='{\"X-CSRF-TOKEN\": \"<?= $csrfToken ?>\"}'",
"+ hx-target=\"#form-message\"",
"+ hx-swap=\"innerHTML\">",
" <div class=\"form-group\">",
" <label for=\"title\">Titel *<\/label>",
" <input type=\"text\" id=\"title\" name=\"title\" class=\"form-input\" required"
]
},
{
"oldStart": 44,
"oldLines": 34,
"newStart": 55,
"newLines": 14,
"lines": [
" <\/select>",
" <\/div>",
" <div class=\"form-actions\">",
"- <button type=\"submit\" class=\"btn btn--primary\">Speichern<\/button>",
"+ <button type=\"submit\" class=\"btn btn--primary\">",
"+ <span class=\"htmx-indicator\">Speichern...<\/span>",
"+ <span class=\"htmx-content\">Speichern<\/span>",
"+ <\/button>",
" <a href=\"\/content\/<?= $order['id'] ?>\" class=\"btn\">Abbrechen<\/a>",
" <\/div>",
" <\/form>",
" <div id=\"form-message\" class=\"form-message\"><\/div>",
" ",
"-<script>",
"-document.getElementById('order-form').addEventListener('submit', async (e) => {",
"- e.preventDefault();",
"- const form = e.target;",
"- const formData = new FormData(form);",
"- const data = Object.fromEntries(formData.entries());",
"-",
"- const response = await fetch('\/api\/v1\/content\/<?= $order['id'] ?>', {",
"- method: 'PUT',",
"- headers: {'Content-Type': 'application\/json'},",
"- body: JSON.stringify(data)",
"- });",
"- const result = await response.json();",
"-",
"- if (result.success) {",
"- window.location.href = '\/content\/<?= $order['id'] ?>';",
"- } 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=\"\/content\">Content Studio<\/a> » <a href=\"\/content\/<?= $order['id'] ?>\">Auftrag #<?= $order['id'] ?><\/a> » Bearbeiten\n<\/nav>\n\n<h1>Auftrag bearbeiten<\/h1>\n\n<form id=\"order-form\" class=\"form\" style=\"max-width: 600px;\">\n <div class=\"form-group\">\n <label for=\"title\">Titel *<\/label>\n <input type=\"text\" id=\"title\" name=\"title\" class=\"form-input\" required\n value=\"<?= htmlspecialchars($order['title']) ?>\">\n <\/div>\n <div class=\"form-group\">\n <label for=\"briefing\">Briefing *<\/label>\n <textarea id=\"briefing\" name=\"briefing\" class=\"form-textarea\" rows=\"6\" required><?= htmlspecialchars($order['briefing']) ?><\/textarea>\n <\/div>\n <div class=\"form-group\">\n <label for=\"author_profile_id\">Autorenprofil<\/label>\n <select id=\"author_profile_id\" name=\"author_profile_id\" class=\"form-select\">\n <option value=\"\">-- Kein Profil --<\/option>\n <?php foreach ($profiles ?? [] as $profile): ?>\n <option value=\"<?= $profile['id'] ?>\" <?= ($order['author_profile_id'] ?? '') == $profile['id'] ? 'selected' : '' ?>><?= htmlspecialchars($profile['name']) ?><\/option>\n <?php endforeach; ?>\n <\/select>\n <\/div>\n <div class=\"form-group\">\n <label for=\"contract_id\">Contract<\/label>\n <select id=\"contract_id\" name=\"contract_id\" class=\"form-select\">\n <option value=\"\">-- Kein Contract --<\/option>\n <?php foreach ($contracts ?? [] as $contract): ?>\n <option value=\"<?= $contract['id'] ?>\" <?= ($order['contract_id'] ?? '') == $contract['id'] ? 'selected' : '' ?>><?= htmlspecialchars($contract['name']) ?><\/option>\n <?php endforeach; ?>\n <\/select>\n <\/div>\n <div class=\"form-group\">\n <label for=\"structure_id\">Struktur<\/label>\n <select id=\"structure_id\" name=\"structure_id\" class=\"form-select\">\n <option value=\"\">-- Keine Struktur --<\/option>\n <?php foreach ($structures ?? [] as $structure): ?>\n <option value=\"<?= $structure['id'] ?>\" <?= ($order['structure_id'] ?? '') == $structure['id'] ? 'selected' : '' ?>><?= htmlspecialchars($structure['name']) ?><\/option>\n <?php endforeach; ?>\n <\/select>\n <\/div>\n <div class=\"form-actions\">\n <button type=\"submit\" class=\"btn btn--primary\">Speichern<\/button>\n <a href=\"\/content\/<?= $order['id'] ?>\" class=\"btn\">Abbrechen<\/a>\n <\/div>\n<\/form>\n<div id=\"form-message\" class=\"form-message\"><\/div>\n\n<script>\ndocument.getElementById('order-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\n const response = await fetch('\/api\/v1\/content\/<?= $order['id'] ?>', {\n method: 'PUT',\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 = '\/content\/<?= $order['id'] ?>';\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"
}
}