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,14 +1,14 @@
@use(App\Models\Address)
@extends('layouts.app')
@section('htmlheader_title')
Link
@endsection
@section('content')
<form class="needs-validation" method="post" novalidate>
<form class="needs-validation" method="post" autocomplete="off" novalidate>
@csrf
<input type="hidden" id="address_id" name="address_id">
<div class="row">
<div class="col-12">
<div class="greyframe titledbox shadow0xb0">
@@ -18,29 +18,16 @@
<div class="row">
<!-- Name -->
<div class="col-5">
<label for="system" class="form-label">BBS Name</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="address_id" required>
<option value="">&nbsp;</option>
@foreach (\App\Models\Address::select(['addresses.id','addresses.host_id','addresses.node_id','addresses.point_id','addresses.zone_id','systems.name'])
->active()
->join('systems',['systems.id'=>'addresses.system_id'])
->whereRaw('systems.id NOT IN (SELECT system_id FROM system_user)')
->with(['zone'])
->orderBy('systems.name')
->get() as $oo)
<option value="{{ $oo->id }}" @if(old('id')===$oo->id)selected @endif>{{ $oo->name }} ({{ $oo->ftn3d }})</option>
@endforeach
</select>
<span class="invalid-feedback" role="alert">
@error('system_id')
{{ $message }}
@else
BBS Name is required.
@enderror
</span>
</div>
@php
$options = Address::select(['addresses.id','addresses.host_id','addresses.node_id','addresses.point_id','addresses.zone_id','systems.name'])
->active()
->join('systems',['systems.id'=>'addresses.system_id'])
->whereRaw('systems.id NOT IN (SELECT system_id FROM "system_user")')
->with(['system','zone'])
->orderBy('systems.name')
->cursor()
@endphp
<x-form.select name="address_id" icon="bi-laptop-fill" label="BBS Address" placeholder="Find your AKA" feedback="AKA is required" helper="Enter your BBS name" value="" :options="$options->map(fn($item)=>['id'=>$item->id,'value'=>sprintf('%s (%s)',$item->name,$item->ftn3d)])" required/>
</div>
</div>
@@ -72,18 +59,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({
placeholder: 'Find your Address',
});
});
</script>
@endsection

View File

@@ -7,7 +7,7 @@
@endsection
@section('content')
<form method="POST" autocomplete="off">
<form class="needs-validation" method="post" autocomplete="off" novalidate>
@csrf
<input type="hidden" name="action" value="register">
@@ -26,7 +26,7 @@
->whereRaw('id NOT IN (SELECT system_id FROM "system_user")')
->cursor())
<x-form.select name="system_id" icon="bi-laptop-fill" label="BBS Name" placeholder="See if your BBS exists, otherwise add it" feedback="BBS Name is required" helper="Enter your BBS name and press NEXT" :addvalues="true" :options="$options->map(fn($item,$key)=>['id'=>$item->id,'value'=>$item->name])" />
<x-form.select name="system_id" icon="bi-laptop-fill" label="BBS Name" placeholder="See if your BBS exists, otherwise add it" feedback="BBS Name is required" helper="Enter your BBS name and press NEXT" :addvalues="true" :options="$options->map(fn($item,$key)=>['id'=>$item->id,'value'=>$item->name])" required/>
</div>
</div>