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
@@ -266,8 +266,14 @@ class InjectorProtocolResource extends Resource
->label(__('PDF'))
->icon('heroicon-m-document-magnifying-glass')
->color('gray')
->url(fn (InjectorProtocol $r) => route('tenant.injector-protocols.pdf', ['record' => $r->id]))
->openUrlInNewTab(),
->modalHeading(fn (InjectorProtocol $r) => __('Protocol') . ' ' . $r->protocol_number)
->modalSubmitAction(false)
->modalCancelActionLabel(__('Închide'))
->modalWidth('7xl')
->modalContent(fn (InjectorProtocol $r) => view('filament.tenant.pdf-preview', [
'pdfUrl' => route('tenant.injector-protocols.pdf', ['record' => $r->id]),
'downloadUrl' => route('tenant.injector-protocols.pdf', ['record' => $r->id, 'download' => 1]),
])),
Actions\EditAction::make(),
Actions\DeleteAction::make(),
])
@@ -18,8 +18,14 @@ class EditInjectorProtocol extends EditRecord
->label(__('Vizualizare PDF'))
->icon('heroicon-m-document-magnifying-glass')
->color('gray')
->url(fn (InjectorProtocol $record) => route('tenant.injector-protocols.pdf', ['record' => $record->id]))
->openUrlInNewTab(),
->modalHeading(fn (InjectorProtocol $record) => __('Protocol') . ' ' . $record->protocol_number)
->modalSubmitAction(false)
->modalCancelActionLabel(__('Închide'))
->modalWidth('7xl')
->modalContent(fn (InjectorProtocol $record) => view('filament.tenant.pdf-preview', [
'pdfUrl' => route('tenant.injector-protocols.pdf', ['record' => $record->id]),
'downloadUrl' => route('tenant.injector-protocols.pdf', ['record' => $record->id, 'download' => 1]),
])),
Actions\DeleteAction::make(),
];
}
@@ -188,8 +188,14 @@ class WorkOrderResource extends Resource
->label(__('PDF'))
->icon('heroicon-m-document-magnifying-glass')
->color('gray')
->url(fn (WorkOrder $r) => url('/app/work-orders/' . $r->id . '/pdf'))
->openUrlInNewTab(),
->modalHeading(fn (WorkOrder $r) => __('Factură') . ' — WO #' . $r->number)
->modalSubmitAction(false)
->modalCancelActionLabel(__('Închide'))
->modalWidth('7xl')
->modalContent(fn (WorkOrder $r) => view('filament.tenant.pdf-preview', [
'pdfUrl' => url('/app/work-orders/' . $r->id . '/pdf'),
'downloadUrl' => url('/app/work-orders/' . $r->id . '/pdf?download=1'),
])),
Actions\EditAction::make(),
Actions\DeleteAction::make(),
])
@@ -87,8 +87,14 @@ class EditWorkOrder extends EditRecord
->label(__('Vizualizare PDF'))
->icon('heroicon-m-document-magnifying-glass')
->color('gray')
->url(fn () => url('/app/work-orders/' . $this->record->id . '/pdf'))
->openUrlInNewTab(),
->modalHeading(fn () => __('Factură') . ' — WO #' . $this->record->number)
->modalSubmitAction(false)
->modalCancelActionLabel(__('Închide'))
->modalWidth('7xl')
->modalContent(fn () => view('filament.tenant.pdf-preview', [
'pdfUrl' => url('/app/work-orders/' . $this->record->id . '/pdf'),
'downloadUrl' => url('/app/work-orders/' . $this->record->id . '/pdf?download=1'),
])),
Actions\DeleteAction::make(),
];
}