3
0
mirror of https://github.com/snipe/snipe-it.git synced 2026-08-18 11:15:42 +00:00

Convert bulk edit to form components

This commit is contained in:
snipe
2026-08-11 16:31:11 +01:00
parent b579b89afa
commit 1d90b8aebd
2 changed files with 80 additions and 8 deletions

View File

@ -0,0 +1,55 @@
@use('App\Models\AssetModel', 'AssetModel')
@use('Illuminate\Support\Arr', 'Arr')
@props([
'label',
'name',
'selected' => null,
'required' => false,
'multiple' => false,
'hideNewButton' => false,
])
<div
@class([
'form-group',
'has-error' => $errors->has($name),
])
>
<label for="{{ $name }}_select" class="col-md-3 control-label">{{ $label }}</label>
<div class="col-md-7">
<select
class="js-data-ajax"
data-endpoint="models"
data-placeholder="{{ trans('general.select_model') }}"
name="{{ $name }}{{ $multiple ? '[]' : '' }}"
id="{{ $name }}_select"
style="width: 100%"
aria-label="{{ $label }}"
@required($required)
@if ($multiple) multiple @endif
>
<option value=""></option>
@if ($selected)
@foreach(Arr::wrap($selected) as $value)
<option value="{{ $value }}" selected="selected" role="option" aria-selected="true">
{{ AssetModel::find($value)?->name }}
</option>
@endforeach
@endif
</select>
</div>
@unless($hideNewButton)
<div class="col-md-1 col-sm-1 text-left">
@can('create', AssetModel::class)
<a href="{{ route('modal.show', 'model') }}" data-toggle="modal" data-target="#createModal" data-select="{{ $name }}_select" class="btn btn-sm btn-theme">{{ trans('button.new') }}</a>
<span class="mac_spinner" style="padding-left: 10px; color: green; display:none; width: 30px;">
<i class="fas fa-spinner fa-spin" aria-hidden="true"></i>
</span>
@endcan
</div>
@endunless
<div class="col-md-8 col-md-offset-3"><x-form.error :name="$name" /></div>
</div>

View File

@ -143,10 +143,17 @@
</x-slot:input>
</x-form.row>
@include ('partials.forms.edit.model-select', ['translated_name' => trans('admin/hardware/form.model'), 'fieldname' => 'model_id'])
<x-input.model-select
:label="trans('admin/hardware/form.model')"
name="model_id"
:selected="old('model_id')"
/>
{{-- Default location --}}
@include ('partials.forms.edit.location-select', ['translated_name' => trans('admin/hardware/form.default_location'), 'fieldname' => 'rtd_location_id'])
<x-input.location-select
:label="trans('admin/hardware/form.default_location')"
name="rtd_location_id"
:selected="old('rtd_location_id')"
/>
{{-- Actual-location update rule (3-way radio) --}}
<x-form.radio-row
@ -174,11 +181,17 @@
</x-slot:input>
</x-form.row>
{{-- Supplier --}}
@include ('partials.forms.edit.supplier-select', ['translated_name' => trans('general.supplier'), 'fieldname' => 'supplier_id'])
<x-input.supplier-select
:label="trans('general.supplier')"
name="supplier_id"
:selected="old('supplier_id')"
/>
{{-- Company --}}
@include ('partials.forms.edit.company-select', ['translated_name' => trans('general.company'), 'fieldname' => 'company_id'])
<x-input.company-select
:label="trans('general.company')"
name="company_id"
:selected="old('company_id')"
/>
{{-- Order number --}}
<x-form.row
@ -244,7 +257,11 @@
input_div_class="col-md-7"
/>
@include ('partials.forms.edit.notes')
<x-form.row
:label="trans('general.notes')"
name="notes"
type="textarea"
/>
{{-- Set notes to null --}}
<x-form.checkbox-row