From cf0548bd1f81f7666a1f26732120f3b943c98dad Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 6 May 2022 05:11:52 -0700 Subject: [PATCH 01/18] Create a new partial for asset bulk actions Signed-off-by: snipe --- .../partials/asset-bulk-actions.blade.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 resources/views/partials/asset-bulk-actions.blade.php diff --git a/resources/views/partials/asset-bulk-actions.blade.php b/resources/views/partials/asset-bulk-actions.blade.php new file mode 100644 index 0000000000..4a24a34ced --- /dev/null +++ b/resources/views/partials/asset-bulk-actions.blade.php @@ -0,0 +1,22 @@ +
+ {{ Form::open([ + 'method' => 'POST', + 'route' => ['hardware/bulkedit'], + 'class' => 'form-inline', + 'id' => 'bulkForm']) }} + + + + + + + {{ Form::close() }} +
\ No newline at end of file From 243739e9c335ad26af365f7de91e15e7938130bb Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 6 May 2022 05:13:36 -0700 Subject: [PATCH 02/18] Added missing gate for bulk checkout Signed-off-by: snipe --- app/Http/Controllers/Assets/BulkAssetsController.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php index 0e519251ad..16679fc818 100644 --- a/app/Http/Controllers/Assets/BulkAssetsController.php +++ b/app/Http/Controllers/Assets/BulkAssetsController.php @@ -224,6 +224,9 @@ class BulkAssetsController extends Controller */ public function storeCheckout(Request $request) { + + $this->authorize('checkout', Asset::class); + try { $admin = Auth::user(); From 76213ec3d96a6c9628636583c7627bb73290ce12 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 6 May 2022 05:14:08 -0700 Subject: [PATCH 03/18] Create a session on bulk actions, store it for redirect, then delete it Signed-off-by: snipe --- .../Assets/BulkAssetsController.php | 27 ++++++++++++++----- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php index 16679fc818..d1dce2b69d 100644 --- a/app/Http/Controllers/Assets/BulkAssetsController.php +++ b/app/Http/Controllers/Assets/BulkAssetsController.php @@ -11,6 +11,7 @@ use App\Models\Setting; use Illuminate\Http\Request; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\DB; +use Illuminate\Support\Facades\Session; class BulkAssetsController extends Controller { @@ -32,6 +33,12 @@ class BulkAssetsController extends Controller if (! $request->filled('ids')) { return redirect()->back()->with('error', 'No assets selected'); } + + $bulk_back_url = request()->headers->get('referer'); + session(['bulk_back_url' => $bulk_back_url]); + + \Log::debug('Back to url: '.$bulk_back_url); + $asset_ids = array_values(array_unique($request->input('ids'))); @@ -73,10 +80,11 @@ class BulkAssetsController extends Controller { $this->authorize('update', Asset::class); - \Log::debug($request->input('ids')); + // Get the back url from the session and then destroy the session + $bulk_back_url = $request->session()->pull('bulk_back_url'); if (! $request->filled('ids') || count($request->input('ids')) <= 0) { - return redirect()->route('hardware.index')->with('warning', trans('No assets selected, so nothing was updated.')); + return redirect($back_to_url)->with('warning', trans('No assets selected, so nothing was updated.')); } $assets = array_keys($request->input('ids')); @@ -147,11 +155,13 @@ class BulkAssetsController extends Controller ->update($this->update_array); } // endforeach - return redirect()->route('hardware.index')->with('success', trans('admin/hardware/message.update.success')); - // no values given, nothing to update + return redirect($bulk_back_url)->with('success', trans('admin/hardware/message.update.success')); + + } - return redirect()->route('hardware.index')->with('warning', trans('admin/hardware/message.update.nothing_updated')); + // no values given, nothing to update + return redirect($bulk_back_url)->with('warning', trans('admin/hardware/message.update.nothing_updated')); } /** @@ -188,6 +198,9 @@ class BulkAssetsController extends Controller { $this->authorize('delete', Asset::class); + // Get the back url from the session and then destroy the session + $bulk_back_url = $request->session()->pull('bulk_back_url'); + if ($request->filled('ids')) { $assets = Asset::find($request->get('ids')); foreach ($assets as $asset) { @@ -199,11 +212,11 @@ class BulkAssetsController extends Controller ->update($update_array); } // endforeach - return redirect()->to('hardware')->with('success', trans('admin/hardware/message.delete.success')); + return redirect($bulk_back_url)->with('success', trans('admin/hardware/message.delete.success')); // no values given, nothing to update } - return redirect()->to('hardware')->with('info', trans('admin/hardware/message.delete.nothing_updated')); + return redirect($bulk_back_url)->with('info', trans('admin/hardware/message.delete.nothing_updated')); } /** From c64f34ebcc4dd3f3f3ecf0d4d9e052b865afb23b Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 6 May 2022 05:14:31 -0700 Subject: [PATCH 04/18] =?UTF-8?q?Check=20the=20"do=20not=20change=E2=80=9D?= =?UTF-8?q?=20radio=20button=20by=20default?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: snipe --- resources/views/hardware/bulk.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/hardware/bulk.blade.php b/resources/views/hardware/bulk.blade.php index b073a3b74c..b508db0b80 100755 --- a/resources/views/hardware/bulk.blade.php +++ b/resources/views/hardware/bulk.blade.php @@ -143,7 +143,7 @@ {{ trans('general.no')}} From c4bf0045c8ce4be6b301dc99175d5d21eb94444e Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 6 May 2022 05:14:55 -0700 Subject: [PATCH 05/18] Fixed stray < tag Signed-off-by: snipe --- resources/views/users/view.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/users/view.blade.php b/resources/views/users/view.blade.php index 3091858ba3..fb3245bf13 100755 --- a/resources/views/users/view.blade.php +++ b/resources/views/users/view.blade.php @@ -345,7 +345,7 @@
- {{ trans('admin/users/table.employee_num') }}< + {{ trans('admin/users/table.employee_num') }}
{{ $user->employee_num }} From 78a9c167619d656d2fa0769e271c980ac613fffa Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 6 May 2022 05:15:10 -0700 Subject: [PATCH 06/18] Minor formatting improvements Signed-off-by: snipe --- resources/views/users/view.blade.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/resources/views/users/view.blade.php b/resources/views/users/view.blade.php index fb3245bf13..5d8e97f6ac 100755 --- a/resources/views/users/view.blade.php +++ b/resources/views/users/view.blade.php @@ -61,7 +61,8 @@
  • + + @@ -71,7 +72,8 @@
  • + + @@ -81,7 +83,8 @@
  • + +
  • From fe98e505febad101976f228b764e7ac4f69e52df Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 6 May 2022 05:15:31 -0700 Subject: [PATCH 07/18] Use the new partial for bulk asset edit Signed-off-by: snipe --- resources/views/users/view.blade.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/resources/views/users/view.blade.php b/resources/views/users/view.blade.php index 5d8e97f6ac..1509b2c8e1 100755 --- a/resources/views/users/view.blade.php +++ b/resources/views/users/view.blade.php @@ -566,10 +566,13 @@
    -
    -
    + + @include('partials.asset-bulk-actions') + +
    + Date: Fri, 6 May 2022 05:15:58 -0700 Subject: [PATCH 08/18] Remove conflicting toolbar call in model listing Signed-off-by: snipe --- resources/views/users/view.blade.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/resources/views/users/view.blade.php b/resources/views/users/view.blade.php index 1509b2c8e1..14fbd966df 100755 --- a/resources/views/users/view.blade.php +++ b/resources/views/users/view.blade.php @@ -799,6 +799,7 @@
    +
    Date: Fri, 6 May 2022 05:16:13 -0700 Subject: [PATCH 09/18] Added checkbox to audit listing Signed-off-by: snipe --- app/Presenters/AssetAuditPresenter.php | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/app/Presenters/AssetAuditPresenter.php b/app/Presenters/AssetAuditPresenter.php index 96cf89b841..4129ea9fd3 100644 --- a/app/Presenters/AssetAuditPresenter.php +++ b/app/Presenters/AssetAuditPresenter.php @@ -17,6 +17,10 @@ class AssetAuditPresenter extends Presenter public static function dataTableLayout() { $layout = [ + [ + 'field' => 'checkbox', + 'checkbox' => true, + ], [ 'field' => 'id', 'searchable' => false, From 418a797e7ef0be8e7fafc1663defab5cd9456409 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 6 May 2022 05:20:29 -0700 Subject: [PATCH 10/18] Use partial for asset bulk edit Signed-off-by: snipe --- resources/views/categories/view.blade.php | 3 +++ resources/views/hardware/audit-due.blade.php | 8 +++---- resources/views/hardware/index.blade.php | 25 ++++---------------- resources/views/locations/view.blade.php | 5 ++++ resources/views/manufacturers/view.blade.php | 3 +++ 5 files changed, 18 insertions(+), 26 deletions(-) diff --git a/resources/views/categories/view.blade.php b/resources/views/categories/view.blade.php index 304ccbe92b..2cf0960c9b 100644 --- a/resources/views/categories/view.blade.php +++ b/resources/views/categories/view.blade.php @@ -28,6 +28,9 @@
    + @if ($category->category_type=='asset') + @include('partials.asset-bulk-actions') + @endif
    - {{ Form::open([ - 'method' => 'POST', - 'route' => ['hardware/bulkedit'], - 'class' => 'form-inline', - 'id' => 'bulkForm']) }} + + @include('partials.asset-bulk-actions') +
    diff --git a/resources/views/hardware/index.blade.php b/resources/views/hardware/index.blade.php index d4bd6fc88a..094c9fc1be 100755 --- a/resources/views/hardware/index.blade.php +++ b/resources/views/hardware/index.blade.php @@ -62,27 +62,10 @@
    @if (Request::get('status')!='Deleted') - - - -
    - {{ Form::open([ - 'method' => 'POST', - 'route' => ['hardware/bulkedit'], - 'class' => 'form-inline', - 'id' => 'bulkForm']) }} - - - - - - - {{ Form::close() }} -
    + + + + @include('partials.asset-bulk-actions') @endif diff --git a/resources/views/locations/view.blade.php b/resources/views/locations/view.blade.php index 90b100ee41..87eaf7c1ae 100644 --- a/resources/views/locations/view.blade.php +++ b/resources/views/locations/view.blade.php @@ -23,6 +23,7 @@
    +
    + + + @include('partials.asset-bulk-actions') +
    + @include('partials.asset-bulk-actions') +
    +
    From 59a0f4722b6116b524d709a6849997feebd1b435 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 6 May 2022 05:20:35 -0700 Subject: [PATCH 11/18] Use partial for asset bulk edit Signed-off-by: snipe --- resources/views/models/view.blade.php | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/resources/views/models/view.blade.php b/resources/views/models/view.blade.php index 2f5c37044a..8d78f3506f 100755 --- a/resources/views/models/view.blade.php +++ b/resources/views/models/view.blade.php @@ -42,21 +42,11 @@
    @endif
    -
    -
    - {{ Form::open([ - 'method' => 'POST', - 'route' => ['hardware/bulkedit'], - 'class' => 'form-inline', - 'id' => 'bulkForm']) }} -
    - - -
    + + @include('partials.asset-bulk-actions') + + + Date: Fri, 6 May 2022 05:20:44 -0700 Subject: [PATCH 12/18] Fixed extra divs Signed-off-by: snipe --- resources/views/models/view.blade.php | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/resources/views/models/view.blade.php b/resources/views/models/view.blade.php index 8d78f3506f..96fef52f58 100755 --- a/resources/views/models/view.blade.php +++ b/resources/views/models/view.blade.php @@ -69,8 +69,7 @@ }'>
    {{ Form::close() }} -
    -
    +
    From e1b24bb763666cf0e604b9caa221e9e85ed3f4b1 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 6 May 2022 05:30:21 -0700 Subject: [PATCH 13/18] Added a comment Signed-off-by: snipe --- app/Http/Controllers/Assets/BulkAssetsController.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php index d1dce2b69d..7f3a0f5e3b 100644 --- a/app/Http/Controllers/Assets/BulkAssetsController.php +++ b/app/Http/Controllers/Assets/BulkAssetsController.php @@ -33,7 +33,8 @@ class BulkAssetsController extends Controller if (! $request->filled('ids')) { return redirect()->back()->with('error', 'No assets selected'); } - + + // Figure out where we need to send the user after the update is complete, and store that in the session $bulk_back_url = request()->headers->get('referer'); session(['bulk_back_url' => $bulk_back_url]); From caf17d4f251e9fa2e5d96921bf929f9fa3b8daa2 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 6 May 2022 05:41:32 -0700 Subject: [PATCH 14/18] Fixed wrong variable name Signed-off-by: snipe --- app/Http/Controllers/Assets/BulkAssetsController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php index 7f3a0f5e3b..c0d47743c8 100644 --- a/app/Http/Controllers/Assets/BulkAssetsController.php +++ b/app/Http/Controllers/Assets/BulkAssetsController.php @@ -85,7 +85,7 @@ class BulkAssetsController extends Controller $bulk_back_url = $request->session()->pull('bulk_back_url'); if (! $request->filled('ids') || count($request->input('ids')) <= 0) { - return redirect($back_to_url)->with('warning', trans('No assets selected, so nothing was updated.')); + return redirect($bulk_back_url)->with('error', trans('admin/hardware/message.update.no_assets_selected')); } $assets = array_keys($request->input('ids')); From 22ec3c13986232abc19a6d258c62090ed1d88c29 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 6 May 2022 05:41:52 -0700 Subject: [PATCH 15/18] Use error style instead of warn/info when nothing was selected Signed-off-by: snipe --- app/Http/Controllers/Assets/BulkAssetsController.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php index c0d47743c8..0f13b1e68f 100644 --- a/app/Http/Controllers/Assets/BulkAssetsController.php +++ b/app/Http/Controllers/Assets/BulkAssetsController.php @@ -31,7 +31,8 @@ class BulkAssetsController extends Controller $this->authorize('update', Asset::class); if (! $request->filled('ids')) { - return redirect()->back()->with('error', 'No assets selected'); + return redirect()->back()->with('error', trans('admin/hardware/message.update.no_assets_selected')); + } // Figure out where we need to send the user after the update is complete, and store that in the session @@ -217,7 +218,7 @@ class BulkAssetsController extends Controller // no values given, nothing to update } - return redirect($bulk_back_url)->with('info', trans('admin/hardware/message.delete.nothing_updated')); + return redirect($bulk_back_url)->with('error', trans('admin/hardware/message.delete.nothing_updated')); } /** From 2982d78899c61bd6b690414ecbdbecfc53ebf0e2 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 6 May 2022 05:42:02 -0700 Subject: [PATCH 16/18] Added translation for no assets selected Signed-off-by: snipe --- resources/lang/am/admin/hardware/message.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/resources/lang/am/admin/hardware/message.php b/resources/lang/am/admin/hardware/message.php index 8c8e323a73..1d8fb1874b 100644 --- a/resources/lang/am/admin/hardware/message.php +++ b/resources/lang/am/admin/hardware/message.php @@ -14,9 +14,10 @@ return [ ], 'update' => [ - 'error' => 'Asset was not updated, please try again', - 'success' => 'Asset updated successfully.', - 'nothing_updated' => 'No fields were selected, so nothing was updated.', + 'error' => 'Asset was not updated, please try again', + 'success' => 'Asset updated successfully.', + 'nothing_updated' => 'No fields were selected, so nothing was updated.', + 'no_assets_selected' => 'No assets were selected, so nothing was updated.', ], 'restore' => [ From d5edb0908b4af12c1570780b40bf25cf32209e44 Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 6 May 2022 14:07:05 -0700 Subject: [PATCH 17/18] Added translation string to the correct file this time Signed-off-by: snipe --- resources/lang/en/admin/hardware/message.php | 1 + 1 file changed, 1 insertion(+) diff --git a/resources/lang/en/admin/hardware/message.php b/resources/lang/en/admin/hardware/message.php index 8c8e323a73..d2214ce00c 100644 --- a/resources/lang/en/admin/hardware/message.php +++ b/resources/lang/en/admin/hardware/message.php @@ -17,6 +17,7 @@ return [ 'error' => 'Asset was not updated, please try again', 'success' => 'Asset updated successfully.', 'nothing_updated' => 'No fields were selected, so nothing was updated.', + 'no_assets_selected' => 'No assets were selected, so nothing was updated.', ], 'restore' => [ From 220f94faeebe371051cb9fe5055d56377199e87a Mon Sep 17 00:00:00 2001 From: snipe Date: Fri, 6 May 2022 14:10:47 -0700 Subject: [PATCH 18/18] Check that the session key exists Signed-off-by: snipe --- app/Http/Controllers/Assets/BulkAssetsController.php | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/Assets/BulkAssetsController.php b/app/Http/Controllers/Assets/BulkAssetsController.php index 0f13b1e68f..4aede02a81 100644 --- a/app/Http/Controllers/Assets/BulkAssetsController.php +++ b/app/Http/Controllers/Assets/BulkAssetsController.php @@ -83,7 +83,11 @@ class BulkAssetsController extends Controller $this->authorize('update', Asset::class); // Get the back url from the session and then destroy the session - $bulk_back_url = $request->session()->pull('bulk_back_url'); + $bulk_back_url = route('hardware'); + if ($request->session()->has('bulk_back_url')) { + $bulk_back_url = $request->session()->pull('bulk_back_url'); + } + if (! $request->filled('ids') || count($request->input('ids')) <= 0) { return redirect($bulk_back_url)->with('error', trans('admin/hardware/message.update.no_assets_selected')); @@ -200,8 +204,10 @@ class BulkAssetsController extends Controller { $this->authorize('delete', Asset::class); - // Get the back url from the session and then destroy the session - $bulk_back_url = $request->session()->pull('bulk_back_url'); + $bulk_back_url = route('hardware'); + if ($request->session()->has('bulk_back_url')) { + $bulk_back_url = $request->session()->pull('bulk_back_url'); + } if ($request->filled('ids')) { $assets = Asset::find($request->get('ids'));