Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes bulk checking out of undeployable asset #16492

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions app/Http/Controllers/Assets/BulkAssetsController.php
Original file line number Diff line number Diff line change
@@ -53,6 +53,16 @@ public function edit(Request $request) : View | RedirectResponse

$asset_ids = $request->input('ids');
if ($request->input('bulk_actions') === 'checkout') {
$undeployable_assets = Asset::whereIn('id', $asset_ids)
->whereHas('assetStatus', function ($query){
$query->where('deployable', 0)
->where('archived', 0)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we wouldn't want to allow an archived asset to be checked out?

I think there's a small conflict in a few of the ways we handle this, which we should probably address, since the behavior is different in a few spots. In the API Statuslabel checkIfDeployable() method, we allow pending or deployable. (That is only used by the create/edit asset form when determining if we should present a checkout, via #16354)

In the query scopes on the Asset, scopeRTD(), scopeUndeployable(), we include/exclude pending. We should probably make those consistent across the board, but we'd need to see what else it might break before doing that.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, the double negatives are killing me here lol

Copy link
Owner

@snipe snipe Mar 12, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think deployable = 0, archived = 1 is all we need here?

I dunno, now I'm confused :-/

->where('pending', 0);
})
->get();
if($undeployable_assets->count() > 0) {
return redirect()->back()->with('error', trans_choice('admin/hardware/form.bulk_asset_undeployable', $undeployable_assets->count()));
}
$request->session()->flashInput(['selected_assets' => $asset_ids]);
return redirect()->route('hardware.bulkcheckout.show');
}
1 change: 1 addition & 0 deletions resources/lang/en-US/admin/hardware/form.php
Original file line number Diff line number Diff line change
@@ -56,6 +56,7 @@
'asset_location_update_actual' => 'Update only actual location',
'asset_not_deployable' => 'That asset status is not deployable. This asset cannot be checked out.',
'asset_not_deployable_checkin' => 'That asset status is not deployable. Using this status label will checkin the asset.',
'bulk_asset_undeployable' => 'Asset in this bulk checkout request is undeployable.|[2,*]Assets in this bulk checkout request are undeployable.',
'asset_deployable' => 'This asset can be checked out.',
'processing_spinner' => 'Processing... (This might take a bit of time on large files)',
'optional_infos' => 'Optional Information',