{{-- resources/views/filament/components/article-comparison.blade.php --}} {{-- Story 5-16: Side-by-side article translation comparison --}} {{-- Rendered inside Filament slide-over modal via modalContent() --}} @php $currentBlocks = $current->blocks ?? []; $counterpartBlocks = $counterpart->blocks ?? []; $maxCount = max(count($currentBlocks), count($counterpartBlocks)); /** * Check if a block's content fields are considered empty/missing. */ $isBlockEmpty = function (array $block): bool { $data = $block['data'] ?? []; $contentKeys = ['text', 'content', 'items', 'path', 'url', 'images']; foreach ($contentKeys as $key) { if (! array_key_exists($key, $data)) { continue; } $value = $data[$key]; if (is_null($value) || $value === '' || $value === []) { return true; } } return false; }; $localeLabels = ['fr' => 'Français', 'en' => 'English']; $localeBadgeColors = [ 'fr' => 'background:#dbeafe;color:#1e40af;border:1px solid #93c5fd;', 'en' => 'background:#dcfce7;color:#166534;border:1px solid #86efac;', ]; $blockTypeLabels = [ 'paragraph' => 'Paragraphe', 'classic' => 'Classique', 'heading' => 'Titre', 'list' => 'Liste', 'quote' => 'Citation', 'image' => 'Image', 'gallery' => 'Galerie', 'video' => 'Vidéo', 'link' => 'Lien', 'button' => 'Bouton', 'banner' => 'Bannière', 'kpi' => 'KPI', ]; @endphp
{{-- ── Left column: Current article ── --}}
{{-- Column header --}}
{{ strtoupper($current->locale) }} {{ $current->title ?: '(Sans titre)' }}
{{-- Blocks --}}
@for ($i = 0; $i < $maxCount; $i++) @if (isset($currentBlocks[$i])) @php $block=$currentBlocks[$i]; @endphp
{{-- Block type label --}}
{{ $blockTypeLabels[$block['type']] ?? ucfirst($block['type']) }}
{{-- Block content --}} @include('filament.components.partials.comparison-block', ['block' => $block])
@else {{-- Missing block placeholder --}}
Bloc absent
@endif @endfor @if ($maxCount === 0)
Aucun bloc
@endif
{{-- ── Right column: Counterpart article ── --}}
{{-- Column header --}}
{{ strtoupper($counterpart->locale) }} {{ $counterpart->title ?: '(Sans titre)' }}
{{-- Blocks --}}
@for ($i = 0; $i < $maxCount; $i++) @if (isset($counterpartBlocks[$i])) @php $block=$counterpartBlocks[$i]; $empty=$isBlockEmpty($block); @endphp
{{-- Block type label + empty warning --}}
{{ $blockTypeLabels[$block['type']] ?? ucfirst($block['type']) }} @if ($empty) Contenu manquant @endif
{{-- Block content --}} @include('filament.components.partials.comparison-block', ['block' => $block])
@else {{-- Missing block placeholder --}}
Bloc absent
@endif @endfor @if ($maxCount === 0)
Aucun bloc
@endif