@props([ /** Catalog from EntityFilterCatalog::for($type). */ 'catalog' => [], /** ID for the form element (used by toolbar toggle target). */ 'id' => 'dynamic-filters', /** Form action — defaults to current URL. */ 'action' => null, /** Whether the filter panel starts open. Default: closed (toggle). */ 'open' => false, /** Localized search placeholder, optional. */ 'searchPlaceholder' => null, ]) @php $action = $action ?? url()->current(); // Active-filter chip list. Each entry { field, option_id, name, label_name }. $activeChips = []; foreach ($catalog as $entry) { if (empty($entry['selected'])) continue; $optionsById = []; foreach ($entry['options'] as $opt) { $optionsById[(int) $opt['id']] = $opt; } foreach ($entry['selected'] as $id) { $opt = $optionsById[(int) $id] ?? null; if (! $opt) continue; $activeChips[] = [ 'field' => $entry['field'], 'option_id' => (int) $id, 'name' => (string) ($opt['name'] ?? ''), 'label_name' => (string) ($entry['label_name'] ?? ''), ]; } } $hasAnyFilters = count($catalog) > 0; $searchValue = (string) request('q', ''); $hasAnyActive = $searchValue !== '' || count($activeChips) > 0; // Open by default if any filters are already active so the admin can // see what's selected; otherwise stay collapsed for a cleaner UI. $panelOpen = $open || count($activeChips) > 0; @endphp {{-- Filter UI — rectangular inputs, Select2 multi-selects, show/hide panel. Layout: Row 1: search input + "Filters" toggle (with count badge) Row 2: active filter chips (only when any are active) Row 3: panel with one Select2 per label group + Apply/Reset (collapsed by default; expands when toggle is clicked) Single
@once @push('styles') @endpush @push('scripts') @endpush @endonce