mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 13:44:06 -08:00
Handle asset maintenances that do not have a valid asset associated
This commit is contained in:
parent
74c099f0b3
commit
1eace04ad9
|
@ -162,6 +162,10 @@ class AssetMaintenancesController extends Controller
|
||||||
// Redirect to the improvement management page
|
// Redirect to the improvement management page
|
||||||
return redirect()->route('maintenances.index')
|
return redirect()->route('maintenances.index')
|
||||||
->with('error', trans('admin/asset_maintenances/message.not_found'));
|
->with('error', trans('admin/asset_maintenances/message.not_found'));
|
||||||
|
} elseif (!$assetMaintenance->asset) {
|
||||||
|
return redirect()->route('maintenances.index')
|
||||||
|
->with('error', 'The asset associated with this maintenance does not exist.');
|
||||||
|
|
||||||
} elseif (!Company::isCurrentUserHasAccess($assetMaintenance->asset)) {
|
} elseif (!Company::isCurrentUserHasAccess($assetMaintenance->asset)) {
|
||||||
return static::getInsufficientPermissionsRedirect();
|
return static::getInsufficientPermissionsRedirect();
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,10 +28,15 @@ class AssetMaintenancesTransformer
|
||||||
'asset_tag'=> e($assetmaintenance->asset->asset_tag)
|
'asset_tag'=> e($assetmaintenance->asset->asset_tag)
|
||||||
|
|
||||||
] : null,
|
] : null,
|
||||||
'model' => ($assetmaintenance->asset->model) ? [
|
'model' => (($assetmaintenance->asset) && ($assetmaintenance->asset->model)) ? [
|
||||||
'id' => (int) $assetmaintenance->asset->model->id,
|
'id' => (int) $assetmaintenance->asset->model->id,
|
||||||
'name'=> ($assetmaintenance->asset->model->name) ? e($assetmaintenance->asset->model->name).' '.e($assetmaintenance->asset->model->model_number) : null
|
'name'=> ($assetmaintenance->asset->model->name) ? e($assetmaintenance->asset->model->name).' '.e($assetmaintenance->asset->model->model_number) : null
|
||||||
] : null,
|
] : null,
|
||||||
|
'company' => (($assetmaintenance->asset) && ($assetmaintenance->asset->company)) ? [
|
||||||
|
'id' => (int) $assetmaintenance->asset->company->id,
|
||||||
|
'name'=> ($assetmaintenance->asset->company->name) ? e($assetmaintenance->asset->company->name) : null,
|
||||||
|
|
||||||
|
] : null,
|
||||||
'title' => ($assetmaintenance->title) ? e($assetmaintenance->title) : null,
|
'title' => ($assetmaintenance->title) ? e($assetmaintenance->title) : null,
|
||||||
'location' => (($assetmaintenance->asset) && ($assetmaintenance->asset->location)) ? [
|
'location' => (($assetmaintenance->asset) && ($assetmaintenance->asset->location)) ? [
|
||||||
'id' => (int) $assetmaintenance->asset->location->id,
|
'id' => (int) $assetmaintenance->asset->location->id,
|
||||||
|
|
|
@ -423,8 +423,11 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
function assetTagLinkFormatter(value, row) {
|
function assetTagLinkFormatter(value, row) {
|
||||||
|
if ((row.asset) && (row.asset.id)) {
|
||||||
return '<a href="{{ url('/') }}/hardware/' + row.asset.id + '"> ' + row.asset.asset_tag + '</a>';
|
return '<a href="{{ url('/') }}/hardware/' + row.asset.id + '"> ' + row.asset.asset_tag + '</a>';
|
||||||
}
|
}
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
function assetNameLinkFormatter(value, row) {
|
function assetNameLinkFormatter(value, row) {
|
||||||
if ((row.asset) && (row.asset.name)) {
|
if ((row.asset) && (row.asset.name)) {
|
||||||
|
|
Loading…
Reference in a new issue