mirror of
https://github.com/snipe/snipe-it.git
synced 2024-12-25 21:54:14 -08:00
Allow cloning of deleted assets
Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
parent
b64b774bd5
commit
293abbd1d0
|
@ -576,26 +576,20 @@ class AssetsController extends Controller
|
||||||
* @since [v1.0]
|
* @since [v1.0]
|
||||||
* @return \Illuminate\Contracts\View\View
|
* @return \Illuminate\Contracts\View\View
|
||||||
*/
|
*/
|
||||||
public function getClone($assetId = null)
|
public function getClone(Asset $asset)
|
||||||
{
|
{
|
||||||
// Check if the asset exists
|
$this->authorize('create', $asset);
|
||||||
if (is_null($asset_to_clone = Asset::find($assetId))) {
|
$cloned = clone $asset;
|
||||||
// Redirect to the asset management page
|
$cloned->id = null;
|
||||||
return redirect()->route('hardware.index')->with('error', trans('admin/hardware/message.does_not_exist'));
|
$cloned->asset_tag = '';
|
||||||
}
|
$cloned->serial = '';
|
||||||
|
$cloned->assigned_to = '';
|
||||||
$this->authorize('create', $asset_to_clone);
|
$cloned->deleted_at = '';
|
||||||
|
|
||||||
$asset = clone $asset_to_clone;
|
|
||||||
$asset->id = null;
|
|
||||||
$asset->asset_tag = '';
|
|
||||||
$asset->serial = '';
|
|
||||||
$asset->assigned_to = '';
|
|
||||||
|
|
||||||
return view('hardware/edit')
|
return view('hardware/edit')
|
||||||
->with('statuslabel_list', Helper::statusLabelList())
|
->with('statuslabel_list', Helper::statusLabelList())
|
||||||
->with('statuslabel_types', Helper::statusTypeList())
|
->with('statuslabel_types', Helper::statusTypeList())
|
||||||
->with('item', $asset);
|
->with('item', $cloned);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -197,23 +197,13 @@
|
||||||
@endif
|
@endif
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
|
|
||||||
@can('update', $asset)
|
|
||||||
@if ($asset->deleted_at=='')
|
@if ($asset->deleted_at=='')
|
||||||
|
@can('update', $asset)
|
||||||
<div class="col-md-12" style="padding-top: 5px;">
|
<div class="col-md-12" style="padding-top: 5px;">
|
||||||
<a href="{{ route('hardware.edit', $asset->id) }}" class="btn btn-sm btn-primary btn-block hidden-print">
|
<a href="{{ route('hardware.edit', $asset->id) }}" class="btn btn-sm btn-primary btn-block hidden-print">
|
||||||
{{ trans('admin/hardware/general.edit') }}
|
{{ trans('admin/hardware/general.edit') }}
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
|
||||||
@endcan
|
|
||||||
|
|
||||||
@can('create', $asset)
|
|
||||||
<div class="col-md-12" style="padding-top: 5px;">
|
|
||||||
<a href="{{ route('clone/hardware', $asset->id) }}" class="btn btn-sm btn-primary btn-block hidden-print">
|
|
||||||
{{ trans('admin/hardware/general.clone') }}
|
|
||||||
</a>
|
|
||||||
</div>
|
|
||||||
@endcan
|
@endcan
|
||||||
|
|
||||||
@can('audit', \App\Models\Asset::class)
|
@can('audit', \App\Models\Asset::class)
|
||||||
|
@ -225,6 +215,15 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
@endcan
|
@endcan
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@can('create', $asset)
|
||||||
|
<div class="col-md-12" style="padding-top: 5px;">
|
||||||
|
<a href="{{ route('clone/hardware', $asset->id) }}" class="btn btn-sm btn-primary btn-block hidden-print">
|
||||||
|
{{ trans('admin/hardware/general.clone') }}
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
@endcan
|
||||||
|
|
||||||
@can('delete', $asset)
|
@can('delete', $asset)
|
||||||
<div class="col-md-12" style="padding-top: 30px; padding-bottom: 30px;">
|
<div class="col-md-12" style="padding-top: 30px; padding-bottom: 30px;">
|
||||||
|
|
Loading…
Reference in a new issue