feat: registration field polish, multi-category tags, file uploads, Partner icon

- Restructure field editor dialog: move Options section to bottom with
  divider and subheader, fix delete button with flex layout
- Change tag_category (single string) to tag_categories (JSON array)
  supporting multiple category selection in tag picker fields
- Portal tag picker now groups tags by category with subheaders
- Add generic file upload endpoint (FileUploadService + UploadController)
- Replace email branding logo URL text field with ImageUploadField
- Update Partner crowd type default icon to tabler-affiliate
- Apply changes consistently to both field and template dialogs

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-04-16 18:03:49 +02:00
parent d57dcdb616
commit 6a8d21a5b6
31 changed files with 813 additions and 239 deletions

View File

@@ -317,7 +317,7 @@ class PublicRegistrationDataTest extends TestCase
RegistrationFormField::factory()->tagPickerField()->create([
'event_id' => $event->id,
'tag_category' => 'Certificaat',
'tag_categories' => ['Certificaat'],
'is_portal_visible' => true,
'is_admin_only' => false,
]);

View File

@@ -0,0 +1,125 @@
<?php
declare(strict_types=1);
namespace Tests\Feature\Api\V1;
use App\Models\Organisation;
use App\Models\User;
use Database\Seeders\RoleSeeder;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Http\UploadedFile;
use Illuminate\Support\Facades\Storage;
use Laravel\Sanctum\Sanctum;
use Tests\TestCase;
class UploadTest extends TestCase
{
use RefreshDatabase;
private User $user;
private Organisation $organisation;
protected function setUp(): void
{
parent::setUp();
$this->seed(RoleSeeder::class);
$this->organisation = Organisation::factory()->create();
$this->user = User::factory()->create();
$this->organisation->users()->attach($this->user, ['role' => 'org_admin']);
Storage::fake('public');
}
public function test_upload_image_succeeds_with_valid_png(): void
{
Sanctum::actingAs($this->user);
$file = UploadedFile::fake()->image('logo.png', 200, 200);
$response = $this->postJson('/api/v1/upload/image', [
'file' => $file,
'purpose' => 'logo',
]);
$response->assertOk()
->assertJsonStructure(['data' => ['url']]);
$url = $response->json('data.url');
$this->assertStringContainsString('uploads/logo', $url);
}
public function test_upload_image_rejects_unsupported_mime(): void
{
Sanctum::actingAs($this->user);
$file = UploadedFile::fake()->create('document.pdf', 100, 'application/pdf');
$response = $this->postJson('/api/v1/upload/image', [
'file' => $file,
'purpose' => 'logo',
]);
$response->assertStatus(422);
}
public function test_upload_image_rejects_oversized_file(): void
{
Sanctum::actingAs($this->user);
$file = UploadedFile::fake()->image('large.png')->size(6000); // 6MB > 5MB limit
$response = $this->postJson('/api/v1/upload/image', [
'file' => $file,
'purpose' => 'logo',
]);
$response->assertStatus(422);
}
public function test_upload_image_requires_authentication(): void
{
$file = UploadedFile::fake()->image('logo.png', 200, 200);
$response = $this->postJson('/api/v1/upload/image', [
'file' => $file,
'purpose' => 'logo',
]);
$response->assertUnauthorized();
}
public function test_upload_image_logs_activity(): void
{
Sanctum::actingAs($this->user);
$file = UploadedFile::fake()->image('logo.png', 200, 200);
$this->postJson('/api/v1/upload/image', [
'file' => $file,
'purpose' => 'logo',
]);
$this->assertDatabaseHas('activity_log', [
'log_name' => 'upload',
'description' => 'image.uploaded',
'causer_id' => $this->user->id,
]);
}
public function test_upload_image_requires_valid_purpose(): void
{
Sanctum::actingAs($this->user);
$file = UploadedFile::fake()->image('logo.png', 200, 200);
$response = $this->postJson('/api/v1/upload/image', [
'file' => $file,
'purpose' => 'invalid',
]);
$response->assertUnprocessable()
->assertJsonValidationErrors('purpose');
}
}

View File

@@ -121,32 +121,32 @@ class RegistrationFormFieldTest extends TestCase
->assertJsonValidationErrors('options');
}
public function test_store_tag_picker_accepts_tag_category(): void
public function test_store_tag_picker_accepts_tag_categories(): void
{
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/registration-fields", [
'label' => 'Vaardigheden',
'field_type' => 'tag_picker',
'tag_category' => 'Vaardigheid',
'tag_categories' => ['Vaardigheid', 'Horeca'],
]);
$response->assertCreated()
->assertJsonPath('data.tag_category', 'Vaardigheid');
->assertJsonPath('data.tag_categories', ['Vaardigheid', 'Horeca']);
}
public function test_store_text_field_rejects_tag_category(): void
public function test_store_text_field_rejects_tag_categories(): void
{
Sanctum::actingAs($this->orgAdmin);
$response = $this->postJson("/api/v1/organisations/{$this->organisation->id}/events/{$this->event->id}/registration-fields", [
'label' => 'Naam',
'field_type' => 'text',
'tag_category' => 'Vaardigheid',
'tag_categories' => ['Vaardigheid'],
]);
$response->assertUnprocessable()
->assertJsonValidationErrors('tag_category');
->assertJsonValidationErrors('tag_categories');
}
public function test_slug_uniqueness_per_event(): void