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

Converted Form::select and Form::textarea to blade components #15983

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
2d9a5b9
Add textarea component
marcusmoore Nov 25, 2024
6ba467b
Replace branding and eula textareas with new component
marcusmoore Nov 25, 2024
8020527
Convert a couple more templates
marcusmoore Nov 25, 2024
c35f70b
Convert textarea in ldap settings
marcusmoore Nov 25, 2024
6af8412
Convert textarea in saml settings
marcusmoore Nov 26, 2024
07b5544
Convert textarea in upload modal
marcusmoore Nov 26, 2024
b6f8ac4
Convert some selects
marcusmoore Nov 26, 2024
447bb40
Convert selects on branding settings page
marcusmoore Nov 26, 2024
f80b271
Convert selects on general settings page
marcusmoore Nov 26, 2024
8ad3ec5
Convert additional selects
marcusmoore Dec 3, 2024
8c37c33
Convert additional selects
marcusmoore Dec 5, 2024
26ee4d7
Convert additional selects
marcusmoore Dec 5, 2024
657ea10
Convert additional selects
marcusmoore Dec 10, 2024
2a8790c
Convert additional selects
marcusmoore Dec 10, 2024
ca30f4e
Convert additional selects
marcusmoore Dec 10, 2024
26ee8e3
Allow passing options via a slot
marcusmoore Dec 10, 2024
8622448
Convert select in importer
marcusmoore Dec 10, 2024
5d4eb36
Add comments
marcusmoore Dec 10, 2024
286293a
Delete unused partials
marcusmoore Dec 17, 2024
e8e22b4
Add required indicator to listbox
marcusmoore Dec 17, 2024
1726dfa
Merge branch 'develop' into chore/migrate-blade-helpers
marcusmoore Dec 17, 2024
4b77d6d
Convert the selects in the label settings
marcusmoore Dec 17, 2024
b0a6a3d
Use "options" instead of "items"
marcusmoore Dec 17, 2024
cef196f
Move name to first attribute
marcusmoore Dec 17, 2024
b557ca6
Standardize attribute order
marcusmoore Dec 17, 2024
f9dc650
Remove unneeded attribute
marcusmoore Dec 17, 2024
496cf93
Improve comment
marcusmoore Dec 17, 2024
848cd62
Formatting
marcusmoore Dec 17, 2024
9c67776
Use attribute spreading in text area
marcusmoore Dec 17, 2024
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
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>
11 changes: 11 additions & 0 deletions resources/views/blade/input/textarea.blade.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
@props([
'value' => '',
'cols' => 50,
'rows' => 10,
Comment on lines +3 to +4
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI: these are the defaults that Form::textarea would give you.

])

<textarea
{{ $attributes->merge(['class' => 'form-control']) }}
cols="{{ $cols }}"
rows="{{ $rows }}"
>{{ $value }}</textarea>
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
17 changes: 15 additions & 2 deletions resources/views/custom_fields/fields/edit.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,13 @@
{{ trans('admin/custom_fields/general.field_values') }}
</label>
<div class="col-md-8 required">
{!! Form::textarea('field_values', old('name', $field->field_values), ['style' => 'width: 100%', 'rows' => 4, 'class' => 'form-control', 'aria-label'=>'field_values']) !!}
<x-input.textarea
name="field_values"
:value="old('field_values', $field->field_values)"
style="width: 100%"
rows="4"
aria-label="field_values"
/>
{!! $errors->first('field_values', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
<p class="help-block">{{ trans('admin/custom_fields/general.field_values_help') }}</p>
</div>
Expand All @@ -88,7 +94,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
16 changes: 11 additions & 5 deletions resources/views/hardware/quickscan-checkin.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
}
</style>



<div class="row">
{{ Form::open(['method' => 'POST', 'class' => 'form-horizontal', 'role' => 'form', 'id' => 'checkin-form' ]) }}
Expand Down 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 All @@ -63,8 +69,8 @@
{!! $errors->first('note', '<span class="alert-msg" aria-hidden="true"><i class="fas fa-times" aria-hidden="true"></i> :message</span>') !!}
</div>
</div>



</div> <!--/.box-body-->
<div class="box-footer">
Expand All @@ -87,7 +93,7 @@
<h2 class="box-title"> {{ trans('general.quickscan_checkin_status') }} (<span id="checkin-counter">0</span> {{ trans('general.assets_checked_in_count') }}) </h2>
</div>
<div class="box-body">

<table id="checkedin" class="table table-striped snipe-table">
<thead>
<tr>
Expand Down
7 changes: 6 additions & 1 deletion resources/views/livewire/category-edit-form.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@
<div class="form-group {{ $errors->has('eula_text') ? 'error' : '' }}">
<label for="eula_text" class="col-md-3 control-label">{{ trans('admin/categories/general.eula_text') }}</label>
<div class="col-md-7">
{{ Form::textarea('eula_text', null, ['wire:model.live' => 'eulaText', 'class' => 'form-control', 'aria-label'=>'eula_text', 'disabled' => $this->eulaTextDisabled]) }}
<x-input.textarea
name="eula_text"
wire:model.live="eulaText"
aria-label="eula_text"
:disabled="$this->eulaTextDisabled"
/>
<p class="help-block">{!! trans('admin/categories/general.eula_text_help') !!} </p>
<p class="help-block">{!! trans('admin/settings/general.eula_markdown') !!} </p>
{!! $errors->first('eula_text', '<span class="alert-msg" aria-hidden="true">:message</span>') !!}
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
Loading
Loading