Disable buttons on view page if model is invalid

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-05-31 18:47:53 +01:00
parent b936591240
commit 8c5249ba4b

View file

@ -895,7 +895,7 @@
@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">
<a href="{{ route('hardware.checkin.create', $asset->id) }}" class="btn btn-sm btn-primary btn-block hidden-print{{ (!$asset->model ? ' disabled' : '') }}"{!! (!$asset->model ? ' data-tooltip="true" title="'.trans('admin/hardware/general.model_invalid_fix').'" disabled' : '') !!}>
{{ trans('admin/hardware/general.checkin') }}
</a>
</div>
@ -903,7 +903,7 @@
@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">
<a href="{{ route('hardware.checkout.create', $asset->id) }}" class="btn btn-sm btn-primary btn-block hidden-print{{ (!$asset->model ? ' disabled' : '') }}"{!! (!$asset->model ? ' data-tooltip="true" title="'.trans('admin/hardware/general.model_invalid_fix').'" disabled' : '') !!}>
{{ trans('admin/hardware/general.checkout') }}
</a>
</div>
@ -915,7 +915,7 @@
@can('update', $asset)
@if ($asset->deleted_at=='')
<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">
<a href="{{ route('hardware.edit', $asset->id) }}" class="btn btn-sm btn-primary btn-block hidden-print">
{{ trans('admin/hardware/general.edit') }}
</a>
</div>
@ -924,7 +924,7 @@
@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">
<a href="{{ route('clone/hardware', $asset->id) }}" class="btn btn-sm btn-primary btn-block hidden-print">
{{ trans('admin/hardware/general.clone') }}
</a>
</div>
@ -932,7 +932,7 @@
@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">
<a href="{{ route('asset.audit.create', $asset->id) }}" class="btn btn-sm btn-primary btn-block hidden-print{{ (!$asset->model ? ' disabled' : '') }}"{!! (!$asset->model ? ' data-tooltip="true" title="'.trans('admin/hardware/general.model_invalid_fix').'" disabled' : '') !!}">
{{ trans('general.audit') }}
</a>
</div>
@ -941,12 +941,13 @@
@can('delete', $asset)
<div class="col-md-12" style="padding-top: 30px; padding-bottom: 30px;">
@if ($asset->deleted_at=='')
<button class="btn btn-sm btn-block btn-danger delete-asset" data-toggle="modal" data-title="{{ trans('general.delete') }}" data-content="{{ trans('general.sure_to_delete_var', ['item' => $asset->asset_tag]) }}" data-target="#dataConfirmModal">{{ trans('general.delete') }} </button>
<button class="btn btn-sm btn-block btn-danger delete-asset" data-toggle="modal" data-title="{{ trans('general.delete') }}" data-content="{{ trans('general.sure_to_delete_var', ['item' => $asset->asset_tag]) }}" data-target="#dataConfirmModal">{{ trans('general.delete') }}
</button>
<span class="sr-only">{{ trans('general.delete') }}</span>
@else
<form method="POST" action="{{ route('restore/hardware', ['assetId' => $asset->id]) }}">
@csrf
<button class="btn btn-sm btn-warning col-md-12">{{ trans('general.restore') }}</button>
<button class="btn btn-sm btn-warning btn-block">{{ trans('general.restore') }}</button>
</form>
@endif
</div>