Backup #202

ID202
Dateipfad/var/www/dev.campus.systemische-tools.de/src/View/partials/form/collections-select.php
Version1
Typ modified
Größe2.3 KB
Hash53e30713db7bbcb588992a481c76ee8e3f17ec7d189447c51c6fff1e43483fda
Datum2025-12-21 14:45:42
Geändert vonclaude-code-hook
GrundClaude Code Pre-Hook Backup vor Edit-Operation
Datei existiert Ja

Dateiinhalt

<?php

/**
 * Collections Multi-Select Partial
 *
 * Einheitliches Dropdown für RAG-Collection-Auswahl.
 * Verwendet in: Chat, Content Studio
 *
 * @param array  $collections Array von Collection-Daten aus CollectionRepository
 * @param array  $selected    Array von ausgewählten collection_ids
 * @param string $name        Form-Feldname (default: 'collections[]')
 * @param string $variant     'default' oder 'inline' für Styling
 * @param bool   $required    Mindestens eine Auswahl erforderlich
 */

$collections = $collections ?? [];
$selected = $selected ?? [];

// JSON-String zu Array konvertieren (Abwärtskompatibilität)
if (is_string($selected)) {
    $selected = json_decode($selected, true) ?: [];
}

$name = $name ?? 'collections[]';
$variant = $variant ?? 'default';
$required = $required ?? false;

$class = match ($variant) {
    'inline' => 'form-select form-select--inline',
    'checkbox' => '', // Für Checkbox-Variante
    default => 'form-select',
};
?>
<?php if ($variant === 'checkbox'): ?>
<div class="checkbox-group collections-select">
    <?php foreach ($collections as $col):
        $colId = $col['collection_id'];
        $isSelected = in_array($colId, $selected, true);
        $points = (int) ($col['points_count'] ?? 0);
    ?>
    <label class="checkbox-label" title="<?= number_format($points) ?> Dokumente">
        <input type="checkbox" name="<?= htmlspecialchars($name) ?>"
               value="<?= htmlspecialchars($colId) ?>"
               <?= $isSelected ? 'checked' : '' ?>>
        <?= htmlspecialchars($col['display_name']) ?>
        <span class="checkbox-meta">(<?= number_format($points) ?>)</span>
    </label>
    <?php endforeach; ?>
</div>
<?php else: ?>
<select name="<?= htmlspecialchars($name) ?>"
        multiple
        class="<?= $class ?> collections-select"
        title="Collections für RAG auswählen"
        <?= $required ? 'required' : '' ?>>
    <?php foreach ($collections as $col):
        $colId = $col['collection_id'];
        $isSelected = in_array($colId, $selected, true);
        $points = (int) ($col['points_count'] ?? 0);
    ?>
    <option value="<?= htmlspecialchars($colId) ?>"
            <?= $isSelected ? 'selected' : '' ?>
            title="<?= number_format($points) ?> Dokumente">
        <?= htmlspecialchars($col['display_name']) ?>
    </option>
    <?php endforeach; ?>
</select>
<?php endif; ?>

Vollständig herunterladen

Aktionen

Herunterladen

Andere Versionen dieser Datei

ID Version Typ Größe Datum
203 2 modified 2.4 KB 2025-12-21 14:45
202 1 modified 2.3 KB 2025-12-21 14:45

← Zurück zur Übersicht