proper closer status

This commit is contained in:
Mark Gregory
2026-06-23 11:01:55 +01:00
parent e12ab543e8
commit a6148f9bfd
8 changed files with 329 additions and 50 deletions
@@ -101,7 +101,8 @@
</form>
<form method="POST" action="{{ route('helpdesk.tickets.status.update', $ticket) }}"
class="mb-4 space-y-2">
class="mb-4 space-y-2"
data-helpdesk-status-form>
@csrf
<label class="block text-xs font-bold text-zinc-700 dark:text-zinc-200"
@@ -111,7 +112,9 @@
data-dusk="ticket-show-status">
@foreach ($statuses as $status)
<option
value="{{ $status->id }}" @selected((int) $status_id === (int) $status->id)>{{ $status->name }}
value="{{ $status->id }}"
data-is-closed="{{ $status->is_closed ? '1' : '0' }}"
@selected((int) $status_id === (int) $status->id)>{{ $status->name }}
</option>
@endforeach
</select>
@@ -120,6 +123,58 @@
<p class="text-xs font-bold text-red-600 dark:text-red-400">{{ $message }}</p>
@enderror
@error('closure_comment')
<p class="text-xs font-bold text-red-600 dark:text-red-400">{{ $message }}</p>
@enderror
<dialog data-helpdesk-close-ticket-dialog
class="w-full max-w-lg rounded-2xl border border-zinc-200 bg-white p-0 shadow-2xl backdrop:bg-slate-950/70 dark:border-zinc-700 dark:bg-zinc-900">
<div class="bg-gradient-to-r from-red-800 via-red-700 to-slate-900 px-5 py-4 text-white">
<div class="flex items-center gap-3">
<span class="inline-flex h-10 w-10 shrink-0 items-center justify-center rounded-xl bg-white/15 text-white ring-1 ring-white/20">
<i class="fa-solid fa-lock" aria-hidden="true"></i>
</span>
<div class="min-w-0">
<h3 class="text-base font-black tracking-tight">Close ticket</h3>
<p class="text-xs font-semibold text-red-100">A closure comment is required for the audit trail.</p>
</div>
</div>
</div>
<div class="space-y-4 p-5">
<label class="block text-xs font-bold text-zinc-700 dark:text-zinc-200" for="closure_comment">
Closure comment <span class="text-red-600">*</span>
</label>
<textarea id="closure_comment" name="closure_comment" rows="5" minlength="10" maxlength="5000"
placeholder="Explain what was completed, verified, or agreed before closing this ticket."
class="block w-full rounded-xl border border-zinc-300 bg-white p-3 text-sm font-semibold text-zinc-900 shadow-sm focus:border-red-500 focus:ring-red-500 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100"
data-helpdesk-closure-comment>{{ old('closure_comment') }}</textarea>
<label class="flex items-start gap-3 rounded-xl border border-emerald-200 bg-emerald-50 p-3 text-sm text-emerald-950 dark:border-emerald-900 dark:bg-emerald-950 dark:text-emerald-100">
<input type="hidden" name="closure_internal" value="0">
<input type="checkbox" name="closure_internal" value="1"
class="mt-1 rounded border-emerald-400 text-purple-600 focus:ring-purple-500">
<span>
<span class="block font-extrabold">Internal closure note</span>
<span class="mt-1 block text-xs font-semibold opacity-80">Leave unticked to save the closure as a public customer-visible response.</span>
</span>
</label>
<div class="flex flex-col-reverse gap-2 sm:flex-row sm:justify-end">
<button type="button" data-helpdesk-close-dialog-cancel
class="inline-flex items-center justify-center rounded-lg border border-zinc-300 bg-white px-4 py-2 text-xs font-black text-zinc-700 shadow-sm hover:bg-zinc-50 dark:border-zinc-700 dark:bg-zinc-950 dark:text-zinc-100 dark:hover:bg-zinc-800">
Cancel
</button>
<button type="submit" data-helpdesk-confirm-close
class="inline-flex items-center justify-center rounded-lg bg-red-600 px-4 py-2 text-xs font-black text-white shadow-sm hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-red-400/70">
<i class="fa-solid fa-lock mr-2" aria-hidden="true"></i>
Close ticket
</button>
</div>
</div>
</dialog>
<button type="submit" dusk="update-status"
class="inline-flex items-center justify-center rounded-lg bg-blue-600 px-3 py-2 text-xs font-black text-white shadow-sm transition hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-400/70">
<i class="fa-solid fa-circle-check mr-2" aria-hidden="true"></i>
@@ -154,4 +209,36 @@
</button>
</form>
</details>
<script>
document.addEventListener('DOMContentLoaded', function () {
document.querySelectorAll('[data-helpdesk-status-form]').forEach(function (form) {
const statusSelect = form.querySelector('[data-dusk="ticket-show-status"]');
const dialog = form.querySelector('[data-helpdesk-close-ticket-dialog]');
const comment = form.querySelector('[data-helpdesk-closure-comment]');
const cancel = form.querySelector('[data-helpdesk-close-dialog-cancel]');
if (!statusSelect || !dialog || !comment) {
return;
}
form.addEventListener('submit', function (event) {
const selectedOption = statusSelect.options[statusSelect.selectedIndex];
const isClosing = selectedOption?.dataset?.isClosed === '1';
if (!isClosing || comment.value.trim().length >= 10) {
return;
}
event.preventDefault();
dialog.showModal();
comment.focus();
});
cancel?.addEventListener('click', function () {
dialog.close();
});
});
});
</script>
@endcan