Return input when linking a BBS, some consistent instantiation of <form>, more work on select2 transition

This commit is contained in:
2024-12-06 11:11:50 +11:00
parent 70f3a049f6
commit 082b70e072
6 changed files with 50 additions and 129 deletions

View File

@@ -1,3 +1,7 @@
<!-- $o=Zone::class-->
@use(App\Models\Domain)
@use(App\Models\System)
@extends('layouts.app')
@section('htmlheader_title')
@@ -30,24 +34,12 @@
</div>
<div class="col-3">
<label for="domain" class="form-label">Domain</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-tag-fill"></i></span>
<select class="form-select @error('domain_id') is-invalid @enderror" id="domain" name="domain_id" required @cannot('admin',$o)disabled @endcannot>
<option value="">&nbsp;</option>
@foreach (\App\Models\Domain::active()->orderBy('name')->cursor() as $oo)
<option value="{{ $oo->id }}" @if(old('domain_id',$o->domain_id)==$oo->id)selected @endif>{{ $oo->name }}</option>
@endforeach
</select>
<span class="invalid-feedback" role="alert">
@error('domain_id')
{{ $message }}
@else
A domain is required.
@enderror
</span>
<span class="input-helper">Add a <a href="{{ url('domain/addedit') }}">NEW Domain</a></span>
</div>
@php
$helper = (! $o->domain_id)
? sprintf('Add a <a href="%s">NEW Domain</a>',url('domain/addedit'))
: sprintf('<a href="%s">Edit</a> Domain',url('domain/addedit',[$o->domain_id]));
@endphp
<x-form.select name="domain_id" icon="bi-tag-fill" label="Domain" :helper="$helper" feedback="A domain is required" :value="$o->domain_id" :options="Domain::select(['id','name'])->active()->orderBy('name')->cursor()->map(fn($item)=>['id'=>$item->id,'value'=>$item->name])" required/>
</div>
<div class="offset-1 col-2">
@@ -84,24 +76,12 @@
<div class="row">
<div class="col-4">
<label for="system" class="form-label">System</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-laptop-fill"></i></span>
<select style="width: 80%;" class="form-select @error('system_id') is-invalid @enderror" id="system" name="system_id" required @cannot('admin',$o)disabled @endcannot>
<option value="">&nbsp;</option>
@foreach (\App\Models\System::active()->cursor() as $oo)
<option value="{{ $oo->id }}" @if(old('system_id',$o->system_id)==$oo->id)selected @endif>{{ $oo->name }}</option>
@endforeach
</select>
<span class="invalid-feedback" role="alert">
@error('system_id')
{{ $message }}
@else
A system is required.
@enderror
</span>
<span class="input-helper">Add a <a href="{{ url('system/addedit') }}">NEW System</a>. This system is the primary mailer/tosser responsible for managing the zone.</span>
</div>
@php
$helper = (! $o->system_id)
? sprintf('Add a <a href="%s">NEW System</a>',url('domain/addedit'))
: sprintf('<a href="%s">Edit</a> System',url('domain/addedit',[$o->system_id]));
@endphp
<x-form.select name="system_id" icon="bi-laptop-fill" label="System" feedback="A system is required" :helper="sprintf('%s. This system is the primary mailer/tosser responsible for the zone.',$helper)" :value="$o->system_id" :options="System::select(['id','name'])->active()->orderBy('name')->cursor()->map(fn($item)=>['id'=>$item->id,'value'=>$item->name])" required/>
</div>
</div>
@@ -175,17 +155,4 @@
</div>
</div>
</form>
@endsection
@section('page-css')
@css('select2')
@append
@section('page-scripts')
@js('select2')
<script type="text/javascript">
$(document).ready(function() {
$('#system').select2();
});
</script>
@append
@endsection