Merge branch 'feature/customise-record-actions' into develop

This commit is contained in:
Dan Harrin
2021-03-11 22:05:14 +00:00
+19 -9
View File
@@ -161,22 +161,32 @@ class RelationManager extends Component
$this->selected = [];
}
public function getPrimaryRecordAction($record)
{
if (! Filament::can('update', $record)) return;
return 'openEdit';
}
public function getRecordActions()
{
return [
RecordActions\Link::make('edit')
->label(static::$editRecordActionLabel)
->action('openEdit')
->when(fn ($record) => Filament::can('update', $record)),
];
}
public function getTable()
{
return static::table(Table::make())
->filterable($this->filterable)
->pagination(false)
->primaryRecordAction(function ($record) {
if (! Filament::can('update', $record)) return;
return 'openEdit';
return $this->getPrimaryRecordAction($record);
})
->recordActions([
RecordActions\Link::make('edit')
->label(static::$editRecordActionLabel)
->action('openEdit')
->when(fn ($record) => Filament::can('update', $record)),
])
->recordActions($this->getRecordActions())
->searchable($this->searchable)
->sortable($this->sortable);
}