Backup #2178

ID2178
Dateipfad/var/www/dev.campus.systemische-tools.de/src/View/content/edit.php
Version7
Typ modified
Größe13.3 KB
Hash56002f16e25e2d45abffad9c33f594d070710741802224dde2c689f415df172e
Datum2025-12-30 22:37:28
Geändert vonclaude-code-hook
GrundClaude Code Pre-Hook Backup vor Edit-Operation
Datei existiert Ja

Dateiinhalt

<?php

declare(strict_types=1);

// @responsibility: Edit-Formular für Content-Aufträge mit HTMX-Submit

ob_start();
$orderModel = $order['model'] ?? 'claude-sonnet-4-20250514';
$orderCollections = json_decode($order['collections'] ?? '["documents"]', true) ?: ['documents'];
$orderContextLimit = (int) ($order['context_limit'] ?? 5);
$orderTemperature = (float) ($order['temperature'] ?? 0.5);
$orderMaxTokens = (int) ($order['max_tokens'] ?? 4096);
$orderSystemPromptId = $order['system_prompt_id'] ?? null;
$orderQualityCheck = (bool) ($order['quality_check'] ?? false);
$orderSelectedCritics = json_decode($order['selected_critics'] ?? '[]', true) ?: [];
?>

<nav class="breadcrumb">
    <a href="/content">Content Studio</a> &raquo; <a href="/content/<?= $order['id'] ?>">Auftrag #<?= $order['id'] ?></a> &raquo; Bearbeiten
</nav>

<h1>Auftrag bearbeiten</h1>

<form id="order-form" class="form" style="max-width: 700px;"
      hx-put="/api/v1/content/<?= $order['id'] ?>"
      hx-headers='{"X-CSRF-TOKEN": "<?= $csrfToken ?>"}'
      hx-target="#form-message"
      hx-swap="innerHTML"
      hx-indicator="#save-btn"
      hx-disabled-elt="#save-btn">

    <fieldset>
        <legend>Inhalt</legend>
        <div class="form-group">
            <label for="title">Titel *</label>
            <input type="text" id="title" name="title" class="form-input" required
                   value="<?= htmlspecialchars($order['title']) ?>">
        </div>
        <div class="form-group">
            <label for="briefing">Briefing *</label>
            <textarea id="briefing" name="briefing" class="form-textarea" rows="6" required><?= htmlspecialchars($order['briefing']) ?></textarea>
        </div>
    </fieldset>

    <fieldset>
        <legend>KI-Einstellungen</legend>
        <div class="form-row">
            <div class="form-group form-group--half">
                <label for="model">Sprachmodell</label>
                <select id="model" name="model" class="form-select">
                    <?php foreach ($models ?? [] as $modelId => $modelName): ?>
                    <option value="<?= $modelId ?>" <?= $modelId === $orderModel ? 'selected' : '' ?>><?= htmlspecialchars($modelName) ?></option>
                    <?php endforeach; ?>
                </select>
            </div>
            <div class="form-group form-group--half">
                <label for="context_limit">Kontext-Quellen</label>
                <select id="context_limit" name="context_limit" class="form-select">
                    <option value="3" <?= $orderContextLimit === 3 ? 'selected' : '' ?>>3 Quellen</option>
                    <option value="5" <?= $orderContextLimit === 5 ? 'selected' : '' ?>>5 Quellen</option>
                    <option value="10" <?= $orderContextLimit === 10 ? 'selected' : '' ?>>10 Quellen</option>
                    <option value="15" <?= $orderContextLimit === 15 ? 'selected' : '' ?>>15 Quellen</option>
                </select>
            </div>
        </div>
        <div class="form-group">
            <label>Collections (Wissensquellen)</label>
            <?php
            $selected = $orderCollections;
