Anliegen, Feldkatalog, Feldgruppen, Anfragevorlagen mit Fassungen, Anfrage-Einstiege, Posteingang mit Status und Notizen, Einstellungen mit Empfängern. Das Widget speichert nur die Kennung eines veröffentlichten Einstiegs; Formular, Bedingungen und Annahme kommen zur Laufzeit vom Server (Kompaktformular und mehrstufiger Dialog aus derselben Beschreibung). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
113 lines
4.9 KiB
PHP
113 lines
4.9 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Communication\Entries\Pages;
|
|
|
|
use App\Domain\Communication\InquiryEntry;
|
|
use App\Domain\Communication\InquiryTemplate;
|
|
use App\Domain\Communication\Keys;
|
|
use App\Filament\Resources\Communication\Entries\InquiryEntryResource;
|
|
use App\Filament\Support\ListsCatalog;
|
|
use Filament\Actions\Action;
|
|
use Filament\Forms\Components\Select;
|
|
use Filament\Forms\Components\TextInput;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Resources\Pages\ListRecords;
|
|
use Illuminate\Contracts\Support\Htmlable;
|
|
|
|
class ListInquiryEntries extends ListRecords
|
|
{
|
|
use ListsCatalog;
|
|
|
|
protected static string $resource = InquiryEntryResource::class;
|
|
|
|
public function getSubheading(): string|Htmlable|null
|
|
{
|
|
return 'Ein Anfrage-Einstieg ist die Nutzungsvariante einer Anfragevorlage: zugelassene Anliegen, Vorauswahl, Texte und Darstellung. Nur veröffentlichte Einstiege lassen sich im CMS mit dem Widget „Anfrage“ auf einer Seite einbinden. Mehrere Seiten können denselben Einstieg verwenden.';
|
|
}
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
Action::make('create')
|
|
->label('Einstieg anlegen')
|
|
->modalHeading('Neuer Anfrage-Einstieg')
|
|
->modalDescription('Zugelassene Anliegen, Vorauswahl und Texte legst du danach fest.')
|
|
->modalSubmitActionLabel('Einstieg anlegen')
|
|
->schema([
|
|
TextInput::make('name')->label('Bezeichnung')->required()->maxLength(120),
|
|
Select::make('template_id')->label('Anfragevorlage')->required()
|
|
->options(fn (): array => InquiryTemplate::query()->whereNull('archived_at')->orderBy('name')->pluck('name', 'id')->all()),
|
|
])
|
|
->action(function (array $data): void {
|
|
$entry = InquiryEntry::query()->create([
|
|
'key' => Keys::from($data['name'], InquiryEntry::query()->pluck('key')->all()),
|
|
'name' => $data['name'],
|
|
'template_id' => $data['template_id'],
|
|
'config' => InquiryEntry::emptyConfig(),
|
|
]);
|
|
|
|
Notification::make()->title('Der Einstieg ist angelegt.')->success()->send();
|
|
$this->redirect(InquiryEntryResource::getUrl('edit', ['record' => $entry]));
|
|
}),
|
|
];
|
|
}
|
|
|
|
protected function catalogRows(): array
|
|
{
|
|
$rows = [];
|
|
|
|
foreach (InquiryEntry::query()->with('template.publishedVersion')->orderBy('name')->get() as $entry) {
|
|
$url = InquiryEntryResource::getUrl('edit', ['record' => $entry]);
|
|
$archived = $entry->archived_at !== null;
|
|
$live = $entry->isLive();
|
|
$config = (array) ($entry->published_config ?? $entry->config);
|
|
$mode = ($config['mode'] ?? 'compact') === 'wizard' ? 'Mehrstufiger Dialog' : 'Kompaktformular';
|
|
|
|
$rows[] = [
|
|
'schluessel' => 'e'.$entry->id,
|
|
'titel' => $entry->name,
|
|
'meta' => 'Anfrage-Einstieg · '.$mode.' · Vorlage „'.$entry->template->name.'“',
|
|
'text' => '',
|
|
'symbol' => 'modul',
|
|
'url' => $url,
|
|
'chips' => array_values(array_filter([
|
|
$archived ? ['label' => 'Archiviert', 'ton' => 'leise'] : ($live
|
|
? ['label' => 'Veröffentlicht', 'ton' => 'gut']
|
|
: ($entry->published_at !== null ? ['label' => 'Veröffentlicht, aber Vorlage nicht gültig', 'ton' => 'achtung'] : ['label' => 'Entwurf', 'ton' => 'offen'])),
|
|
$entry->published_at !== null && $entry->hasUnpublishedChanges() ? ['label' => 'Änderungen noch nicht veröffentlicht', 'ton' => 'achtung'] : null,
|
|
])),
|
|
'zustand' => [$archived ? 'archiviert' : ($live ? 'veroeffentlicht' : 'entwurf'), ...($entry->published_at !== null && $entry->hasUnpublishedChanges() ? ['aenderungen'] : [])],
|
|
'aktionen' => [['label' => 'Bearbeiten', 'href' => $url, 'icon' => 'stift']],
|
|
];
|
|
}
|
|
|
|
return $rows;
|
|
}
|
|
|
|
protected function zustandOptionen(): array
|
|
{
|
|
return [
|
|
'alle' => 'Jeder Zustand',
|
|
'veroeffentlicht' => 'Veröffentlicht',
|
|
'entwurf' => 'Entwurf',
|
|
'aenderungen' => 'Mit unveröffentlichten Änderungen',
|
|
'archiviert' => 'Archiviert',
|
|
];
|
|
}
|
|
|
|
protected function suchPlatzhalter(): string
|
|
{
|
|
return 'Bezeichnung';
|
|
}
|
|
|
|
protected function einheit(): array
|
|
{
|
|
return ['Anfrage-Einstieg', 'Anfrage-Einstiege'];
|
|
}
|
|
|
|
protected function leer(): array
|
|
{
|
|
return ['titel' => 'Noch keine Anfrage-Einstiege', 'text' => 'Mit „Einstieg anlegen“ oben entsteht der erste Einstieg. Dazu braucht es eine veröffentlichte Anfragevorlage.'];
|
|
}
|
|
}
|