Flache Prozessfelder im Kanalformular entfallen als Hauptansicht. Volle Suite 820/820. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
55 lines
2.1 KiB
PHP
55 lines
2.1 KiB
PHP
<?php
|
|
|
|
namespace App\Filament\Resources\Channels\Pages;
|
|
|
|
use App\Actions\AnalyzeChannelCalendar;
|
|
use App\Actions\ConfigureChannel;
|
|
use App\Channels\ChannelSyncException;
|
|
use App\Filament\Resources\Channels\ChannelResource;
|
|
use App\Models\Channel;
|
|
use Filament\Actions\Action;
|
|
use Filament\Notifications\Notification;
|
|
use Filament\Resources\Pages\EditRecord;
|
|
use Illuminate\Database\Eloquent\Model;
|
|
|
|
class EditChannel extends EditRecord
|
|
{
|
|
protected static string $resource = ChannelResource::class;
|
|
|
|
protected function getHeaderActions(): array
|
|
{
|
|
return [
|
|
Action::make('process')->label('Ablauf')->url(fn (): string => ChannelResource::getUrl('process', ['record' => $this->record])),
|
|
Action::make('rules')->label('Regeln & Exportfelder')->url(fn (): string => ChannelResource::getUrl('rules', ['record' => $this->record]))->visible(fn (): bool => $this->record->isPortal()),
|
|
Action::make('analyze')->label('Kalender analysieren')->visible(fn (): bool => $this->record->isPortal())->action(function (AnalyzeChannelCalendar $analyze): void {
|
|
try {
|
|
$analyze->handle($this->record);
|
|
$this->redirect(ChannelResource::getUrl('rules', ['record' => $this->record]));
|
|
} catch (ChannelSyncException $exception) {
|
|
Notification::make()->title('Analyse nicht möglich')->body($exception->getMessage())->danger()->send();
|
|
}
|
|
}),
|
|
];
|
|
}
|
|
|
|
protected function mutateFormDataBeforeFill(array $data): array
|
|
{
|
|
return [...$data, 'settings' => $this->record->settings];
|
|
}
|
|
|
|
protected function handleRecordUpdate(Model $record, array $data): Model
|
|
{
|
|
// The own website's entry has no connection to configure; its process is set up under "Ablauf" (ChannelProcess).
|
|
if ($record instanceof Channel && $record->isWebsite()) {
|
|
return $record;
|
|
}
|
|
|
|
return app(ConfigureChannel::class)->handle($record->property, $data, $record);
|
|
}
|
|
|
|
protected function getRedirectUrl(): string
|
|
{
|
|
return ChannelResource::getUrl('index');
|
|
}
|
|
}
|