proper naming

This commit is contained in:
Mark Gregory
2026-06-22 16:09:40 +01:00
parent ad84b68044
commit d311597baa
@@ -1,10 +1,41 @@
@php
$hasRunningTimer = method_exists($this, 'hasRunningTimer') && (bool)$this->hasRunningTimer();
use Illuminate\Support\Facades\Schema;
use Modules\Helpdesk\Models\TicketTimeLog;
$ticketTimeLogTable = (new TicketTimeLog())->getTable();
$runningTimerQuery = TicketTimeLog::query()
->where('ticket_id', $ticket->getKey())
->orderByDesc('started_at');
if (Schema::hasColumn($ticketTimeLogTable, 'user_id')) {
$runningTimerQuery->where('user_id', auth()->id());
}
if (Schema::hasColumn($ticketTimeLogTable, 'ended_at')) {
$runningTimerQuery->whereNull('ended_at');
}
if (Schema::hasColumn($ticketTimeLogTable, 'stopped_at')) {
$runningTimerQuery->whereNull('stopped_at');
}
if (Schema::hasColumn($ticketTimeLogTable, 'finished_at')) {
$runningTimerQuery->whereNull('finished_at');
}
$runningTimer = $runningTimerQuery->first();
$runningTimerStartedAt = $runningTimer?->started_at;
$runningTimerElapsedSeconds = $runningTimerStartedAt
? max(0, now()->diffInSeconds($runningTimerStartedAt))
: 0;
$runningTimerElapsedDisplay = gmdate('H:i:s', $runningTimerElapsedSeconds);
$hasRunningTimer = $runningTimerStartedAt !== null;
@endphp
@can('update', $ticket)
<details
@if ($hasRunningTimer) open @endif
@if ($hasRunningTimer) wire:poll.1s @endif
class="group rounded-xl border border-zinc-200 bg-white p-4 shadow-sm dark:border-zinc-700 dark:bg-zinc-900"
data-helpdesk-ticket-controls>
<summary
@@ -14,17 +45,33 @@
class="inline-flex h-12 w-12 shrink-0 items-center justify-center rounded-xl bg-indigo-950 text-white ring-1 ring-indigo-300/60 shadow-lg">
<i class="fa-solid fa-sliders text-lg" aria-hidden="true"></i>
</span>
<div class="min-w-0">
<h2 class="text-lg font-black uppercase tracking-wide">Ticket controls</h2>
<p class="text-xs font-semibold text-indigo-100">Log time, assignment, status and
priority
<p class="text-xs font-semibold text-indigo-100">
Log time, assignment, status and priority
</p>
</div>
</div>
<span
class="inline-flex h-9 w-9 shrink-0 items-center justify-center rounded-xl bg-white/15 text-white ring-1 ring-white/20">
<i class="fa-solid fa-chevron-right text-xs transition group-open:rotate-90" aria-hidden="true"></i>
<span class="inline-flex shrink-0 items-center gap-2">
@if ($hasRunningTimer)
<span
class="inline-flex items-center gap-2 rounded-xl bg-emerald-400/20 px-3 py-2 text-xs font-black text-emerald-50 ring-1 ring-emerald-200/40"
data-dusk="ticket-running-timer-summary">
<span class="relative flex h-2.5 w-2.5">
<span class="absolute inline-flex h-full w-full animate-ping rounded-full bg-emerald-200 opacity-75"></span>
<span class="relative inline-flex h-2.5 w-2.5 rounded-full bg-emerald-300"></span>
</span>
<span>Running</span>
<span class="font-mono" data-dusk="ticket-running-elapsed-summary">{{ $runningTimerElapsedDisplay }}</span>
</span>
@endif
<span
class="inline-flex h-9 w-9 items-center justify-center rounded-xl bg-white/15 text-white ring-1 ring-white/20">
<i class="fa-solid fa-chevron-right text-xs transition group-open:rotate-90" aria-hidden="true"></i>
</span>
</span>
</summary>
@@ -35,6 +82,33 @@
</div>
@endif
@if ($hasRunningTimer)
<div
class="mb-4 rounded-xl border border-emerald-300 bg-emerald-50 p-3 text-emerald-950 shadow-sm dark:border-emerald-800 dark:bg-emerald-950 dark:text-emerald-100"
data-helpdesk-running-timer>
<div class="flex items-center justify-between gap-3">
<div class="min-w-0">
<p class="text-[0.68rem] font-black uppercase tracking-[0.18em] text-emerald-700 dark:text-emerald-300">
Timer running
</p>
<p class="mt-1 text-xs font-semibold text-emerald-800 dark:text-emerald-200">
Started {{ $runningTimerStartedAt->format('d M Y H:i:s') }}
</p>
</div>
<div class="shrink-0 text-right">
<p class="font-mono text-2xl font-black leading-none text-emerald-900 dark:text-emerald-100"
data-dusk="ticket-running-elapsed-time">
{{ $runningTimerElapsedDisplay }}
</p>
<p class="mt-1 text-[0.65rem] font-bold uppercase tracking-wide text-emerald-700 dark:text-emerald-300">
Elapsed
</p>
</div>
</div>
</div>
@endif
@include('helpdesk::partials.ticket-time-timer', [
'ticket' => $ticket,
])