Skip to content

Commit c711278

Browse files
authored
Merge pull request #16486 from marcusmoore/bug/sc-28639
Fixed location being automatically populated on asset checkin screen
2 parents ff637f1 + 18b208b commit c711278

File tree

2 files changed

+82
-1
lines changed

2 files changed

+82
-1
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
@use('App\Models\Location', 'Location')
2+
@use('Illuminate\Support\Arr', 'Arr')
3+
4+
@props([
5+
'label',
6+
'name',
7+
'selected',
8+
'required' => false,
9+
'multiple' => false,
10+
'helpText' => null,
11+
'hideNewButton' => false,
12+
])
13+
14+
<div
15+
@class([
16+
'form-group',
17+
'has-error' => $errors->has($name),
18+
])
19+
>
20+
21+
<label for="{{ $name }}" class="col-md-3 control-label">{{ $label }}</label>
22+
<div class="col-md-7">
23+
<select
24+
class="js-data-ajax"
25+
data-endpoint="locations"
26+
data-placeholder="{{ trans('general.select_location') }}"
27+
name="{{ $name }}"
28+
style="width: 100%"
29+
id="{{ $name }}_location_select"
30+
aria-label="{{ $name }}"
31+
@required($required)
32+
@if ($multiple)
33+
multiple
34+
@endif
35+
>
36+
@if ($selected)
37+
@foreach(Arr::wrap($selected) as $id)
38+
<option value="{{ $id }}" selected="selected" role="option" aria-selected="true" role="option">
39+
{{ optional(Location::find($id))->name }}
40+
</option>
41+
@endforeach
42+
@endif
43+
</select>
44+
</div>
45+
46+
<div class="col-md-1 col-sm-1 text-left">
47+
@unless($hideNewButton)
48+
@can('create', Location::class)
49+
<a href='{{ route('modal.show', 'location') }}' data-toggle="modal" data-target="#createModal" data-select='{{ $name }}_location_select' class="btn btn-sm btn-primary">{{ trans('button.new') }}</a>
50+
@endcan
51+
@endunless
52+
</div>
53+
54+
{!! $errors->first($name, '<div class="col-md-8 col-md-offset-3"><span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span></div>') !!}
55+
56+
@if ($helpText)
57+
<div class="col-md-7 col-sm-11 col-md-offset-3">
58+
<p class="help-block">{{ $helpText }}</p>
59+
</div>
60+
@endif
61+
62+
</div>

resources/views/hardware/checkin.blade.php

+20-1
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,26 @@
9595
</div>
9696
</div>
9797

98-
@include ('partials.forms.edit.location-select', ['translated_name' => trans('general.location'), 'fieldname' => 'location_id', 'help_text' => ($asset->defaultLoc) ? trans('general.checkin_to_diff_location', ['default_location' => $asset->defaultLoc->name]) : null, 'hide_location_radio' => true])
98+
<x-input.location-select
99+
:label="trans('general.location')"
100+
name="location_id"
101+
:help_text="($asset->defaultLoc) ? trans('general.checkin_to_diff_location', ['default_location' => $asset->defaultLoc->name]) : null"
102+
:selected="old('location_id')"
103+
/>
104+
105+
<!-- Update actual location -->
106+
<div class="form-group">
107+
<div class="col-md-9 col-md-offset-3">
108+
<label class="form-control">
109+
{{ Form::radio('update_default_location', '1', old('update_default_location'), ['checked'=> 'checked', 'aria-label'=>'update_default_location']) }}
110+
{{ trans('admin/hardware/form.asset_location') }}
111+
</label>
112+
<label class="form-control">
113+
{{ Form::radio('update_default_location', '0', old('update_default_location'), ['aria-label'=>'update_default_location']) }}
114+
{{ trans('admin/hardware/form.asset_location_update_default_current') }}
115+
</label>
116+
</div>
117+
</div> <!--/form-group-->
99118

100119
<!-- Checkout/Checkin Date -->
101120
<div class="form-group{{ $errors->has('checkin_at') ? ' has-error' : '' }}">

0 commit comments

Comments
 (0)