$variant = 'checkbox';
include __DIR__ . '/../partials/form/collections-select.php';
?>
        </div>
        <div class="form-row">
            <div class="form-group form-group--half">
                <label for="temperature">Temperatur: <span id="tempValue"><?= number_format($orderTemperature, 1) ?></span></label>
                <input type="range" id="temperature" name="temperature" class="form-slider"
                       min="0" max="1" step="0.1" value="<?= $orderTemperature ?>">
                <div class="preset-buttons">
                    <button type="button" class="preset-btn<?= $orderTemperature == 0.3 ? ' preset-btn--active' : '' ?>" data-temp="0.3" data-tokens="2048">Präzise</button>
                    <button type="button" class="preset-btn<?= $orderTemperature == 0.5 ? ' preset-btn--active' : '' ?>" data-temp="0.5" data-tokens="4096">Ausgewogen</button>
                    <button type="button" class="preset-btn<?= $orderTemperature == 0.9 ? ' preset-btn--active' : '' ?>" data-temp="0.9" data-tokens="4096">Kreativ</button>
                </div>
            </div>
            <div class="form-group form-group--half">
                <label for="max_tokens">Max Tokens</label>
                <select id="max_tokens" name="max_tokens" class="form-select">
                    <option value="1024" <?= $orderMaxTokens === 1024 ? 'selected' : '' ?>>1024</option>
                    <option value="2048" <?= $orderMaxTokens === 2048 ? 'selected' : '' ?>>2048</option>
                    <option value="4096" <?= $orderMaxTokens === 4096 ? 'selected' : '' ?>>4096</option>
                    <option value="8192" <?= $orderMaxTokens === 8192 ? 'selected' : '' ?>>8192</option>
                </select>
            </div>
        </div>
        <div class="form-row">
            <div class="form-group form-group--half">
                <label for="system_prompt_id">System Prompt</label>
                <select id="system_prompt_id" name="system_prompt_id" class="form-select">
                    <option value="">-- Standard --</option>
                    <?php foreach ($systemPrompts ?? [] as $prompt): ?>
                    <option value="<?= $prompt['id'] ?>" <?= $orderSystemPromptId !== null && (int) $orderSystemPromptId === (int) $prompt['id'] ? 'selected' : '' ?>><?= htmlspecialchars($prompt['name']) ?></option>
                    <?php endforeach; ?>
                </select>
            </div>
            <div class="form-group form-group--half form-group--checkbox">
                <label class="checkbox-toggle">
                    <input type="checkbox" id="quality_check" name="quality_check" value="1" <?= $orderQualityCheck ? 'checked' : '' ?>>
                    <span class="checkbox-toggle__label">Qualitätsprüfung (LLM-Validierung)</span>
                </label>
            </div>
        </div>
    </fieldset>

    <fieldset>
        <legend>Content-Konfiguration</legend>
        <div class="form-row">
            <div class="form-group form-group--third">
                <label for="author_profile_id">Autorenprofil</label>
                <select id="author_profile_id" name="author_profile_id" class="form-select">
                    <option value="">-- Kein Profil --</option>
                    <?php foreach ($profiles ?? [] as $profile): ?>
                    <option value="<?= $profile['id'] ?>" <?= ($order['author_profile_id'] ?? '') == $profile['id'] ? 'selected' : '' ?>><?= htmlspecialchars($profile['name']) ?></option>
                    <?php endforeach; ?>
                </select>
            </div>
            <div class="form-group form-group--third">
                <label for="contract_id">Contract</label>
                <select id="contract_id" name="contract_id" class="form-select">
                    <option value="">-- Kein Contract --</option>
                    <?php foreach ($contracts ?? [] as $contract): ?>
                    <option value="<?= $contract['id'] ?>" <?= ($order['contract_id'] ?? '') == $contract['id'] ? 'selected' : '' ?>><?= htmlspecialchars($contract['name']) ?></option>
                    <?php endforeach; ?>
                </select>
            </div>
            <div class="form-group form-group--third">
                <label for="structure_id">Struktur</label>
                <select id="structure_id" name="structure_id" class="form-select">
                    <option value="">-- Keine Struktur --</option>
                    <?php foreach ($structures ?? [] as $structure): ?>
                    <option value="<?= $structure['id'] ?>" <?= ($order['structure_id'] ?? '') == $structure['id'] ? 'selected' : '' ?>><?= htmlspecialchars($structure['name']) ?></option>
                    <?php endforeach; ?>
                </select>
            </div>
        </div>
    </fieldset>

    <?php if (!empty($critics)): ?>
    <fieldset>
        <legend>Kritiker <span class="legend-hint">(für Qualitätsprüfung)</span></legend>
        <p class="fieldset-info">Wähle die Kritiker, die den generierten Content prüfen sollen. <a href="/config?type=critic" class="link-muted">Kritiker verwalten →</a></p>
        <div class="critic-grid">
            <?php foreach ($critics as $critic):
                $isSelected = in_array((int) $critic['id'], $orderSelectedCritics, true);
            ?>
            <label class="critic-card <?= $isSelected ? 'critic-card--selected' : '' ?>">
                <input type="checkbox" name="critics[]" value="<?= $critic['id'] ?>" <?= $isSelected ? 'checked' : '' ?>>
                <span class="critic-card__name"><?= htmlspecialchars($critic['name']) ?></span>
                <?php if (!empty($critic['description'])): ?>
                <span class="critic-card__desc"><?= htmlspecialchars($critic['description']) ?></span>
                <?php endif; ?>
            </label>
            <?php endforeach; ?>
        </div>
    </fieldset>
    <?php endif; ?>

    <div class="form-actions">
        <button type="submit" id="save-btn" 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>

<style>
.form-row { display: flex; gap: var(--space-md); }
.form-group--half { flex: 1; }
.form-group--third { flex: 1; }
.form-group--checkbox { display: flex; align-items: center; }
fieldset { border: 1px solid var(--color-border); border-radius: 8px; padding: var(--space-md); margin-bottom: var(--space-md); }
legend { font-weight: 600; padding: 0 0.5rem; }

