Merge pull request #12940 from akemidx/delete_asset_from_view_page

Delete button on asset view page
This commit is contained in:
snipe 2023-07-25 12:11:35 +01:00 committed by GitHub
commit a01cb26aac
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 76 additions and 67 deletions

View file

@ -774,7 +774,7 @@ class AssetsController extends Controller
}
/**
* Retore a deleted asset.
* Restore a deleted asset.
*
* @author [A. Gianotto] [<snipe@snipe.net>]
* @param int $assetId

View file

@ -12,6 +12,7 @@ return [
'clone' => 'Clone Asset',
'deployable' => 'Deployable',
'deleted' => 'This asset has been deleted.',
'delete_confirm' => 'Are you sure you want to delete this asset?',
'edit' => 'Edit Asset',
'model_deleted' => 'This Assets model has been deleted. You must restore the model before you can restore the Asset.',
'model_invalid' => 'The Model of this Asset is invalid.',

View file

@ -264,7 +264,7 @@ return [
'accept_eula' => 'Acceptance Agreement',
'supplier' => 'Supplier',
'suppliers' => 'Suppliers',
'sure_to_delete' => 'Are you sure you wish to delete',
'sure_to_delete' => 'Are you sure you wish to delete',
'submit' => 'Submit',
'target' => 'Target',
'time_and_date_display' => 'Time and Date Display',

View file

@ -6,67 +6,6 @@
@parent
@stop
{{-- Right header --}}
@section('header_right')
@can('manage', \App\Models\Asset::class)
@if ($asset->deleted_at=='')
<div class="dropdown pull-right">
<button class="btn btn-default dropdown-toggle" data-toggle="dropdown">{{ trans('button.actions') }}
<span class="caret"></span>
</button>
<ul class="dropdown-menu pull-right" role="menu">
@if (($asset->assetstatus) && ($asset->assetstatus->deployable=='1'))
@if (($asset->assigned_to != '') && ($asset->deleted_at==''))
@can('checkin', \App\Models\Asset::class)
<li role="menuitem">
<a href="{{ route('hardware.checkin.create', $asset->id) }}">
{{ trans('admin/hardware/general.checkin') }}
</a>
</li>
@endcan
@elseif (($asset->assigned_to == '') && ($asset->deleted_at==''))
@can('checkout', \App\Models\Asset::class)
<li role="menuitem">
<a href="{{ route('hardware.checkout.create', $asset->id) }}">
{{ trans('admin/hardware/general.checkout') }}
</a>
</li>
@endcan
@endif
@endif
@can('update', \App\Models\Asset::class)
<li role="menuitem">
<a href="{{ route('hardware.edit', $asset->id) }}">
{{ trans('admin/hardware/general.edit') }}
</a>
</li>
@endcan
@can('create', \App\Models\Asset::class)
<li role="menuitem">
<a href="{{ route('clone/hardware', $asset->id) }}">
{{ trans('admin/hardware/general.clone') }}
</a>
</li>
@endcan
@can('audit', \App\Models\Asset::class)
<li role="menuitem">
<a href="{{ route('asset.audit.create', $asset->id) }}">
{{ trans('general.audit') }}
</a>
</li>
@endcan
</ul>
</div>
@endif
@endcan
@stop
{{-- Page content --}}
@section('content')
@ -884,17 +823,73 @@
<div class="col-md-4">
@if (($asset->image) || (($asset->model) && ($asset->model->image!='')))
<div class="text-center col-md-12" style="padding-bottom: 15px;">
<a href="{{ ($asset->getImageUrl()) ? $asset->getImageUrl() : null }}" data-toggle="lightbox">
<img src="{{ ($asset->getImageUrl()) ? $asset->getImageUrl() : null }}" class="assetimg img-responsive" alt="{{ $asset->getDisplayNameAttribute() }}">
</a>
</div>
@else
<!-- generic image goes here -->
@endif
<!-- Start side button column -->
@if (($asset->assetstatus) && ($asset->assetstatus->deployable=='1'))
@if (($asset->assigned_to != '') && ($asset->deleted_at==''))
@can('checkin', \App\Models\Asset::class)
<div class="col-md-12">
<a href="{{ route('hardware.checkin.create', $asset->id) }}" style="width: 100%;" class="btn btn-sm btn-primary hidden-print">
{{ trans('admin/hardware/general.checkin') }}
</a>
</div>
@endcan
@elseif (($asset->assigned_to == '') && ($asset->deleted_at==''))
@can('checkout', \App\Models\Asset::class)
<div class="col-md-12" style="padding-top: 5px;">
<a href="{{ route('hardware.checkout.create', $asset->id) }}" style="width: 100%;" class="btn btn-sm btn-primary hidden-print">
{{ trans('admin/hardware/general.checkout') }}
</a>
</div>
@endcan
@endif
@endif
@can('update', $asset)
<div class="col-md-12" style="padding-top: 5px;">
<a href="{{ route('hardware.edit', $asset->id) }}" style="width: 100%;" class="btn btn-sm btn-primary hidden-print">
{{ trans('admin/hardware/general.edit') }}
</a>
</div>
@endcan
@can('create', $asset)
<div class="col-md-12" style="padding-top: 5px;">
<a href="{{ route('clone/hardware', $asset->id) }}" style="width: 100%;" class="btn btn-sm btn-primary hidden-print">
{{ trans('admin/hardware/general.clone') }}
</a>
</div>
@endcan
@can('audit', \App\Models\Asset::class)
<div class="col-md-12" style="padding-top: 5px;">
<a href="{{ route('asset.audit.create', $asset->id) }}" style="width: 100%;" class="btn btn-sm btn-primary hidden-print">
{{ trans('general.audit') }}
</a>
</div>
@endcan
@can('delete', $asset)
@if ($asset->deleted_at=='')
<div class="col-md-12" style="padding-top: 30px; padding-bottom: 30px;">
<button class="btn btn-block btn-danger delete-asset" data-toggle="modal" data-title="{{ trans('general.delete') }}" data-content="{{ trans('general.sure_to_delete', ['item' => $asset->asset_tag]) }}" data-target="#dataConfirmModal">{{ trans('general.delete') }} </button>
<span class="sr-only">{{ trans('general.delete') }}</span>
</div>
@endif
@endcan
@if ($asset->deleted_at!='')
<div class="text-center col-md-12" style="padding-bottom: 15px;">
<div class="text-center col-md-12" style="padding-top: 30px; padding-bottom: 30px;">
<form method="POST" action="{{ route('restore/hardware', ['assetId' => $asset->id]) }}">
@csrf
<button class="btn btn-danger col-md-12">{{ trans('general.restore') }}</button>
@ -907,11 +902,13 @@
@endif
@if (($asset->assignedTo) && ($asset->deleted_at==''))
<h2>{{ trans('admin/hardware/form.checkedout_to') }}</h2>
<div style="text-align: left">
<h2>{{ trans('admin/hardware/form.checkedout_to') }}</h2>
<p>
@if($asset->checkedOutToUser()) <!-- Only users have avatars currently-->
<img src="{{ $asset->assignedTo->present()->gravatar() }}" class="user-image-inline" alt="{{ $asset->assignedTo->present()->fullName() }}">
@endif
</p>
{!! $asset->assignedTo->present()->glyph() . ' ' .$asset->assignedTo->present()->nameUrl() !!}
</p>
@ -958,6 +955,7 @@
</li>
@endif
</ul>
</div>
@endif
</div> <!-- div.col-md-4 -->
@ -1408,6 +1406,16 @@
@stop
@section('moar_scripts')
<script>
$('#dataConfirmModal').on('show.bs.modal', function (event) {
var content = $(event.relatedTarget).data('content');
var title = $(event.relatedTarget).data('title');
$(this).find(".modal-body").text(content);
$(this).find(".modal-header").text(title);
});
</script>
@include ('partials.bootstrap-table')
@stop