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,117 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Communication\Fields\Pages;
|
||||
|
||||
use App\Domain\Communication\FieldType;
|
||||
use App\Domain\Communication\InquiryField;
|
||||
use App\Domain\Communication\InquiryFieldGroup;
|
||||
use App\Domain\Communication\Keys;
|
||||
use App\Filament\Resources\Communication\Fields\InquiryFieldResource;
|
||||
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 ListInquiryFields extends ListRecords
|
||||
{
|
||||
use ListsCatalog;
|
||||
|
||||
protected static string $resource = InquiryFieldResource::class;
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Der Feldkatalog enthält alle Eingabefelder, die Anfragevorlagen verwenden können. Ein Feld wie „Postleitzahl“ oder „Telefonnummer“ wird einmal angelegt und überall wiederverwendet. Felder werden nie gelöscht, nur deaktiviert oder archiviert.';
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('create')
|
||||
->label('Feld anlegen')
|
||||
->modalHeading('Neues Feld')
|
||||
->modalDescription('Weitere Angaben wie Hilfetext, Grenzen oder die Verwendung in der Anfrageübersicht legst du danach fest.')
|
||||
->modalSubmitActionLabel('Feld anlegen')
|
||||
->schema([
|
||||
TextInput::make('name')->label('Fachliche Bezeichnung')->required()->maxLength(120),
|
||||
TextInput::make('label')->label('Öffentliche Beschriftung')->required()->maxLength(200),
|
||||
Select::make('type')->label('Feldtyp')->options(FieldType::options())->required()->live(),
|
||||
...InquiryFieldResource::optionsFields(),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$field = InquiryField::query()->create([
|
||||
'key' => Keys::from($data['name'], InquiryField::query()->pluck('key')->all()),
|
||||
'name' => $data['name'],
|
||||
'label' => $data['label'],
|
||||
'type' => $data['type'],
|
||||
'options' => FieldType::from($data['type'])->hasOptions() ? Keys::withKeys((array) ($data['options'] ?? [])) : null,
|
||||
]);
|
||||
|
||||
Notification::make()->title('Das Feld ist angelegt.')->success()->send();
|
||||
$this->redirect(InquiryFieldResource::getUrl('edit', ['record' => $field]));
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
protected function catalogRows(): array
|
||||
{
|
||||
$usage = [];
|
||||
foreach (InquiryFieldGroup::query()->get() as $group) {
|
||||
foreach ($group->itemList() as $item) {
|
||||
$usage[$item['field']] = ($usage[$item['field']] ?? 0) + 1;
|
||||
}
|
||||
}
|
||||
|
||||
$rows = [];
|
||||
|
||||
foreach (InquiryField::query()->orderBy('name')->get() as $field) {
|
||||
$url = InquiryFieldResource::getUrl('edit', ['record' => $field]);
|
||||
$state = $field->archived_at !== null ? 'archiviert' : ($field->active ? 'aktiv' : 'inaktiv');
|
||||
$used = $usage[$field->key] ?? 0;
|
||||
$rows[] = [
|
||||
'schluessel' => 'f'.$field->id,
|
||||
'titel' => $field->name,
|
||||
'meta' => $field->type->label().' · '.$field->key,
|
||||
'text' => $field->label,
|
||||
'suchtext' => $field->key.' '.$field->label,
|
||||
'symbol' => 'modul',
|
||||
'url' => $url,
|
||||
'chips' => array_values(array_filter([
|
||||
match ($state) {
|
||||
'aktiv' => ['label' => 'Wird angeboten', 'ton' => 'gut'],
|
||||
'inaktiv' => ['label' => 'Deaktiviert', 'ton' => 'leise'],
|
||||
default => ['label' => 'Archiviert', 'ton' => 'leise'],
|
||||
},
|
||||
['label' => $used === 0 ? 'In keiner Feldgruppe' : ($used === 1 ? 'In 1 Feldgruppe' : "In $used Feldgruppen"), 'ton' => 'neutral'],
|
||||
$field->purpose !== null ? ['label' => $field->purpose->label(), 'ton' => 'neutral'] : null,
|
||||
])),
|
||||
'zustand' => [$state, 'typ_'.$field->type->value],
|
||||
'aktionen' => [['label' => 'Bearbeiten', 'href' => $url, 'icon' => 'stift']],
|
||||
];
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
protected function zustandOptionen(): array
|
||||
{
|
||||
return ['alle' => 'Jeder Zustand', 'aktiv' => 'Wird angeboten', 'inaktiv' => 'Deaktiviert', 'archiviert' => 'Archiviert'];
|
||||
}
|
||||
|
||||
protected function suchPlatzhalter(): string
|
||||
{
|
||||
return 'Bezeichnung, Beschriftung oder Kennung';
|
||||
}
|
||||
|
||||
protected function einheit(): array
|
||||
{
|
||||
return ['Feld', 'Felder'];
|
||||
}
|
||||
|
||||
protected function leer(): array
|
||||
{
|
||||
return ['titel' => 'Noch keine Felder', 'text' => 'Mit „Feld anlegen“ oben entsteht das erste Feld, zum Beispiel „E-Mail-Adresse“.'];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user