From 033c3253bb51ff1490898eecfd85912cd00c2de0 Mon Sep 17 00:00:00 2001 From: snipe Date: Mon, 25 Oct 2021 14:10:17 -0700 Subject: [PATCH] Fixed permissions array to handle missing clone button Signed-off-by: snipe --- app/Http/Transformers/AssetsTransformer.php | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/app/Http/Transformers/AssetsTransformer.php b/app/Http/Transformers/AssetsTransformer.php index 72b7799bd7..fb87a09644 100644 --- a/app/Http/Transformers/AssetsTransformer.php +++ b/app/Http/Transformers/AssetsTransformer.php @@ -116,23 +116,12 @@ class AssetsTransformer $permissions_array['available_actions'] = [ 'checkout' => Gate::allows('checkout', Asset::class), 'checkin' => Gate::allows('checkin', Asset::class), - 'clone' => false, - 'restore' => false, + 'clone' => Gate::allows('create', Asset::class), + 'restore' => ($asset->deleted_at!='' && Gate::allows('create', Asset::class)) ? true : false, 'update' => (bool) Gate::allows('update', Asset::class), - 'delete' => ($asset->assigned_to=='' && Gate::allows('delete', Asset::class)), + 'delete' => ($asset->deleted_at=='' && $asset->assigned_to =='' && Gate::allows('delete', Asset::class)), ]; - if ($asset->deleted_at!='') { - $permissions_array['available_actions'] = [ - 'checkout' => true, - 'checkin' => false, - 'clone' => Gate::allows('create', Asset::class), - 'restore' => Gate::allows('create', Asset::class), - 'update' => false, - 'delete' => false, - ]; - } - if (request('components')=='true') {