/* Temperature Slider */
.form-slider { width: 100%; height: 6px; border-radius: 3px; background: var(--color-bg-muted); appearance: none; cursor: pointer; margin: 0.5rem 0; }
.form-slider::-webkit-slider-thumb { appearance: none; width: 18px; height: 18px; border-radius: 50%; background: var(--color-primary); cursor: pointer; }
.form-slider::-moz-range-thumb { width: 18px; height: 18px; border-radius: 50%; background: var(--color-primary); cursor: pointer; border: none; }

/* Preset Buttons */
.preset-buttons { display: flex; gap: 0.5rem; margin-top: 0.5rem; }
.preset-btn { flex: 1; padding: 0.4rem 0.6rem; font-size: 0.8rem; border: 1px solid var(--color-border); border-radius: 4px; background: var(--color-bg); cursor: pointer; transition: all 0.2s; }
.preset-btn:hover { background: var(--color-bg-muted); }
.preset-btn--active { background: var(--color-primary); color: white; border-color: var(--color-primary); }

/* Checkbox Toggle */
.checkbox-toggle { display: flex; align-items: center; gap: 0.5rem; cursor: pointer; padding: 0.5rem 0; }
.checkbox-toggle input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; }
.checkbox-toggle__label { font-size: 0.9rem; }

/* Legend & Fieldset Info */
.legend-hint { font-weight: 400; font-size: 0.85rem; color: var(--color-text-muted); }
.fieldset-info { margin: 0 0 1rem 0; font-size: 0.9rem; color: var(--color-text-muted); }
.link-muted { color: var(--color-primary); text-decoration: none; }
.link-muted:hover { text-decoration: underline; }

/* Critic Cards */
.critic-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 0.75rem; }
.critic-card { display: flex; flex-direction: column; padding: 0.75rem 1rem; border: 2px solid var(--color-border); border-radius: 8px; cursor: pointer; transition: all 0.2s; background: var(--color-bg); }
.critic-card:hover { border-color: var(--color-primary-light); background: var(--color-bg-muted); }
.critic-card--selected { border-color: var(--color-primary); background: var(--color-primary-bg, rgba(59, 130, 246, 0.1)); }
.critic-card input[type="checkbox"] { position: absolute; opacity: 0; pointer-events: none; }
.critic-card__name { font-weight: 600; font-size: 0.95rem; margin-bottom: 0.25rem; }
.critic-card__desc { font-size: 0.8rem; color: var(--color-text-muted); line-height: 1.3; }

@media (max-width: 600px) {
    .form-row { flex-direction: column; gap: 0; }
    .critic-grid { grid-template-columns: 1fr; }
}
</style>

<script>
document.addEventListener('DOMContentLoaded', function() {
    const tempSlider = document.getElementById('temperature');
    const tempValue = document.getElementById('tempValue');
    const maxTokens = document.getElementById('max_tokens');
    const presetBtns = document.querySelectorAll('.preset-btn');

    if (tempSlider && tempValue) {
        tempSlider.addEventListener('input', function() {
            tempValue.textContent = parseFloat(this.value).toFixed(1);
            updatePresetButtons(this.value);
        });
    }

    presetBtns.forEach(btn => {
        btn.addEventListener('click', function() {
            const temp = this.dataset.temp;
            const tokens = this.dataset.tokens;
            if (tempSlider) {
                tempSlider.value = temp;
                tempValue.textContent = parseFloat(temp).toFixed(1);
            }
            if (maxTokens && tokens) {
                maxTokens.value = tokens;
            }
            updatePresetButtons(temp);
        });
    });

    function updatePresetButtons(temp) {
        presetBtns.forEach(btn => {
            btn.classList.toggle('preset-btn--active', btn.dataset.temp === temp);
        });
    }
});
</script>

<?php $content = ob_get_clean(); ?>
<?php require VIEW_PATH . '/layout.php'; ?>

Vollständig herunterladen

Aktionen

Herunterladen

Andere Versionen dieser Datei

ID Version Typ Größe Datum
2186 11 modified 19.9 KB 2025-12-30 22:51
2184 10 modified 16.5 KB 2025-12-30 22:43
2183 9 modified 15.3 KB 2025-12-30 22:42
2182 8 modified 13.6 KB 2025-12-30 22:41
2178 7 modified 13.3 KB 2025-12-30 22:37
2177 6 modified 12.2 KB 2025-12-30 22:37
2176 5 modified 11.1 KB 2025-12-30 22:36
2172 4 modified 3.0 KB 2025-12-30 22:33
1679 3 modified 3.0 KB 2025-12-27 11:49
1678 2 modified 3.0 KB 2025-12-27 11:49
1673 1 modified 3.3 KB 2025-12-27 11:44

← Zurück zur Übersicht