Der Kalenderabgleich alle 5 Minuten hat jede fortbestehende Ueberschneidung erneut gemailt. ReportChannelConflicts legt jede Ueberschneidung einmal im neuen Postfach (InboxMessage, Fingerabdruck je Mandant) ab und mailt nur neue. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
83 lines
3.8 KiB
PHP
83 lines
3.8 KiB
PHP
<?php
|
||
|
||
namespace App\Filament\Resources\InboxMessages\Tables;
|
||
|
||
use App\Enums\InboxMessageKind;
|
||
use App\Models\InboxMessage;
|
||
use Filament\Actions\Action;
|
||
use Filament\Actions\BulkAction;
|
||
use Filament\Actions\BulkActionGroup;
|
||
use Filament\Actions\DeleteBulkAction;
|
||
use Filament\Support\Enums\FontWeight;
|
||
use Filament\Support\Icons\Heroicon;
|
||
use Filament\Tables\Columns\IconColumn;
|
||
use Filament\Tables\Columns\TextColumn;
|
||
use Filament\Tables\Filters\SelectFilter;
|
||
use Filament\Tables\Filters\TernaryFilter;
|
||
use Filament\Tables\Table;
|
||
use Illuminate\Database\Eloquent\Collection;
|
||
|
||
class InboxMessagesTable
|
||
{
|
||
public static function configure(Table $table): Table
|
||
{
|
||
return $table
|
||
->defaultSort('created_at', 'desc')
|
||
->description('Hinweise, um die Sie sich kümmern sollten. Jede Meldung kommt nur einmal – auch wenn sie bei jedem Kalenderabgleich wieder auffällt.')
|
||
->emptyStateHeading('Keine Meldungen')
|
||
->columns([
|
||
IconColumn::make('read_at')
|
||
->label('')
|
||
->state(fn (InboxMessage $record): bool => ! $record->isRead())
|
||
->boolean()
|
||
->trueIcon(Heroicon::Envelope)
|
||
->falseIcon(Heroicon::OutlinedEnvelopeOpen)
|
||
->trueColor('danger')
|
||
->falseColor('gray')
|
||
->tooltip(fn (InboxMessage $record): string => $record->isRead() ? 'Gelesen' : 'Ungelesen'),
|
||
TextColumn::make('created_at')->label('Eingang')->dateTime('d.m. H:i')->sortable(),
|
||
TextColumn::make('kind')->label('Art')->badge(),
|
||
TextColumn::make('subject')
|
||
->label('Meldung')
|
||
->weight(fn (InboxMessage $record): ?FontWeight => $record->isRead() ? null : FontWeight::Bold)
|
||
->description(fn (InboxMessage $record): string => $record->body)
|
||
->wrap(),
|
||
])
|
||
->filters([
|
||
TernaryFilter::make('read_at')
|
||
->label('Gelesen')
|
||
->nullable()
|
||
->trueLabel('Nur gelesene')
|
||
->falseLabel('Nur ungelesene'),
|
||
SelectFilter::make('kind')->label('Art')->options(InboxMessageKind::class),
|
||
])
|
||
->recordUrl(null)
|
||
->recordActions([
|
||
Action::make('open')
|
||
->label('Ansehen')
|
||
->icon(Heroicon::OutlinedArrowTopRightOnSquare)
|
||
->visible(fn (InboxMessage $record): bool => filled($record->action_url))
|
||
->action(function (InboxMessage $record) {
|
||
$record->update(['read_at' => $record->read_at ?? now()]);
|
||
|
||
return redirect($record->action_url);
|
||
}),
|
||
Action::make('toggleRead')
|
||
->label(fn (InboxMessage $record): string => $record->isRead() ? 'Als ungelesen markieren' : 'Als gelesen markieren')
|
||
->icon(fn (InboxMessage $record): Heroicon => $record->isRead() ? Heroicon::OutlinedEnvelope : Heroicon::OutlinedCheck)
|
||
->color('gray')
|
||
->action(fn (InboxMessage $record) => $record->update(['read_at' => $record->isRead() ? null : now()])),
|
||
])
|
||
->toolbarActions([
|
||
BulkActionGroup::make([
|
||
BulkAction::make('markRead')
|
||
->label('Als gelesen markieren')
|
||
->icon(Heroicon::OutlinedCheck)
|
||
->action(fn (Collection $records) => InboxMessage::query()->whereKey($records->modelKeys())->update(['read_at' => now()]))
|
||
->deselectRecordsAfterCompletion(),
|
||
DeleteBulkAction::make(),
|
||
]),
|
||
]);
|
||
}
|
||
}
|