Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert Form::select to blade component #16065

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
25 changes: 25 additions & 0 deletions resources/views/blade/input/select.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
@props([
// <options> can either be provided as key => value pairs
// or passed in via the default $slot
'options',
'selected' => null,
'includeEmpty' => false,
'forLivewire' => false,
])

<select
{{ $attributes->class(['select2', 'livewire-select2' => $forLivewire]) }}
@if($forLivewire) data-livewire-component="{{ $this->getId() }}" @endif
>
@if($includeEmpty)
<option value=""></option>
@endif
{{-- map the simple key => value pairs when nothing is passed in via the slot --}}
@if($slot->isEmpty())
@foreach($options as $key => $value)
<option value="{{ $key }}" @selected($selected == $key)>{{ $value }}</option>
@endforeach
@else
{{ $slot }}
@endif
</select>
9 changes: 8 additions & 1 deletion resources/views/categories/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,14 @@
<div class="form-group {{ $errors->has('category_type') ? ' has-error' : '' }}">
<label for="category_type" class="col-md-3 control-label">{{ trans('general.type') }}</label>
<div class="col-md-7 required">
{{ Form::select('category_type', $category_types , old('category_type', $item->category_type), array('class'=>'select2', 'style'=>'min-width:350px', 'aria-label'=>'category_type', ($item->category_type!='') || ($item->itemCount() > 0) ? 'disabled' : '')) }}
<x-input.select
name="category_type"
:options="$category_types"
:selected="old('category_type', $item->category_type)"
:disabled="$item->category_type!='' || $item->itemCount() > 0"
style="min-width:350px"
aria-label="category_type"
/>
{!! $errors->first('category_type', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
<div class="col-md-7 col-md-offset-3">
Expand Down
9 changes: 8 additions & 1 deletion resources/views/custom_fields/fields/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,14 @@
}
@endphp
<div class="col-md-8 required">
{{ Form::select("format",Helper::predefined_formats(), ($field_format == '') ? $field->format : $field_format, array('class'=>'format select2 form-control', 'aria-label'=>'format', 'style' => 'width:100%;')) }}
<x-input.select
name="format"
:options="Helper::predefined_formats()"
:selected="($field_format == '') ? $field->format : $field_format"
class="format form-control"
style="width:100%"
aria-label="format"
/>
{!! $errors->first('format', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
</div>
Expand Down
8 changes: 6 additions & 2 deletions resources/views/custom_fields/fieldsets/view.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,12 @@
<label for="field_id" class="sr-only">
{{ trans('admin/custom-field/general.add_field_to_fieldset')}}
</label>
{{ Form::select("field_id",$custom_fields_list,"",['aria-label'=>'field_id', 'class'=>'select2', 'style' => 'min-width:400px;']) }}

<x-input.select
name="field_id"
:options="$custom_fields_list"
style="min-width:400px"
aria-label="field_id"
/>
</div>

<div class="form-group" style="display: none;">
Expand Down
8 changes: 7 additions & 1 deletion resources/views/hardware/bulk.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,13 @@
{{ trans('admin/hardware/form.status') }}
</label>
<div class="col-md-7">
{{ Form::select('status_id', $statuslabel_list , old('status_id'), array('class'=>'select2', 'style'=>'width:100%', 'aria-label'=>'status_id')) }}
<x-input.select
name="status_id"
:options="$statuslabel_list"
:selected="old('status_id')"
style="width: 100%"
aria-label="status_id"
/>
<p class="help-block">{{ trans('general.status_compatibility') }}</p>
{!! $errors->first('status_id', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
Expand Down
10 changes: 8 additions & 2 deletions resources/views/hardware/checkin.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,13 @@
{{ trans('admin/hardware/form.status') }}
</label>
<div class="col-md-8 required">
{{ Form::select('status_id', $statusLabel_list, '', array('class'=>'select2', 'style'=>'width:100%','id' =>'modal-statuslabel_types', 'aria-label'=>'status_id')) }}
<x-input.select
name="status_id"
id="modal-statuslabel_types"
:options="$statusLabel_list"
style="width: 100%"
aria-label="status_id"
/>
{!! $errors->first('status_id', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
</div>
Expand Down Expand Up @@ -142,4 +148,4 @@
</div>
</div>

@stop
@stop
8 changes: 7 additions & 1 deletion resources/views/hardware/checkout.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,13 @@
{{ trans('admin/hardware/form.status') }}
</label>
<div class="col-md-7 required">
{{ Form::select('status_id', $statusLabel_list, $asset->status_id, array('class'=>'select2', 'style'=>'width:100%','', 'aria-label'=>'status_id')) }}
<x-input.select
name="status_id"
:options="$statusLabel_list"
:selected="$asset->status_id"
style="width: 100%;"
aria-label="status_id"
/>
{!! $errors->first('status_id', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
</div>
Expand Down
8 changes: 7 additions & 1 deletion resources/views/hardware/quickscan-checkin.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@
{{ trans('admin/hardware/form.status') }}
</label>
<div class="col-md-7">
{{ Form::select('status_id', $statusLabel_list, '', array('class'=>'select2', 'style'=>'width:100%','', 'aria-label'=>'status_id')) }}
<x-input.select
name="status_id"
id="status_id"
:options="$statusLabel_list"
style="width:100%"
aria-label="status_id"
/>
{!! $errors->first('status_id', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,16 @@
{{ trans('admin/models/general.fieldset') }}
</label>
<div class="col-md-5">
{{ Form::select('fieldset_id', Helper::customFieldsetList(), old('fieldset_id', $fieldset_id), array('class'=>'select2 js-fieldset-field livewire-select2', 'style'=>'width:100%; min-width:350px', 'aria-label'=>'custom_fieldset', 'data-livewire-component' => $this->getId())) }}
<x-input.select
name="fieldset_id"
id="fieldset_id"
:options="Helper::customFieldsetList()"
:selected="old('fieldset_id', $fieldset_id)"
:for-livewire="true"
class="js-fieldset-field"
style="width:100%; min-width:350px;"
aria-label="custom_fieldset"
/>
{!! $errors->first('custom_fieldset', '<span class="alert-msg" aria-hidden="true"><br><i class="fas fa-times"></i> :message</span>') !!}
</div>
<div class="col-md-3">
Expand Down
50 changes: 30 additions & 20 deletions resources/views/livewire/importer.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -155,15 +155,20 @@ class="col-md-12 table table-striped snipe-table">
</label>

<div class="col-md-9 col-xs-12">
{{ Form::select('typeOfImport', $importTypes, $typeOfImport, [
'id' => 'import_type',
'class' => 'livewire-select2',
'style' => 'min-width: 350px',
'data-placeholder' => trans('general.select_var', ['thing' => trans('general.import_type')]),
'placeholder' => '', //needed so that the form-helper will put an empty option first
'data-minimum-results-for-search' => '-1', // Remove this if the list gets long enough that we need to search
'data-livewire-component' => $this->getId()
]) }}
<x-input.select
name="typeOfImport"
id="import_type"
:options="$importTypes"
:selected="$typeOfImport"
:for-livewire="true"
:include-empty="true"
:data-placeholder="trans('general.select_var', ['thing' => trans('general.import_type')])"
{{--placeholder needed so that the form-helper will put an empty option first--}}
placeholder=""
{{--Remove this if the list gets long enough that we need to search--}}
data-minimum-results-for-search="-1"
style="min-width: 350px;"
/>
@if ($typeOfImport === 'asset' && $snipeSettings->auto_increment_assets == 0)
<p class="help-block">
{{ trans('general.auto_incrementing_asset_tags_disabled_so_tags_required') }}
Expand Down Expand Up @@ -238,17 +243,22 @@ class="col-md-12 table table-striped snipe-table">

<label for="field_map.{{ $index }}" class="col-md-3 control-label text-right">{{ $header }}</label>
<div class="col-md-4">

{{ Form::select('field_map.'.$index, $columnOptions[$typeOfImport], @$field_map[$index],
[
'class' => 'mappings livewire-select2',
'placeholder' => trans('general.importer.do_not_import'),
'style' => 'min-width: 100%',
'data-livewire-component' => $this->getId()
],[
'-' => ['disabled' => true] // this makes the "-----" line unclickable
])
}}
<x-input.select
:name="'field_map.'.$index"
:for-livewire="true"
:placeholder="trans('general.importer.do_not_import')"
class="mappings"
style="min-width: 100%;"
>
<option selected="selected" value="">Do Not Import</option>
@foreach($columnOptions[$typeOfImport] as $key => $value)
<option
value="{{ $key }}"
@selected(@$field_map[$index] === $key)
@disabled($key === '-')
>{{ $value }}</option>
@endforeach
</x-input.select>
</div>
@if (($this->activeFile->first_row) && (array_key_exists($index, $this->activeFile->first_row)))
<div class="col-md-5">
Expand Down
18 changes: 11 additions & 7 deletions resources/views/livewire/slack-settings-form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,17 @@
</label>
</div>
<div class="col-md-9 required" wire:ignore>

@if (Helper::isDemoMode())
{{ Form::select('webhook_selected', array('slack' => trans('admin/settings/general.slack'), 'general' => trans('admin/settings/general.general_webhook'),'google' => trans('admin/settings/general.google_workspaces'), 'microsoft' => trans('admin/settings/general.ms_teams')), old('webhook_selected', $webhook_selected), array('class'=>'select2 form-control', 'aria-label' => 'webhook_selected', 'id' => 'select2', 'style'=>'width:100%', 'disabled')) }}
@else
{{ Form::select('webhook_selected', array('slack' => trans('admin/settings/general.slack'), 'general' => trans('admin/settings/general.general_webhook'),'google' => trans('admin/settings/general.google_workspaces'), 'microsoft' => trans('admin/settings/general.ms_teams')), old('webhook_selected', $webhook_selected), array('class'=>'select2 form-control', 'aria-label' => 'webhook_selected', 'id' => 'select2', 'data-minimum-results-for-search' => '-1', 'style'=>'width:100%')) }}
@endif

<x-input.select
name="webhook_selected"
id="select2"
:options="['slack' => trans('admin/settings/general.slack'), 'general' => trans('admin/settings/general.general_webhook'),'google' => trans('admin/settings/general.google_workspaces'), 'microsoft' => trans('admin/settings/general.ms_teams')]"
:selected="old('webhook_selected', $webhook_selected)"
:disabled="Helper::isDemoMode()"
data-minimum-results-for-search="-1"
class="form-control"
style="width:100%"
aria-label="webhook_selected"
/>
</div>
</div>

Expand Down
12 changes: 10 additions & 2 deletions resources/views/modals/partials/fieldset-select.blade.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
<!-- partials/modals/partials/fieldset-select.blade.php -->
<div class="dynamic-form-row">
<div class="col-md-4 col-xs-12"><label for="modal-fieldset_id">{{ trans('admin/models/general.fieldset') }}:</label></div>
<div class="col-md-8 col-xs-12">{{ Form::select('fieldset_id', Helper::customFieldsetList(),old('fieldset_id'), array('class'=>'select2', 'id'=>'modal-fieldset_id', 'style'=>'width:100%;')) }}</div>
<div class="col-md-8 col-xs-12">
<x-input.select
name="fieldset_id"
id="modal-fieldset_id"
:options="Helper::customFieldsetList()"
:selected="old('fieldset_id')"
style="width:100%;"
/>
</div>
</div>
<!-- partials/modals/partials/fieldset-select.blade.php -->
<!-- partials/modals/partials/fieldset-select.blade.php -->
10 changes: 9 additions & 1 deletion resources/views/modals/statuslabel.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,15 @@
<div class="dynamic-form-row">
<div class="col-md-3 col-xs-12"><label for="modal-type">{{ trans('admin/statuslabels/table.status_type') }}:
</label></div>
<div class="col-md-8 col-xs-12">{{ Form::select('type', $statuslabel_types, '', array('class'=>'select2', 'style'=>'width:100%','id' =>'modal-type', 'required',)) }}</div>
<div class="col-md-8 col-xs-12">
<x-input.select
name="type"
id="modal-type"
:options="$statuslabel_types"
required
style="width:100%;"
/>
</div>
</div>
</form>
</div>
Expand Down
Loading
Loading