Fix broken Issue ticket form Alpine markup.
Deploy Ladill Queue / deploy (push) Successful in 1m18s

JSON inside x-data broke the attribute and dumped JS onto the page; use a plain Blade form with queue-driven service points instead.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
isaacclad
2026-07-17 19:49:16 +00:00
co-authored by Cursor
parent 9c92a04a74
commit 74c7782cdf
3 changed files with 51 additions and 57 deletions
@@ -65,7 +65,15 @@ class TicketController extends Controller
->orderBy('name')
->get();
return view('qms.tickets.create', compact('queues', 'organization'));
$selectedQueueId = (int) (
old('service_queue_id')
?? $request->query('queue')
?? $queues->first()?->id
?? 0
);
$selectedQueue = $queues->firstWhere('id', $selectedQueueId) ?? $queues->first();
return view('qms.tickets.create', compact('queues', 'organization', 'selectedQueue'));
}
public function store(Request $request): RedirectResponse
+30 -56
View File
@@ -1,38 +1,9 @@
<x-app-layout title="Issue ticket">
@php
$queuePayload = $queues->map(fn ($queue) => [
'id' => $queue->id,
'label' => $queue->name.($queue->branch ? ' ('.$queue->branch->name.')' : ''),
'assigned_only' => $queue->usesAssignedOnlyRouting(),
'counters' => $queue->counters->map(fn ($c) => [
'id' => $c->id,
'label' => $c->name.($c->code ? ' · '.$c->code : ''),
])->values(),
])->values();
$selectedQueueId = (int) ($selectedQueue?->id ?? 0);
$needsPoint = $selectedQueue?->usesAssignedOnlyRouting() ?? false;
@endphp
<div
class="mx-auto max-w-lg"
x-data="{
queues: @json($queuePayload),
queueId: @json(old('service_queue_id', $queues->first()?->id)),
counterId: @json(old('assigned_counter_id')),
get selected() {
return this.queues.find(q => String(q.id) === String(this.queueId)) || null
},
get needsPoint() {
return Boolean(this.selected?.assigned_only)
},
get counters() {
return this.selected?.counters || []
},
onQueueChange() {
if (! this.counters.some(c => String(c.id) === String(this.counterId))) {
this.counterId = this.counters[0]?.id || ''
}
}
}"
x-init="onQueueChange()"
>
<div class="mx-auto max-w-lg">
<h1 class="text-2xl font-semibold">Issue ticket</h1>
<form method="POST" action="{{ route('qms.tickets.store') }}" class="mt-6 space-y-4 rounded-2xl border bg-white p-6 dark:border-slate-700 dark:bg-slate-900">
@csrf
@@ -42,36 +13,39 @@
name="service_queue_id"
required
class="mt-1 w-full rounded-lg border-slate-300 text-sm"
x-model="queueId"
@change="onQueueChange()"
onchange="window.location = @json(route('qms.tickets.create')).concat('?queue=', encodeURIComponent(this.value))"
>
<template x-for="queue in queues" :key="queue.id">
<option :value="queue.id" x-text="queue.label"></option>
</template>
@foreach ($queues as $queue)
<option value="{{ $queue->id }}" @selected($selectedQueueId === (int) $queue->id)>
{{ $queue->name }}{{ $queue->branch ? ' ('.$queue->branch->name.')' : '' }}
</option>
@endforeach
</select>
@error('service_queue_id')
<p class="mt-1 text-sm text-rose-600">{{ $message }}</p>
@enderror
</div>
<div x-show="needsPoint" x-cloak>
<label class="block text-sm font-medium">Service point</label>
<select
name="assigned_counter_id"
class="mt-1 w-full rounded-lg border-slate-300 text-sm"
x-model="counterId"
:required="needsPoint"
:disabled="!needsPoint"
>
<option value="">Select service point</option>
<template x-for="counter in counters" :key="counter.id">
<option :value="counter.id" x-text="counter.label"></option>
</template>
</select>
<p class="mt-1 text-xs text-slate-500">This queue only serves tickets assigned to a desk or room.</p>
@error('assigned_counter_id')
<p class="mt-1 text-sm text-rose-600">{{ $message }}</p>
@enderror
</div>
@if ($needsPoint)
<div>
<label class="block text-sm font-medium">Service point</label>
<select name="assigned_counter_id" required class="mt-1 w-full rounded-lg border-slate-300 text-sm">
<option value="">Select service point</option>
@forelse ($selectedQueue->counters as $counter)
<option value="{{ $counter->id }}" @selected((string) old('assigned_counter_id') === (string) $counter->id)>
{{ $counter->name }}{{ $counter->code ? ' · '.$counter->code : '' }}
</option>
@empty
<option value="" disabled>No service points linked to this queue</option>
@endforelse
</select>
<p class="mt-1 text-xs text-slate-500">This queue only serves tickets assigned to a desk or room.</p>
@error('assigned_counter_id')
<p class="mt-1 text-sm text-rose-600">{{ $message }}</p>
@enderror
</div>
@endif
<div>
<label class="block text-sm font-medium">Customer name</label>
<input name="customer_name" value="{{ old('customer_name') }}" class="mt-1 w-full rounded-lg border-slate-300 text-sm">
+12
View File
@@ -117,6 +117,18 @@ class ServicePointRoutingTest extends TestCase
]);
}
public function test_web_issue_create_page_shows_service_point_without_alpine_leak(): void
{
[$user, , , $queue] = $this->setUpAssignedConsultation();
$this->actingAs($user)
->get(route('qms.tickets.create', ['queue' => $queue->id]))
->assertOk()
->assertSee('Service point')
->assertDontSee('needsPoint')
->assertDontSee('onQueueChange');
}
public function test_web_issue_without_service_point_returns_validation_error_not_500(): void
{
[$user, , , $queue] = $this->setUpAssignedConsultation();