feat(pdf): preview in Filament modal (iframe) instead of new tab

All "Vizualizare PDF" actions now open a wide (7xl) Filament modal
containing an iframe pointing at the inline PDF endpoint, with a
top-right "Descarcă" and "Deschide în tab nou" fallback.

- WorkOrder edit action + WO table row action
- InjectorProtocol edit action + protocols table row action
- Dashboard Docs tab preview button (Alpine.js overlay since it's
  a plain Blade view, not a Filament action)

The underlying /pdf routes stay unchanged (Content-Disposition: inline,
?download=1 for attachment) — the iframe just loads the same URL.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-06 05:47:07 +00:00
parent e289fbc068
commit c9d400fd6e
8 changed files with 68 additions and 11 deletions
@@ -687,13 +687,28 @@
{{-- ── DOCUMENTS TAB ── --}}
<div x-show="tab === 'docs'" x-cloak>
<div style="display:flex;flex-direction:column;gap:8px;">
<a class="wd-btn" href="{{ url('/app/work-orders/' . $wo->id . '/pdf') }}" target="_blank">
<div style="display:flex;flex-direction:column;gap:8px;" x-data="{ pdfOpen: false }">
<button type="button" class="wd-btn" @click="pdfOpen = true">
🔍 {{ __('Vizualizează factură (PDF)') }}
</a>
</button>
<a class="wd-btn" href="{{ url('/app/work-orders/' . $wo->id . '/pdf?download=1') }}">
⬇️ {{ __('Descarcă factură (PDF)') }}
</a>
{{-- PDF preview modal (Alpine.js overlay) --}}
<div x-show="pdfOpen" x-cloak
style="position:fixed;inset:0;background:rgba(0,0,0,0.6);z-index:9999;display:flex;align-items:center;justify-content:center;padding:24px;"
@click.self="pdfOpen = false"
@keydown.escape.window="pdfOpen = false">
<div style="background:#fff;border-radius:8px;width:100%;max-width:1000px;height:90vh;display:flex;flex-direction:column;overflow:hidden;">
<div style="display:flex;align-items:center;justify-content:space-between;padding:10px 14px;border-bottom:1px solid #e5e7eb;">
<b style="font-size:14px;">{{ __('Factură') }} WO #{{ $wo->number }}</b>
<button type="button" @click="pdfOpen = false" style="background:none;border:none;font-size:20px;cursor:pointer;color:#6b7280;"></button>
</div>
<iframe x-bind:src="pdfOpen ? '{{ url('/app/work-orders/' . $wo->id . '/pdf') }}#toolbar=1&navpanes=0' : ''"
style="flex:1;width:100%;border:none;" title="PDF"></iframe>
</div>
</div>
@php $signed = $wo->getMedia('signed_documents'); @endphp
@if ($signed->isNotEmpty())
<div style="font-size:11px;color:var(--wd-text-3);text-transform:uppercase;margin-top:12px;">{{ __('Documente semnate') }}</div>
@@ -0,0 +1,14 @@
{{-- Reusable PDF preview iframe (loaded inside a Filament action modal).
$pdfUrl inline PDF endpoint (Content-Disposition: inline).
$downloadUrl same URL with ?download=1, shown as a fallback link. --}}
<div style="display:flex;flex-direction:column;gap:10px;">
<div style="display:flex;justify-content:flex-end;gap:8px;">
<a href="{{ $downloadUrl }}" class="text-primary-600 hover:underline text-sm font-medium">
⬇️ {{ __('Descarcă') }}
</a>
<a href="{{ $pdfUrl }}" target="_blank" class="text-primary-600 hover:underline text-sm font-medium">
↗️ {{ __('Deschide în tab nou') }}
</a>
</div>
<iframe src="{{ $pdfUrl }}#toolbar=1&navpanes=0" style="width:100%;height:75vh;border:1px solid var(--fi-color-gray-200,#e5e7eb);border-radius:6px;" title="PDF"></iframe>
</div>