feat(pdf): inline preview by default with ?download=1 override + vehicle photo fallback
- WorkOrder and InjectorProtocol PDF routes now respond with Content-Disposition: inline (opens in browser tab so the user can read/print/save from the built-in PDF viewer). ?download=1 forces the classic attachment download. - CalendarBoard exportPdf() switched to the same inline default. - WO edit action + WO table row action + injector protocol actions now use ->url(...)->openUrlInNewTab() instead of streaming the PDF inline into the current tab. - Dashboard Docs tab has both a preview link and a "Descarcă" link. - Vehicle card photo falls back to WO's first uploaded photo when Vehicle model has no MediaLibrary integration of its own. Test CalendarEnhancementsTest updated to assert the new inline response headers. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -495,9 +495,15 @@
|
||||
</div>
|
||||
@if ($wo->vehicle)
|
||||
@php
|
||||
// 1) Vehicle's own photo (if the model uses MediaLibrary), else
|
||||
// 2) fall back to the first WO photo (uploaded via edit form).
|
||||
$photoUrl = method_exists($wo->vehicle, 'getFirstMediaUrl')
|
||||
? ($wo->vehicle->getFirstMediaUrl('photos') ?: null)
|
||||
: null;
|
||||
if (! $photoUrl) {
|
||||
$woFirst = $wo->getFirstMedia('photos');
|
||||
$photoUrl = $woFirst?->getFullUrl();
|
||||
}
|
||||
@endphp
|
||||
@if ($photoUrl)
|
||||
<img class="wd-vehicle-photo" src="{{ $photoUrl }}" alt="{{ $wo->vehicle->make }}">
|
||||
@@ -683,7 +689,10 @@
|
||||
<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">
|
||||
📄 {{ __('Descarcă factură (PDF)') }}
|
||||
🔍 {{ __('Vizualizează factură (PDF)') }}
|
||||
</a>
|
||||
<a class="wd-btn" href="{{ url('/app/work-orders/' . $wo->id . '/pdf?download=1') }}">
|
||||
⬇️ {{ __('Descarcă factură (PDF)') }}
|
||||
</a>
|
||||
@php $signed = $wo->getMedia('signed_documents'); @endphp
|
||||
@if ($signed->isNotEmpty())
|
||||
|
||||
Reference in New Issue
Block a user