Skip to content

A free open source IT asset/license management system

Fixed #19848 - opt out of requireness for checkout selector in asset create

snipe072d5dcf3643
diff --git a/resources/views/hardware/edit.blade.php b/resources/views/hardware/edit.blade.php
index 5ac66033e6..77f7f55cbb 100755
--- a/resources/views/hardware/edit.blade.php
+++ b/resources/views/hardware/edit.blade.php
@@ -98,7 +98,8 @@
@include ('partials.forms.edit.status', [ 'required' => 'true'])
@if (!$item->id)
- @include ('partials.forms.checkout-selector', ['user_select' => 'true','asset_select' => 'true', 'location_select' => 'true', 'style' => 'display:none;'])
+
+ @include ('partials.forms.checkout-selector', ['user_select' => 'true','asset_select' => 'true', 'location_select' => 'true', 'style' => 'display:none;', 'optional' => true])
<x-input.user-select
:label="trans('general.user')"
name="assigned_user"
diff --git a/resources/views/partials/forms/checkout-selector.blade.php b/resources/views/partials/forms/checkout-selector.blade.php
index e119bd9282..23b25d5b95 100644
--- a/resources/views/partials/forms/checkout-selector.blade.php
+++ b/resources/views/partials/forms/checkout-selector.blade.php
@@ -1,3 +1,7 @@
+{{-- $optional opts out of the requiredness, usually only used in the asset-create screen --}}
+@php
+ $optional = isset($optional) && $optional;
+@endphp
<div class="form-group" id="assignto_selector"{!! (isset($style)) ? ' style="'.e($style).'"' : '' !!}>
<label for="checkout_to_type" class="col-md-3 control-label">{{ trans('admin/hardware/form.checkout_to') }}</label>
<div class="col-md-8">
@@ -6,7 +10,8 @@
@if ((isset($user_select)) && ($user_select!='false'))
<label class="btn btn-theme @if((session('checkout_to_type') ?: 'user') == 'user') active @endif">
<input name="checkout_to_type" value="user" aria-label="checkout_to_type"
- type="radio" data-required-select="#assigned_user_select"
+ type="radio"
+ @unless ($optional) data-required-select="#assigned_user_select" @endunless
@checked((session('checkout_to_type') ?: 'user') == 'user')>
<x-icon type="user" />
{{ trans('general.user') }}
@@ -15,7 +20,8 @@
@if ((isset($asset_select)) && ($asset_select!='false'))
<label class="btn btn-theme @if(session('checkout_to_type') == 'asset') active @endif">
<input name="checkout_to_type" value="asset" aria-label="checkout_to_type"
- type="radio" data-required-select="#assigned_asset_select"
+ type="radio"
+ @unless ($optional) data-required-select="#assigned_asset_select" @endunless
@checked(session('checkout_to_type') == 'asset')>
<i class="fas fa-barcode" aria-hidden="true"></i>
{{ trans('general.asset') }}
@@ -24,7 +30,8 @@
@if ((isset($location_select)) && ($location_select!='false'))
<label class="btn btn-theme @if(session('checkout_to_type') == 'location') active @endif">
<input name="checkout_to_type" value="location" aria-label="checkout_to_type"
- type="radio" data-required-select="#assigned_location_location_select"
+ type="radio"
+ @unless ($optional) data-required-select="#assigned_location_location_select" @endunless
@checked(session('checkout_to_type') == 'location')>
<i class="fas fa-map-marker-alt" aria-hidden="true"></i>
{{ trans('general.location') }}