Fix event naming and checklist labels
This commit is contained in:
@@ -109,8 +109,9 @@ class EventResource extends Resource
|
|||||||
->columns([
|
->columns([
|
||||||
Tables\Columns\TextColumn::make('id')->sortable(),
|
Tables\Columns\TextColumn::make('id')->sortable(),
|
||||||
Tables\Columns\TextColumn::make('tenant.name')->label(__('admin.events.table.tenant'))->searchable(),
|
Tables\Columns\TextColumn::make('tenant.name')->label(__('admin.events.table.tenant'))->searchable(),
|
||||||
Tables\Columns\TextColumn::make('name.de')
|
Tables\Columns\TextColumn::make('name')
|
||||||
->label(__('admin.events.fields.name'))
|
->label(__('admin.events.fields.name'))
|
||||||
|
->formatStateUsing(fn (mixed $state): string => static::formatEventName($state))
|
||||||
->limit(30),
|
->limit(30),
|
||||||
Tables\Columns\TextColumn::make('slug')->searchable(),
|
Tables\Columns\TextColumn::make('slug')->searchable(),
|
||||||
Tables\Columns\TextColumn::make('date')->date(),
|
Tables\Columns\TextColumn::make('date')->date(),
|
||||||
@@ -278,6 +279,30 @@ class EventResource extends Resource
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed>|string|null $name
|
||||||
|
*/
|
||||||
|
private static function formatEventName(mixed $name): string
|
||||||
|
{
|
||||||
|
if (is_array($name)) {
|
||||||
|
$candidates = [
|
||||||
|
$name['de'] ?? null,
|
||||||
|
$name['en'] ?? null,
|
||||||
|
reset($name) ?: null,
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($candidates as $candidate) {
|
||||||
|
if (is_string($candidate) && $candidate !== '') {
|
||||||
|
return $candidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return is_string($name) ? $name : '';
|
||||||
|
}
|
||||||
|
|
||||||
public static function getPages(): array
|
public static function getPages(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
|
|||||||
@@ -161,11 +161,13 @@ class EventController extends Controller
|
|||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$resolvedName = $this->resolveEventNameString($validated['name']);
|
||||||
$eventData = array_merge($validated, [
|
$eventData = array_merge($validated, [
|
||||||
'tenant_id' => $tenantId,
|
'tenant_id' => $tenantId,
|
||||||
'status' => $validated['status'] ?? 'draft',
|
'status' => $validated['status'] ?? 'draft',
|
||||||
'slug' => $this->generateUniqueSlug($validated['name'], $tenantId),
|
'slug' => $this->generateUniqueSlug($resolvedName, $tenantId),
|
||||||
]);
|
]);
|
||||||
|
$eventData['name'] = $this->normalizeEventName($validated['name']);
|
||||||
|
|
||||||
if (isset($eventData['event_date'])) {
|
if (isset($eventData['event_date'])) {
|
||||||
$eventData['date'] = $eventData['event_date'];
|
$eventData['date'] = $eventData['event_date'];
|
||||||
@@ -228,7 +230,7 @@ class EventController extends Controller
|
|||||||
]);
|
]);
|
||||||
|
|
||||||
if ($billingIsReseller && ! $isSuperAdmin) {
|
if ($billingIsReseller && ! $isSuperAdmin) {
|
||||||
$note = sprintf('Event #%d created (%s)', $event->id, $event->name);
|
$note = sprintf('Event #%d created (%s)', $event->id, $this->resolveEventNameString($event->name));
|
||||||
|
|
||||||
if (! $tenant->consumeEventAllowanceFor($eventServicePackage->slug, 1, 'event.create', $note)) {
|
if (! $tenant->consumeEventAllowanceFor($eventServicePackage->slug, 1, 'event.create', $note)) {
|
||||||
throw new HttpException(402, 'Insufficient package allowance.');
|
throw new HttpException(402, 'Insufficient package allowance.');
|
||||||
@@ -404,9 +406,13 @@ class EventController extends Controller
|
|||||||
unset($validated['event_date']);
|
unset($validated['event_date']);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($nameProvided && $validated['name'] !== $event->name) {
|
$currentName = $this->resolveEventNameString($event->name);
|
||||||
$validated['slug'] = $this->generateUniqueSlug($validated['name'], $tenantId, $event->id);
|
$nextName = $this->resolveEventNameString($validated['name']);
|
||||||
|
|
||||||
|
if ($nameProvided && $nextName !== $currentName) {
|
||||||
|
$validated['slug'] = $this->generateUniqueSlug($nextName, $tenantId, $event->id);
|
||||||
}
|
}
|
||||||
|
$validated['name'] = $this->normalizeEventName($validated['name']);
|
||||||
|
|
||||||
foreach (['password', 'password_confirmation', 'password_protected'] as $unused) {
|
foreach (['password', 'password_confirmation', 'password_protected'] as $unused) {
|
||||||
unset($validated[$unused]);
|
unset($validated[$unused]);
|
||||||
@@ -935,6 +941,45 @@ class EventController extends Controller
|
|||||||
return $slug;
|
return $slug;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed>|string|null $name
|
||||||
|
* @return array<string, mixed>
|
||||||
|
*/
|
||||||
|
private function normalizeEventName(mixed $name): array
|
||||||
|
{
|
||||||
|
if (is_array($name)) {
|
||||||
|
return $name;
|
||||||
|
}
|
||||||
|
|
||||||
|
$value = is_string($name) ? trim($name) : '';
|
||||||
|
|
||||||
|
return ['de' => $value];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param array<string, mixed>|string|null $name
|
||||||
|
*/
|
||||||
|
private function resolveEventNameString(mixed $name): string
|
||||||
|
{
|
||||||
|
if (is_array($name)) {
|
||||||
|
$candidates = [
|
||||||
|
$name['de'] ?? null,
|
||||||
|
$name['en'] ?? null,
|
||||||
|
reset($name) ?: null,
|
||||||
|
];
|
||||||
|
|
||||||
|
foreach ($candidates as $candidate) {
|
||||||
|
if (is_string($candidate) && $candidate !== '') {
|
||||||
|
return $candidate;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
return is_string($name) ? $name : '';
|
||||||
|
}
|
||||||
|
|
||||||
public function search(Request $request): AnonymousResourceCollection
|
public function search(Request $request): AnonymousResourceCollection
|
||||||
{
|
{
|
||||||
$tenantId = $request->attributes->get('tenant_id');
|
$tenantId = $request->attributes->get('tenant_id');
|
||||||
|
|||||||
@@ -445,7 +445,7 @@
|
|||||||
"editTitle": "Event bearbeiten",
|
"editTitle": "Event bearbeiten",
|
||||||
"createTitle": "Neues Event erstellen",
|
"createTitle": "Neues Event erstellen",
|
||||||
"name": "Eventname",
|
"name": "Eventname",
|
||||||
"date": "Datum & Uhrzeit",
|
"date": "Datum & Ort",
|
||||||
"description": "Optionale Details",
|
"description": "Optionale Details",
|
||||||
"descriptionPlaceholder": "Beschreibung",
|
"descriptionPlaceholder": "Beschreibung",
|
||||||
"location": "Ort",
|
"location": "Ort",
|
||||||
|
|||||||
@@ -441,7 +441,7 @@
|
|||||||
"editTitle": "Edit event",
|
"editTitle": "Edit event",
|
||||||
"createTitle": "Create new event",
|
"createTitle": "Create new event",
|
||||||
"name": "Event name",
|
"name": "Event name",
|
||||||
"date": "Date & time",
|
"date": "Date & location",
|
||||||
"description": "Optional details",
|
"description": "Optional details",
|
||||||
"descriptionPlaceholder": "Description",
|
"descriptionPlaceholder": "Description",
|
||||||
"location": "Location",
|
"location": "Location",
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ class EventControllerTest extends TenantTestCase
|
|||||||
|
|
||||||
$this->assertDatabaseHas('events', [
|
$this->assertDatabaseHas('events', [
|
||||||
'tenant_id' => $tenant->id,
|
'tenant_id' => $tenant->id,
|
||||||
'name' => json_encode('Test Event'),
|
'name' => json_encode(['de' => 'Test Event']),
|
||||||
'slug' => 'test-event',
|
'slug' => 'test-event',
|
||||||
'event_type_id' => $eventType->id,
|
'event_type_id' => $eventType->id,
|
||||||
]);
|
]);
|
||||||
@@ -293,6 +293,7 @@ class EventControllerTest extends TenantTestCase
|
|||||||
|
|
||||||
$event->refresh();
|
$event->refresh();
|
||||||
$settings = $event->settings;
|
$settings = $event->settings;
|
||||||
|
$this->assertSame(['de' => 'Live Show Event'], $event->name);
|
||||||
$this->assertSame('manual', data_get($settings, 'live_show.moderation_mode'));
|
$this->assertSame('manual', data_get($settings, 'live_show.moderation_mode'));
|
||||||
$this->assertSame(12, data_get($settings, 'live_show.retention_window_hours'));
|
$this->assertSame(12, data_get($settings, 'live_show.retention_window_hours'));
|
||||||
$this->assertSame('balanced', data_get($settings, 'live_show.playback_mode'));
|
$this->assertSame('balanced', data_get($settings, 'live_show.playback_mode'));
|
||||||
|
|||||||
Reference in New Issue
Block a user