Allow to disable actions on a per-row (per-record) basis

When adding actions to a dataGrid the `condition` key can be specified. It can hold a function which currently doesn't receive any parameters.

When we pass the record here we allow developers to decide whether or not to show a action on a per-row (per-record) basis, so showing an action for some items, hiding it for others.
This commit is contained in:
Rene Hrdina 2020-11-18 15:37:08 +01:00 committed by GitHub
parent dfccdc3463
commit 1c7ea33817
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -43,7 +43,7 @@
<div class="action">
@foreach ($actions as $action)
@php
$toDisplay = (isset($action['condition']) && gettype($action['condition']) == 'object') ? $action['condition']() : true;
$toDisplay = (isset($action['condition']) && gettype($action['condition']) == 'object') ? $action['condition']($record) : true;
@endphp
@if ($toDisplay)