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,143 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Communication\Issues\Pages;
|
||||
|
||||
use App\Domain\Communication\InquiryIssue;
|
||||
use App\Domain\Communication\Keys;
|
||||
use App\Filament\Resources\Communication\Issues\InquiryIssueResource;
|
||||
use App\Filament\Support\ListsCatalog;
|
||||
use Filament\Actions\Action;
|
||||
use Filament\Forms\Components\Select;
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Notifications\Notification;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
class ListInquiryIssues extends ListRecords
|
||||
{
|
||||
use ListsCatalog;
|
||||
|
||||
protected static string $resource = InquiryIssueResource::class;
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Ein Anliegen beschreibt, weshalb Besucher Kontakt aufnehmen. Unteranliegen verfeinern es. Welche Anliegen ein Formular anbietet und welche Felder dazu erscheinen, legst du in den Anfragevorlagen und Anfrage-Einstiegen fest. Anliegen werden nie gelöscht, nur deaktiviert oder archiviert.';
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('create')
|
||||
->label('Anliegen anlegen')
|
||||
->modalHeading('Neues Anliegen')
|
||||
->modalDescription('Bezeichnung und Einordnung genügen. Die interne Kennung wird einmalig vergeben.')
|
||||
->modalSubmitActionLabel('Anliegen anlegen')
|
||||
->schema([
|
||||
Select::make('parent_id')->label('Einordnung')
|
||||
->options(fn (): array => InquiryIssue::query()->whereNull('parent_id')->orderBy('sort_order')->pluck('label', 'id')->all())
|
||||
->placeholder('Anliegen auf oberster Ebene')
|
||||
->helperText('Alternativ als Unteranliegen eines bestehenden Anliegens.'),
|
||||
TextInput::make('label')->label('Öffentliche Bezeichnung')->required()->maxLength(120),
|
||||
Textarea::make('description')->label('Beschreibung (optional)')->rows(2)->maxLength(300),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$issue = InquiryIssue::query()->create([
|
||||
'parent_id' => $data['parent_id'] ?? null,
|
||||
'key' => Keys::from($data['label'], InquiryIssue::query()->pluck('key')->all()),
|
||||
'label' => $data['label'],
|
||||
'description' => $data['description'] ?? null,
|
||||
'sort_order' => ((int) InquiryIssue::query()->where('parent_id', $data['parent_id'] ?? null)->max('sort_order')) + 10,
|
||||
]);
|
||||
|
||||
Notification::make()->title('Das Anliegen ist angelegt.')->success()->send();
|
||||
$this->redirect(InquiryIssueResource::getUrl('edit', ['record' => $issue]));
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
/** Ein Anliegen vor oder hinter seinem Nachbarn derselben Ebene einordnen. */
|
||||
public function moveIssue(int $id, string $direction): void
|
||||
{
|
||||
$issue = InquiryIssue::query()->findOrFail($id);
|
||||
$siblings = InquiryIssue::query()->where('parent_id', $issue->parent_id)->orderBy('sort_order')->orderBy('id')->get()->values();
|
||||
$index = $siblings->search(fn (InquiryIssue $item): bool => $item->id === $issue->id);
|
||||
$target = $direction === 'up' ? $index - 1 : $index + 1;
|
||||
|
||||
if ($index === false || $target < 0 || $target >= $siblings->count()) {
|
||||
return;
|
||||
}
|
||||
|
||||
$order = $siblings->all();
|
||||
[$order[$index], $order[$target]] = [$order[$target], $order[$index]];
|
||||
|
||||
foreach ($order as $position => $item) {
|
||||
$item->forceFill(['sort_order' => ($position + 1) * 10])->save();
|
||||
}
|
||||
}
|
||||
|
||||
protected function catalogRows(): array
|
||||
{
|
||||
$all = InquiryIssue::query()->orderBy('sort_order')->orderBy('id')->get();
|
||||
$children = $all->whereNotNull('parent_id')->groupBy('parent_id');
|
||||
$rows = [];
|
||||
$tops = $all->whereNull('parent_id')->values();
|
||||
|
||||
$row = function (InquiryIssue $issue, ?InquiryIssue $parent, int $position, int $count) use (&$rows): void {
|
||||
$url = InquiryIssueResource::getUrl('edit', ['record' => $issue]);
|
||||
$state = $issue->archived_at !== null ? 'archiviert' : ($issue->active ? 'aktiv' : 'inaktiv');
|
||||
$rows[] = [
|
||||
'schluessel' => 'i'.$issue->id,
|
||||
'titel' => ($parent !== null ? '↳ ' : '').$issue->label,
|
||||
'meta' => $parent !== null ? 'Unteranliegen von „'.$parent->label.'“' : 'Anliegen',
|
||||
'text' => (string) ($issue->description ?? ''),
|
||||
'symbol' => 'modul',
|
||||
'url' => $url,
|
||||
'chips' => [
|
||||
match ($state) {
|
||||
'aktiv' => ['label' => 'Wird angeboten', 'ton' => 'gut'],
|
||||
'inaktiv' => ['label' => 'Deaktiviert', 'ton' => 'leise'],
|
||||
default => ['label' => 'Archiviert', 'ton' => 'leise'],
|
||||
},
|
||||
],
|
||||
'zustand' => [$state],
|
||||
'aktionen' => [
|
||||
['label' => 'Bearbeiten', 'href' => $url, 'icon' => 'stift'],
|
||||
...($position > 0 ? [['label' => 'Nach oben', 'wire' => "moveIssue({$issue->id}, 'up')"]] : []),
|
||||
...($position < $count - 1 ? [['label' => 'Nach unten', 'wire' => "moveIssue({$issue->id}, 'down')"]] : []),
|
||||
],
|
||||
];
|
||||
};
|
||||
|
||||
foreach ($tops as $i => $top) {
|
||||
$row($top, null, $i, $tops->count());
|
||||
$kids = ($children[$top->id] ?? collect())->values();
|
||||
|
||||
foreach ($kids as $j => $child) {
|
||||
$row($child, $top, $j, $kids->count());
|
||||
}
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
protected function zustandOptionen(): array
|
||||
{
|
||||
return ['alle' => 'Jeder Zustand', 'aktiv' => 'Wird angeboten', 'inaktiv' => 'Deaktiviert', 'archiviert' => 'Archiviert'];
|
||||
}
|
||||
|
||||
protected function suchPlatzhalter(): string
|
||||
{
|
||||
return 'Bezeichnung oder Beschreibung';
|
||||
}
|
||||
|
||||
protected function einheit(): array
|
||||
{
|
||||
return ['Anliegen', 'Anliegen'];
|
||||
}
|
||||
|
||||
protected function leer(): array
|
||||
{
|
||||
return ['titel' => 'Noch keine Anliegen', 'text' => 'Mit „Anliegen anlegen“ oben entsteht das erste Anliegen, zum Beispiel „Kurse & Workshops“. Auf der Seite „Einstellungen“ lässt sich eine Beispielkonfiguration anlegen.'];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user