new ataxchments preview code
This commit is contained in:
@@ -170,30 +170,76 @@
|
||||
</form>
|
||||
@endcan
|
||||
|
||||
@if ($ticket->attachments->isEmpty())
|
||||
@php
|
||||
$visibleAttachments = $ticket->attachments->filter(fn ($attachment) => ! $attachment->isDeletedAttachment());
|
||||
@endphp
|
||||
|
||||
@if ($visibleAttachments->isEmpty())
|
||||
<div
|
||||
class="rounded-xl border border-dashed border-zinc-300 p-4 text-center text-xs font-semibold text-zinc-500 dark:border-zinc-700">
|
||||
No supporting files have been attached yet.
|
||||
</div>
|
||||
@else
|
||||
<div class="grid gap-2 sm:grid-cols-2">
|
||||
@foreach ($ticket->attachments as $attachment)
|
||||
<a href="{{ route('helpdesk.attachments.download', $attachment->id) }}" target="_blank"
|
||||
class="group/file flex items-center justify-between gap-3 rounded-lg border border-zinc-200 px-3 py-2 text-xs transition hover:bg-zinc-50 dark:border-zinc-700 dark:hover:bg-zinc-800">
|
||||
<span class="min-w-0">
|
||||
<span class="block truncate font-bold text-zinc-900 dark:text-zinc-100">
|
||||
{{ $attachment->original_name ?? ($attachment->original_filename ?? ($attachment->filename ?? ($attachment->file_name ?? basename($attachment->path ?? ($attachment->file_path ?? ''))))) }}
|
||||
</span>
|
||||
<span class="block text-[0.7rem] text-zinc-500">
|
||||
{{ Number::fileSize($attachment->size ?? ($attachment->size_bytes ?? 0)) }}
|
||||
</span>
|
||||
</span>
|
||||
<div class="grid gap-3 sm:grid-cols-2">
|
||||
@foreach ($visibleAttachments as $attachment)
|
||||
<article
|
||||
class="group/file overflow-hidden rounded-xl border border-zinc-200 bg-white text-xs shadow-sm transition hover:bg-zinc-50 dark:border-zinc-700 dark:bg-zinc-950 dark:hover:bg-zinc-900">
|
||||
@if ($attachment->isImage())
|
||||
<a href="{{ route('helpdesk.attachments.preview', $attachment->id) }}" target="_blank"
|
||||
class="block aspect-video overflow-hidden bg-zinc-100 dark:bg-zinc-900">
|
||||
<img src="{{ route('helpdesk.attachments.preview', $attachment->id) }}" alt="{{ $attachment->displayName() }}"
|
||||
class="h-full w-full object-cover transition group-hover/file:scale-[1.02]">
|
||||
</a>
|
||||
@endif
|
||||
|
||||
<span
|
||||
class="inline-flex h-8 w-8 shrink-0 items-center justify-center rounded-lg bg-zinc-100 text-zinc-700 transition group-hover/file:bg-blue-600 group-hover/file:text-white dark:bg-zinc-800 dark:text-zinc-200">
|
||||
<i class="fa-solid fa-download text-xs" aria-hidden="true"></i>
|
||||
</span>
|
||||
</a>
|
||||
<div class="flex items-start gap-3 p-3">
|
||||
<span
|
||||
class="inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-blue-50 text-blue-700 dark:bg-blue-500/10 dark:text-blue-300">
|
||||
<i class="{{ $attachment->icon() }} text-sm" aria-hidden="true"></i>
|
||||
</span>
|
||||
|
||||
<div class="min-w-0 flex-1">
|
||||
<p class="truncate font-bold text-zinc-900 dark:text-zinc-100">
|
||||
{{ $attachment->displayName() }}
|
||||
</p>
|
||||
<p class="mt-1 text-[0.7rem] font-semibold uppercase tracking-wide text-zinc-500">
|
||||
{{ strtoupper($attachment->language()) }} · {{ Number::fileSize($attachment->byteSize()) }}
|
||||
@if ($attachment->downloadCount() > 0)
|
||||
· {{ $attachment->downloadCount() }} download{{ $attachment->downloadCount() === 1 ? '' : 's' }}
|
||||
@endif
|
||||
</p>
|
||||
|
||||
<div class="mt-3 flex flex-wrap gap-2">
|
||||
@if ($attachment->canPreview())
|
||||
<a href="{{ route('helpdesk.attachments.preview', $attachment->id) }}" target="_blank"
|
||||
class="inline-flex items-center gap-1 rounded-lg bg-green-600 px-2.5 py-1.5 text-[0.7rem] font-bold text-white hover:bg-green-700">
|
||||
<i class="fa-regular fa-eye" aria-hidden="true"></i>
|
||||
Preview
|
||||
</a>
|
||||
@endif
|
||||
|
||||
<a href="{{ route('helpdesk.attachments.download', $attachment->id) }}" target="_blank"
|
||||
class="inline-flex items-center gap-1 rounded-lg bg-blue-600 px-2.5 py-1.5 text-[0.7rem] font-bold text-white hover:bg-blue-700">
|
||||
<i class="fa-solid fa-download" aria-hidden="true"></i>
|
||||
Download
|
||||
</a>
|
||||
|
||||
@can('update', $ticket)
|
||||
<form method="POST" action="{{ route('helpdesk.attachments.destroy', $attachment->id) }}"
|
||||
onsubmit="return confirm('Remove this attachment from the ticket?');">
|
||||
@csrf
|
||||
@method('DELETE')
|
||||
<button type="submit"
|
||||
class="inline-flex items-center gap-1 rounded-lg bg-red-600 px-2.5 py-1.5 text-[0.7rem] font-bold text-white hover:bg-red-700">
|
||||
<i class="fa-regular fa-trash-can" aria-hidden="true"></i>
|
||||
Remove
|
||||
</button>
|
||||
</form>
|
||||
@endcan
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</article>
|
||||
@endforeach
|
||||
</div>
|
||||
@endif
|
||||
|
||||
Reference in New Issue
Block a user