Zeige Kurse im Mitgliederbereich und mach hochgeladene Fassungen ansehbar.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
b374335b3a
commit
4f2e5a5f3b
24 files changed
+413
-47
No files matched your search
@@ -3,6 +3,7 @@
|
||||
namespace App\Filament\Resources\ContentElements\Pages;
|
||||
|
||||
use App\Domain\Catalog\ContentElement;
|
||||
use App\Domain\Catalog\ContentElementVersion;
|
||||
use App\Domain\Catalog\ContentService;
|
||||
use App\Filament\Resources\ContentElements\ContentElementResource;
|
||||
use App\Filament\Support\ReportsDomainRules;
|
||||
@@ -11,6 +12,7 @@
|
||||
use Filament\Forms\Components\Textarea;
|
||||
use Filament\Forms\Components\TextInput;
|
||||
use Filament\Resources\Pages\ViewRecord;
|
||||
use Illuminate\Contracts\Support\Htmlable;
|
||||
|
||||
class ViewContentElement extends ViewRecord
|
||||
{
|
||||
@@ -18,21 +20,58 @@ class ViewContentElement extends ViewRecord
|
||||
|
||||
protected static string $resource = ContentElementResource::class;
|
||||
|
||||
public function getSubheading(): string|Htmlable|null
|
||||
{
|
||||
return 'Text und Datei gehören zur Fassung. Eine Filmfassung kann eine Entscheidungsmarke in Sekunden tragen. Zum Kurs wird das Element in einer Komposition, zum Paket über den Lizenzartikel.';
|
||||
}
|
||||
|
||||
protected function getHeaderActions(): array
|
||||
{
|
||||
return [
|
||||
Action::make('preview')
|
||||
->label('Ansehen')
|
||||
->url(function (): ?string {
|
||||
$version = $this->latestVersion();
|
||||
|
||||
return $version === null ? null : route('content.preview', $version);
|
||||
})
|
||||
->visible(fn (): bool => $this->latestVersion() !== null)
|
||||
->openUrlInNewTab(),
|
||||
Action::make('version')
|
||||
->label('Fassung veröffentlichen')
|
||||
->schema([
|
||||
Textarea::make('body')->label('Text'),
|
||||
FileUpload::make('incoming')->label('Datei')->disk('cms_incoming')->directory('inhalte'),
|
||||
FileUpload::make('incoming')
|
||||
->label('Datei')
|
||||
->disk('cms_incoming')
|
||||
->directory('inhalte')
|
||||
->helperText('Film, Audio oder PDF. Die Datei wird übernommen und ist danach unter Ansehen sichtbar.'),
|
||||
TextInput::make('decision_seconds')
|
||||
->label('Entscheidungsmarke in Sekunden')
|
||||
->numeric()
|
||||
->minValue(0)
|
||||
->helperText('Nur für Filme: der Kursplayer pausiert an dieser Stelle.'),
|
||||
TextInput::make('change_note')->label('Änderungsnotiz'),
|
||||
])
|
||||
->action(function (array $data): void {
|
||||
$this->report(function () use ($data): void {
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
$metadata = filled($data['incoming'] ?? null) ? ['incoming' => $data['incoming']] : [];
|
||||
$metadata = [];
|
||||
$incoming = $data['incoming'] ?? null;
|
||||
|
||||
if (is_array($incoming)) {
|
||||
$incoming = array_values(array_filter($incoming, 'is_string'))[0] ?? null;
|
||||
}
|
||||
|
||||
if (is_string($incoming) && $incoming !== '') {
|
||||
$metadata['incoming'] = $incoming;
|
||||
}
|
||||
|
||||
if (is_numeric($data['decision_seconds'] ?? null)) {
|
||||
$metadata['decision_seconds'] = (int) $data['decision_seconds'];
|
||||
}
|
||||
|
||||
app(ContentService::class)->publishElementVersion(
|
||||
$element,
|
||||
$data['body'] ?? null,
|
||||
@@ -45,4 +84,12 @@ protected function getHeaderActions(): array
|
||||
}),
|
||||
];
|
||||
}
|
||||
|
||||
private function latestVersion(): ?ContentElementVersion
|
||||
{
|
||||
/** @var ContentElement $element */
|
||||
$element = $this->getRecord();
|
||||
|
||||
return $element->versions()->orderByDesc('number')->first();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user