Skip to content

Commit 8c8af30

Browse files
authored
Merge pull request #16354 from snipe/dont_checkin_for_pending_on_asset_update
Allow pending as an asset status type that does not automatically check the asset in
2 parents 2ff47ed + 1618c9a commit 8c8af30

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

app/Http/Controllers/Api/StatuslabelsController.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -290,18 +290,20 @@ public function assets(Request $request, $id) : array
290290

291291
/**
292292
* Returns a boolean response based on whether the status label
293-
* is one that is deployable.
293+
* is one that is deployable or pending.
294294
*
295295
* This is used by the hardware create/edit view to determine whether
296-
* we should provide a dropdown of users for them to check the asset out to.
296+
* we should provide a dropdown of users for them to check the asset out to,
297+
* and whether we show a warning that the asset will be checked in if it's already
298+
* assigned but the status is changed to one that isn't pending or deployable
297299
*
298300
* @author [A. Gianotto] [<[email protected]>]
299301
* @since [v4.0]
300302
*/
301303
public function checkIfDeployable($id) : string
302304
{
303305
$statuslabel = Statuslabel::findOrFail($id);
304-
if ($statuslabel->getStatuslabelType() == 'deployable') {
306+
if (($statuslabel->getStatuslabelType() == 'pending') || ($statuslabel->getStatuslabelType() == 'deployable')) {
305307
return '1';
306308
}
307309

app/Http/Controllers/Assets/AssetsController.php

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -340,15 +340,14 @@ public function update(ImageUploadRequest $request, Asset $asset) : RedirectResp
340340

341341
$status = Statuslabel::find($request->input('status_id'));
342342

343-
// This is a non-deployable status label - we should check the asset back in.
344-
if (($status && $status->getStatuslabelType() != 'deployable') && ($target = $asset->assignedTo)) {
345-
343+
// This is an archived or undeployable - we should check the asset back in.
344+
// Pending is allowed here
345+
if (($status) && (($status->getStatuslabelType() != 'pending') && ($status->getStatuslabelType() != 'deployable')) && ($target = $asset->assignedTo)) {
346346
$originalValues = $asset->getRawOriginal();
347347
$asset->assigned_to = null;
348348
$asset->assigned_type = null;
349349
$asset->accepted = null;
350-
351-
event(new CheckoutableCheckedIn($asset, $target, auth()->user(), 'Checkin on asset update', date('Y-m-d H:i:s'), $originalValues));
350+
event(new CheckoutableCheckedIn($asset, $target, auth()->user(), 'Checkin on asset update with '.$status->getStatuslabelType().' status', date('Y-m-d H:i:s'), $originalValues));
352351
}
353352

354353
if ($asset->assigned_to == '') {

resources/lang/en-US/admin/hardware/form.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656
'asset_location_update_actual' => 'Update only actual location',
5757
'asset_not_deployable' => 'That asset status is not deployable. This asset cannot be checked out.',
5858
'asset_not_deployable_checkin' => 'That asset status is not deployable. Using this status label will checkin the asset.',
59-
'asset_deployable' => 'That status is deployable. This asset can be checked out.',
59+
'asset_deployable' => 'This asset can be checked out.',
6060
'processing_spinner' => 'Processing... (This might take a bit of time on large files)',
6161
'optional_infos' => 'Optional Information',
6262
'order_details' => 'Order Related Information',

0 commit comments

Comments
 (0)