Zeige Medienfassungen in der Verwaltung und halte Beschreibungen davon getrennt.
Eine Fassung bleibt nummeriert und kann deaktiviert werden. Beschreibung und fachliche Säulen gehören zum Medium und legen keine neue Fassung an. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
12f12117dd
commit
af85a94cd5
28 files changed
+1002
-168
No files matched your search
@@ -6,6 +6,7 @@
|
||||
use App\Domain\Identity\StaffRole;
|
||||
use App\Filament\Resources\ContentElements\Pages\EditContentElement;
|
||||
use App\Filament\Resources\ContentElements\Pages\ListContentElements;
|
||||
use App\Filament\Resources\ContentElements\Pages\ViewContentElement;
|
||||
use App\Models\User;
|
||||
use Filament\Facades\Filament;
|
||||
use Filament\Resources\Resource;
|
||||
@@ -34,7 +35,11 @@ class ContentElementResource extends Resource
|
||||
|
||||
public static function canViewAny(): bool
|
||||
{
|
||||
return self::editor();
|
||||
$user = Filament::auth()->user();
|
||||
|
||||
return $user instanceof User && (
|
||||
$user->hasStaffRole(StaffRole::Redakteur) || $user->hasStaffRole(StaffRole::Katalogverwalter)
|
||||
);
|
||||
}
|
||||
|
||||
public static function editor(): bool
|
||||
@@ -44,6 +49,11 @@ public static function editor(): bool
|
||||
return $user instanceof User && $user->hasStaffRole(StaffRole::Redakteur);
|
||||
}
|
||||
|
||||
public static function getViewAuthorizationResponse(Model $record): Response
|
||||
{
|
||||
return self::canViewAny() ? Response::allow() : Response::deny();
|
||||
}
|
||||
|
||||
public static function getEditAuthorizationResponse(Model $record): Response
|
||||
{
|
||||
return self::editor() ? Response::allow() : Response::deny();
|
||||
@@ -56,9 +66,14 @@ public static function form(Schema $schema): Schema
|
||||
|
||||
public static function table(Table $table): Table
|
||||
{
|
||||
return $table->columns([
|
||||
return $table->recordUrl(
|
||||
fn (ContentElement $record): string => static::getUrl('view', ['record' => $record])
|
||||
)->columns([
|
||||
TextColumn::make('working_title')->label('Arbeitstitel')->searchable(),
|
||||
TextColumn::make('kind')->label('Art'),
|
||||
TextColumn::make('pillar_names')->label('Säulen')->state(
|
||||
fn (ContentElement $record): string => $record->pillars->pluck('name')->join(', ') ?: '—'
|
||||
),
|
||||
TextColumn::make('stand')->label('Aktuelle Fassung')->state(function (ContentElement $record): string {
|
||||
$version = $record->versions->sortByDesc('number')->first();
|
||||
|
||||
@@ -75,14 +90,15 @@ public static function table(Table $table): Table
|
||||
|
||||
public static function getEloquentQuery(): Builder
|
||||
{
|
||||
return parent::getEloquentQuery()->with('versions');
|
||||
return parent::getEloquentQuery()->with(['versions', 'pillars']);
|
||||
}
|
||||
|
||||
public static function getPages(): array
|
||||
{
|
||||
return [
|
||||
'index' => ListContentElements::route('/'),
|
||||
'edit' => EditContentElement::route('/{record}'),
|
||||
'view' => ViewContentElement::route('/{record}'),
|
||||
'edit' => EditContentElement::route('/{record}/bearbeiten'),
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user