Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 62 additions & 0 deletions resources/views/blade/input/location-select.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
@use('App\Models\Location', 'Location')
@use('Illuminate\Support\Arr', 'Arr')

@props([
'label',
'name',
'selected',
'required' => false,
'multiple' => false,
'helpText' => null,
'hideNewButton' => false,
])

<div
@class([
'form-group',
'has-error' => $errors->has($name),
])
>

<label for="{{ $name }}" class="col-md-3 control-label">{{ $label }}</label>
<div class="col-md-7">
<select
class="js-data-ajax"
data-endpoint="locations"
data-placeholder="{{ trans('general.select_location') }}"
name="{{ $name }}"
style="width: 100%"
id="{{ $name }}_location_select"
aria-label="{{ $name }}"
@required($required)
@if ($multiple)
multiple
@endif
>
@if ($selected)
@foreach(Arr::wrap($selected) as $id)
<option value="{{ $id }}" selected="selected" role="option" aria-selected="true" role="option">
{{ optional(Location::find($id))->name }}
</option>
@endforeach
@endif
</select>
</div>

<div class="col-md-1 col-sm-1 text-left">
@unless($hideNewButton)
@can('create', Location::class)
<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>
@endcan
@endunless
</div>

{!! $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>') !!}

@if ($helpText)
<div class="col-md-7 col-sm-11 col-md-offset-3">
<p class="help-block">{{ $helpText }}</p>
</div>
@endif

</div>
21 changes: 20 additions & 1 deletion resources/views/hardware/checkin.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,26 @@
</div>
</div>

@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])
<x-input.location-select
:label="trans('general.location')"
name="location_id"
:help_text="($asset->defaultLoc) ? trans('general.checkin_to_diff_location', ['default_location' => $asset->defaultLoc->name]) : null"
:selected="old('location_id')"
/>

<!-- Update actual location -->
<div class="form-group">
<div class="col-md-9 col-md-offset-3">
<label class="form-control">
{{ Form::radio('update_default_location', '1', old('update_default_location'), ['checked'=> 'checked', 'aria-label'=>'update_default_location']) }}
{{ trans('admin/hardware/form.asset_location') }}
</label>
<label class="form-control">
{{ Form::radio('update_default_location', '0', old('update_default_location'), ['aria-label'=>'update_default_location']) }}
{{ trans('admin/hardware/form.asset_location_update_default_current') }}
</label>
</div>
</div> <!--/form-group-->

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