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,128 @@
|
||||
<?php
|
||||
|
||||
namespace App\Filament\Resources\Communication\Inquiries\Pages;
|
||||
|
||||
use App\Domain\Communication\Inquiry;
|
||||
use App\Domain\Communication\InquiryStatus;
|
||||
use App\Filament\Resources\Communication\Inquiries\InquiryResource;
|
||||
use App\Filament\Support\Bestand;
|
||||
use App\Filament\Support\ListsCatalog;
|
||||
use Filament\Resources\Pages\ListRecords;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
use Illuminate\Support\Str;
|
||||
use Livewire\Attributes\Url;
|
||||
|
||||
class ListInquiries extends ListRecords
|
||||
{
|
||||
use ListsCatalog {
|
||||
bestand as protected baseBestand;
|
||||
}
|
||||
|
||||
protected static string $resource = InquiryResource::class;
|
||||
|
||||
#[Url(as: 'anliegen', except: 'alle')]
|
||||
public string $anliegen = 'alle';
|
||||
|
||||
#[Url(as: 'sortierung', except: 'neu')]
|
||||
public string $sortierung = 'neu';
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Alle eingegangenen Anfragen aus allen Anfrage-Einstiegen. Der Status wird von Hand gesetzt; Notizen sind nur intern sichtbar.';
|
||||
}
|
||||
|
||||
protected function bestandFilterEigenschaften(): array
|
||||
{
|
||||
return ['suche', 'zustand', 'anliegen', 'sortierung'];
|
||||
}
|
||||
|
||||
public function resetFilters(): void
|
||||
{
|
||||
$this->suche = '';
|
||||
$this->zustand = 'alle';
|
||||
$this->anliegen = 'alle';
|
||||
$this->sortierung = 'neu';
|
||||
$this->bestandGrenze = Bestand::SCHRITT;
|
||||
}
|
||||
|
||||
public function bestand(): array
|
||||
{
|
||||
$b = $this->baseBestand();
|
||||
$issues = Inquiry::query()->whereNotNull('issue_key')->select('issue_key', 'issue_label')->distinct()->orderBy('issue_label')->pluck('issue_label', 'issue_key')->all();
|
||||
|
||||
$b['filter'][] = ['eigenschaft' => 'anliegen', 'label' => 'Anliegen', 'vorgabe' => 'alle', 'optionen' => ['alle' => 'Alle Anliegen'] + $issues];
|
||||
$b['sortierung'] = ['eigenschaft' => 'sortierung', 'label' => 'Sortierung', 'optionen' => ['neu' => 'Neueste zuerst', 'alt' => 'Älteste zuerst', 'name' => 'Name', 'status' => 'Status']];
|
||||
|
||||
return $b;
|
||||
}
|
||||
|
||||
protected function catalogRows(): array
|
||||
{
|
||||
$query = Inquiry::query()->with('entry');
|
||||
|
||||
if ($this->anliegen !== 'alle') {
|
||||
$query->where('issue_key', $this->anliegen);
|
||||
}
|
||||
|
||||
$inquiries = match ($this->sortierung) {
|
||||
'alt' => $query->orderBy('created_at')->orderBy('id')->get(),
|
||||
'name' => $query->get()->sortBy(fn (Inquiry $i): string => mb_strtolower($i->contactTitle()), SORT_NATURAL)->values(),
|
||||
'status' => $query->get()->sortBy(fn (Inquiry $i): string => array_search($i->status, InquiryStatus::cases(), true).'-'.(PHP_INT_MAX - $i->created_at->getTimestamp()))->values(),
|
||||
default => $query->orderByDesc('created_at')->orderByDesc('id')->get(),
|
||||
};
|
||||
|
||||
$rows = [];
|
||||
|
||||
foreach ($inquiries as $inquiry) {
|
||||
$url = InquiryResource::getUrl('view', ['record' => $inquiry]);
|
||||
$failed = $inquiry->notified_at === null && $inquiry->notification_error !== null;
|
||||
$rows[] = [
|
||||
'schluessel' => 'q'.$inquiry->id,
|
||||
'titel' => $inquiry->contactTitle().($inquiry->organisation ? ' · '.$inquiry->organisation : ''),
|
||||
'meta' => $inquiry->created_at->format('d.m.Y H:i').' · '.($inquiry->issueTitle() ?: 'Ohne Anliegen').' · '.($inquiry->entry->name ?? 'Einstieg gelöscht'),
|
||||
'text' => Str::limit((string) $inquiry->message, 180),
|
||||
'suchtext' => implode(' ', array_filter([$inquiry->contact_email, $inquiry->reference, $inquiry->contact_phone])),
|
||||
'symbol' => 'modul',
|
||||
'url' => $url,
|
||||
'chips' => array_values(array_filter([
|
||||
['label' => $inquiry->status->label(), 'ton' => match ($inquiry->status) {
|
||||
InquiryStatus::Neu => 'offen',
|
||||
InquiryStatus::RueckfrageOffen => 'achtung',
|
||||
InquiryStatus::Erledigt => 'gut',
|
||||
default => 'neutral',
|
||||
}],
|
||||
$failed ? ['label' => 'Benachrichtigung fehlgeschlagen', 'ton' => 'achtung'] : null,
|
||||
])),
|
||||
'zustand' => array_values(array_filter([$inquiry->status->value, $inquiry->status !== InquiryStatus::Erledigt ? 'offen' : null, $failed ? 'mailfehler' : null])),
|
||||
'aktionen' => [['label' => 'Öffnen', 'href' => $url]],
|
||||
];
|
||||
}
|
||||
|
||||
return $rows;
|
||||
}
|
||||
|
||||
protected function zustandOptionen(): array
|
||||
{
|
||||
return [
|
||||
'alle' => 'Jeder Status',
|
||||
'offen' => 'Nicht erledigt',
|
||||
...InquiryStatus::options(),
|
||||
'mailfehler' => 'Benachrichtigung fehlgeschlagen',
|
||||
];
|
||||
}
|
||||
|
||||
protected function suchPlatzhalter(): string
|
||||
{
|
||||
return 'Name, E-Mail, Organisation, Nachricht oder Kennzeichen';
|
||||
}
|
||||
|
||||
protected function einheit(): array
|
||||
{
|
||||
return ['Anfrage', 'Anfragen'];
|
||||
}
|
||||
|
||||
protected function leer(): array
|
||||
{
|
||||
return ['titel' => 'Noch keine Anfragen', 'text' => 'Sobald jemand über einen Anfrage-Einstieg eine Anfrage sendet, erscheint sie hier.'];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user