Backup #203

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

Dateiinhalt

<?php

/**
 * Collections 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', 'inline' oder 'checkbox'
 * @param bool   $multiple    Multi-Select (default: true)
 * @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';
$multiple = $multiple ?? true;
$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