Merge pull request #1579 from prashant-webkul/development
Datagrid actions enhancement
This commit is contained in:
commit
db7013be3f
|
|
@ -130,6 +130,9 @@ class ProductDataGrid extends DataGrid
|
|||
public function prepareActions() {
|
||||
$this->addAction([
|
||||
'title' => 'Edit Product',
|
||||
'condition' => function() {
|
||||
return true;
|
||||
},
|
||||
'method' => 'GET', // use GET request only for redirect purposes
|
||||
'route' => 'admin.catalog.products.edit',
|
||||
'icon' => 'icon pencil-lg-icon'
|
||||
|
|
@ -149,7 +152,7 @@ class ProductDataGrid extends DataGrid
|
|||
public function prepareMassActions() {
|
||||
$this->addMassAction([
|
||||
'type' => 'delete',
|
||||
'label' => 'Delete',
|
||||
'label' => 'Delete',
|
||||
'action' => route('admin.catalog.products.massdelete'),
|
||||
'method' => 'DELETE'
|
||||
]);
|
||||
|
|
|
|||
|
|
@ -42,24 +42,30 @@
|
|||
<td class="actions" style="width: 100px;" data-value="{{ __('ui::app.datagrid.actions') }}">
|
||||
<div class="action">
|
||||
@foreach ($actions as $action)
|
||||
<a
|
||||
@if ($action['method'] == 'GET')
|
||||
href="{{ route($action['route'], $record->{$action['index'] ?? $index}) }}"
|
||||
@php
|
||||
$toDisplay = (isset($action['condition']) && gettype($action['condition']) == 'object') ? $action['condition']() : true;
|
||||
@endphp
|
||||
|
||||
@if ($toDisplay)
|
||||
<a
|
||||
@if ($action['method'] == 'GET')
|
||||
href="{{ route($action['route'], $record->{$action['index'] ?? $index}) }}"
|
||||
@endif
|
||||
|
||||
@if ($action['method'] != 'GET')
|
||||
v-on:click="doAction($event)"
|
||||
@endif
|
||||
|
||||
data-method="{{ $action['method'] }}"
|
||||
data-action="{{ route($action['route'], $record->{$index}) }}"
|
||||
data-token="{{ csrf_token() }}"
|
||||
|
||||
@if (isset($action['title']))
|
||||
title="{{ $action['title'] }}"
|
||||
@endif>
|
||||
<span class="{{ $action['icon'] }}"></span>
|
||||
</a>
|
||||
@endif
|
||||
|
||||
@if ($action['method'] != 'GET')
|
||||
v-on:click="doAction($event)"
|
||||
@endif
|
||||
|
||||
data-method="{{ $action['method'] }}"
|
||||
data-action="{{ route($action['route'], $record->{$index}) }}"
|
||||
data-token="{{ csrf_token() }}"
|
||||
|
||||
@if (isset($action['title']))
|
||||
title="{{ $action['title'] }}"
|
||||
@endif>
|
||||
<span class="{{ $action['icon'] }}"></span>
|
||||
</a>
|
||||
@endforeach
|
||||
</div>
|
||||
</td>
|
||||
|
|
|
|||
Loading…
Reference in New Issue