From 15369d7a86cb9771cffb97e4840a4ff8e35b80a5 Mon Sep 17 00:00:00 2001 From: devansh bawari Date: Thu, 11 Feb 2021 10:45:10 +0530 Subject: [PATCH] Datagrid Issue Fixed In Shops --- .../Shop/src/DataGrids/OrderDataGrid.php | 7 +++--- packages/Webkul/Ui/src/DataGrid/DataGrid.php | 22 +++++++++++++------ 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/packages/Webkul/Shop/src/DataGrids/OrderDataGrid.php b/packages/Webkul/Shop/src/DataGrids/OrderDataGrid.php index a3aca986c..9fe4beaaa 100644 --- a/packages/Webkul/Shop/src/DataGrids/OrderDataGrid.php +++ b/packages/Webkul/Shop/src/DataGrids/OrderDataGrid.php @@ -2,8 +2,8 @@ namespace Webkul\Shop\DataGrids; -use Illuminate\Support\Facades\DB; use Webkul\Ui\DataGrid\DataGrid; +use Illuminate\Support\Facades\DB; class OrderDataGrid extends DataGrid { @@ -80,12 +80,13 @@ class OrderDataGrid extends DataGrid ]); } - public function prepareActions() { + public function prepareActions() + { $this->addAction([ 'type' => 'View', 'method' => 'GET', 'route' => 'customer.orders.view', 'icon' => 'icon eye-icon', - ]); + ], true); } } \ No newline at end of file diff --git a/packages/Webkul/Ui/src/DataGrid/DataGrid.php b/packages/Webkul/Ui/src/DataGrid/DataGrid.php index 3432ac7e2..e6dd5fc7b 100644 --- a/packages/Webkul/Ui/src/DataGrid/DataGrid.php +++ b/packages/Webkul/Ui/src/DataGrid/DataGrid.php @@ -298,13 +298,17 @@ abstract class DataGrid } /** - * Add action. + * Add action. Some datagrids are used in shops also. So extra + * parameters is their. If needs to give an access just pass true + * in second param. * - * @param array $action + * @param array $action + * + * @param bool $specialPermission * * @return void */ - public function addAction($action) + public function addAction($action, $specialPermission = false) { $currentRouteACL = $this->fetchCurrentRouteACL($action); @@ -316,7 +320,7 @@ abstract class DataGrid $eventName = null; } - if (bouncer()->hasPermission($currentRouteACL['key'] ?? null)) { + if (bouncer()->hasPermission($currentRouteACL['key'] ?? null) || $specialPermission) { $this->fireEvent('action.before.' . $eventName); array_push($this->actions, $action); @@ -327,13 +331,17 @@ abstract class DataGrid } /** - * Add mass action. + * Add mass action. Some datagrids are used in shops also. So extra + * parameters is their. If needs to give an access just pass true + * in second param. * * @param array $massAction * + * @param bool $specialPermission + * * @return void */ - public function addMassAction($massAction) + public function addMassAction($massAction, $specialPermission = false) { $massAction['route'] = $this->getRouteNameFromUrl($massAction['action'], $massAction['method']); @@ -347,7 +355,7 @@ abstract class DataGrid $eventName = null; } - if (bouncer()->hasPermission($currentRouteACL['key'] ?? null)) { + if (bouncer()->hasPermission($currentRouteACL['key'] ?? null) || $specialPermission) { $this->fireEvent('mass.action.before.' . $eventName); $this->massActions[] = $massAction;