Baue die Verwaltung Kommunikation, die öffentliche Anfrageschnittstelle und das CMS-Widget Anfrage
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>
This commit is contained in:
1 parent
2ee1fc9866
commit
c6a8167601
45 files changed
+5415
No files matched your search
@@ -0,0 +1,114 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Communication\Templates\Pages;
|
||||
|
||||
use App\Domain\Communication\InquiryTemplate;
|
||||
use App\Domain\Communication\Keys;
|
||||
use App\Filament\Resources\Communication\Templates\InquiryTemplateResource;
|
||||
use App\Filament\Support\ListsCatalog;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
class ListInquiryTemplates extends ListRecords
|
||||
{
|
||||
use ListsCatalog;
|
||||
|
||||
protected static string $resource = InquiryTemplateResource::class;
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Eine Anfragevorlage beschreibt einen vollständigen Anfrageprozess: Schritte, Feldgruppen, Bedingungen und Texte. Änderungen entstehen zunächst als Entwurf und gelten erst nach „Veröffentlichen“. Die Anfrage-Einstiege, die eine Vorlage verwenden, übernehmen jede neu veröffentlichte Fassung.';
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('create')
|
||||
->label('Vorlage anlegen')
|
||||
->modalHeading('Neue Anfragevorlage')
|
||||
->modalDescription('Der Aufbau entsteht danach auf der Seite der Vorlage.')
|
||||
->modalSubmitActionLabel('Vorlage anlegen')
|
||||
->schema([
|
||||
TextInput::make('name')->label('Bezeichnung')->required()->maxLength(120),
|
||||
Textarea::make('description')->label('Beschreibung (nur Verwaltung, optional)')->rows(2)->maxLength(400),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$draft = InquiryTemplate::emptyDraft();
|
||||
$draft['steps'] = [['key' => 's'.Str::lower(Str::random(6)), 'title' => 'Ihre Angaben', 'intro' => null, 'items' => []]];
|
||||
|
||||
$template = InquiryTemplate::query()->create([
|
||||
'key' => Keys::from($data['name'], InquiryTemplate::query()->pluck('key')->all()),
|
||||
'name' => $data['name'],
|
||||
'description' => $data['description'] ?? null,
|
||||
'draft' => $draft,
|
||||
]);
|
||||
|
||||
Notification::make()->title('Die Vorlage ist angelegt.')->success()->send();
|
||||
$this->redirect(InquiryTemplateResource::getUrl('edit', ['record' => $template]));
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
protected function catalogRows(): array
|
||||
{
|
||||
$rows = [];
|
||||
|
||||
foreach (InquiryTemplate::query()->with('publishedVersion')->withCount('entries')->orderBy('name')->get() as $template) {
|
||||
$url = InquiryTemplateResource::getUrl('edit', ['record' => $template]);
|
||||
$archived = $template->archived_at !== null;
|
||||
$published = $template->isPublished();
|
||||
$changes = $published && $template->hasUnpublishedChanges();
|
||||
$steps = count((array) ($template->draft['steps'] ?? []));
|
||||
|
||||
$rows[] = [
|
||||
'schluessel' => 't'.$template->id,
|
||||
'titel' => $template->name,
|
||||
'meta' => 'Anfragevorlage · '.$steps.' '.($steps === 1 ? 'Schritt' : 'Schritte').' · '.$template->entries_count.' '.($template->entries_count === 1 ? 'Einstieg' : 'Einstiege'),
|
||||
'text' => (string) ($template->description ?? ''),
|
||||
'symbol' => 'modul',
|
||||
'url' => $url,
|
||||
'chips' => array_values(array_filter([
|
||||
$archived ? ['label' => 'Archiviert', 'ton' => 'leise'] : ($published
|
||||
? ['label' => 'Fassung '.$template->publishedVersion->version.' gültig', 'ton' => 'gut']
|
||||
: ['label' => 'Noch nicht veröffentlicht', 'ton' => 'offen']),
|
||||
$changes ? ['label' => 'Änderungen noch nicht veröffentlicht', 'ton' => 'achtung'] : null,
|
||||
])),
|
||||
'zustand' => [$archived ? 'archiviert' : ($published ? 'veroeffentlicht' : 'entwurf'), ...($changes ? ['aenderungen'] : [])],
|
||||
'aktionen' => [['label' => 'Bearbeiten', 'href' => $url, 'icon' => 'stift']],
|
||||
];
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
protected function zustandOptionen(): array
|
||||
{
|
||||
return [
|
||||
'alle' => 'Jeder Zustand',
|
||||
'veroeffentlicht' => 'Veröffentlicht',
|
||||
'entwurf' => 'Noch nicht veröffentlicht',
|
||||
'aenderungen' => 'Mit unveröffentlichten Änderungen',
|
||||
'archiviert' => 'Archiviert',
|
||||
];
|
||||
}
|
||||
|
||||
protected function suchPlatzhalter(): string
|
||||
{
|
||||
return 'Bezeichnung oder Beschreibung';
|
||||
}
|
||||
|
||||
protected function einheit(): array
|
||||
{
|
||||
return ['Anfragevorlage', 'Anfragevorlagen'];
|
||||
}
|
||||
|
||||
protected function leer(): array
|
||||
{
|
||||
return ['titel' => 'Noch keine Anfragevorlagen', 'text' => 'Mit „Vorlage anlegen“ oben entsteht die erste Vorlage. Auf der Seite „Einstellungen“ lässt sich eine Beispielkonfiguration anlegen.'];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user