Fix programme attachment dropdown always appearing disabled on events.
Deploy Ladill Events / deploy (push) Successful in 31s
Deploy Ladill Events / deploy (push) Successful in 31s
Load itinerary options in the event show controller and link to programme creation when none exist yet. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -206,6 +206,13 @@ class QrCodeController extends Controller
|
||||
]);
|
||||
}
|
||||
|
||||
$itineraryOptions = $qrCode->type === QrCode::TYPE_EVENT
|
||||
? $account->qrCodes()
|
||||
->where('type', QrCode::TYPE_ITINERARY)
|
||||
->orderBy('label')
|
||||
->get(['id', 'label'])
|
||||
: collect();
|
||||
|
||||
return view('qr-codes.show', [
|
||||
'qrCode' => $qrCode,
|
||||
'previewDataUri' => $previewDataUri,
|
||||
@@ -229,6 +236,7 @@ class QrCodeController extends Controller
|
||||
'customDomains' => \App\Models\CustomDomain::where('qr_code_id', $qrCode->id)->get(),
|
||||
'customDomainsEnabled' => app(\App\Services\CustomDomain\CustomDomainService::class)->enabled(),
|
||||
'customDomainServerIp' => config('customdomain.server_ip'),
|
||||
'itineraryOptions' => $itineraryOptions,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
@@ -629,7 +629,12 @@
|
||||
<label class="block text-[11px] font-medium text-slate-500">Programme outline <span class="text-slate-400">(optional)</span></label>
|
||||
@if($itineraryOptions->isEmpty())
|
||||
<p class="mt-1 rounded-xl border border-dashed border-slate-200 bg-slate-50 px-3.5 py-2.5 text-xs text-slate-400">
|
||||
Create an Itinerary QR code first to attach it here as the event programme.
|
||||
@if(Route::has('programmes.create'))
|
||||
<a href="{{ route('programmes.create') }}" class="font-medium text-indigo-600 hover:text-indigo-800">Create a programme</a>
|
||||
first to attach it here as the event outline.
|
||||
@else
|
||||
Create a programme first to attach it here as the event outline.
|
||||
@endif
|
||||
</p>
|
||||
@else
|
||||
<select name="programme_qr_id" class="mt-1 w-full rounded-xl border border-slate-200 px-3 py-2.5 text-sm text-slate-700 focus:border-indigo-400 focus:outline-none focus:ring-1 focus:ring-indigo-400/30">
|
||||
|
||||
@@ -0,0 +1,73 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\QrCode;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Tests\TestCase;
|
||||
|
||||
class EventProgrammeAttachmentTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
protected function setUp(): void
|
||||
{
|
||||
parent::setUp();
|
||||
$this->withoutMiddleware(\App\Http\Middleware\EnsurePlatformSession::class);
|
||||
Http::fake([
|
||||
config('billing.api_url').'/balance*' => Http::response(['balance_minor' => 50000]),
|
||||
]);
|
||||
}
|
||||
|
||||
public function test_event_show_lists_programmes_for_attachment(): void
|
||||
{
|
||||
$owner = User::factory()->create(['public_id' => 'usr_prog_attach']);
|
||||
|
||||
$programme = QrCode::create([
|
||||
'user_id' => $owner->id,
|
||||
'short_code' => 'prog-attach-1',
|
||||
'type' => QrCode::TYPE_ITINERARY,
|
||||
'label' => 'Summit schedule',
|
||||
'payload' => ['content' => ['title' => 'Summit schedule'], 'style' => []],
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$event = QrCode::create([
|
||||
'user_id' => $owner->id,
|
||||
'short_code' => 'evt-attach-1',
|
||||
'type' => QrCode::TYPE_EVENT,
|
||||
'label' => 'Annual summit',
|
||||
'payload' => ['content' => ['name' => 'Annual summit'], 'style' => []],
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$this->actingAs($owner)
|
||||
->get(route('events.show', $event))
|
||||
->assertOk()
|
||||
->assertSee('name="programme_qr_id"', false)
|
||||
->assertSee('Summit schedule', false)
|
||||
->assertDontSee('Create a programme first to attach it here', false);
|
||||
}
|
||||
|
||||
public function test_event_show_prompts_to_create_programme_when_none_exist(): void
|
||||
{
|
||||
$owner = User::factory()->create(['public_id' => 'usr_prog_empty']);
|
||||
|
||||
$event = QrCode::create([
|
||||
'user_id' => $owner->id,
|
||||
'short_code' => 'evt-empty-1',
|
||||
'type' => QrCode::TYPE_EVENT,
|
||||
'label' => 'Workshop',
|
||||
'payload' => ['content' => ['name' => 'Workshop'], 'style' => []],
|
||||
'is_active' => true,
|
||||
]);
|
||||
|
||||
$this->actingAs($owner)
|
||||
->get(route('events.show', $event))
|
||||
->assertOk()
|
||||
->assertSee('Create a programme', false)
|
||||
->assertDontSee('name="programme_qr_id"', false);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user