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

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

View File

@ -64,7 +64,9 @@ class UserController extends Controller
'code', 'Invalid Code!'
);
return back()->withErrors($validator);
return back()
->withInput()
->withErrors($validator);
}
}

View File

@ -1,5 +1,5 @@
@use(App\Models\Echoarea)
<!-- $o=Domain::class -->
@use(App\Models\Echoarea)
@extends('layouts.app')
@ -8,7 +8,7 @@
@endsection
@section('content')
<form class="needs-validation" method="post" novalidate>
<form class="needs-validation" method="post" autocomplete="off" novalidate>
@csrf
<div class="row">
@ -137,22 +137,12 @@
</div>
<div class="col-4">
@if ($o->isManaged())
<label for="nodestatus_id" class="form-label">Echoarea Node Status</label>
<div class="input-group has-validation">
<span class="input-group-text"><i class="bi bi-journal-text"></i></span>
<select style="width: 80%;" class="form-select @error('nodestatus_id') is-invalid @enderror" id="nodestatus_id" name="nodestatus_id" @cannot('admin',$o)disabled @endcannot>
<option value="">&nbsp;</option>
@foreach (Echoarea::active()->where('domain_id',$o->id)->orderBy('description')->cursor() as $oo)
<option value="{{ $oo->id }}" @if(old('nodestatus_id',$o->nodestatus_id)==$oo->id)selected @endif>{{ $oo->description }}</option>
@endforeach
</select>
<span class="invalid-feedback" role="alert">
@error('nodestatus_id')
{{ $message }}
@enderror
</span>
<span class="input-helper">Add a <a href="{{ url('echoarea/addedit') }}">NEW Echoarea</a>. This echoarea is used to send node status messages.</span>
</div>
@php
$helper = (! $o->nodestatus_id)
? sprintf('Add a <a href="%s">NEW Echoarea</a>. This echoarea is used to send node status messages.',url('echoarea/addedit'))
: sprintf('<a href="%s">Edit</a> Echoarea',url('echoarea/addedit',[$o->nodestatus_id]));
@endphp
<x-form.select name="nodestatus_id" icon="bi-journal-text" label="Echoarea Node Status" :helper="$helper" :value="$o->nodestatus_id" :options="Echoarea::select('id','description')->active()->where('domain_id',$o->id)->orderBy('description')->cursor()->map(fn($item)=>['id'=>$item->id,'value'=>$item->description])"/>
@endif
</div>
</div>
@ -195,21 +185,10 @@
</form>
@endsection
@section('page-css')
@css('simplemde')
@css('select2')
@append
@section('page-scripts')
@js('simplemde')
@js('select2')
@pa(simplemde)
@can('admin',$o)
@section('page-scripts')
<script type="text/javascript">
var simplemde = new SimpleMDE({ element: $("#homepage")[0] });
$(document).ready(function() {
$('#nodestatus_id').select2();
});
</script>
@endcan
@append

View File

@ -1,6 +1,6 @@
@use(App\Models\Zone)
<form class="needs-validation" method="post" action="{{ url('system/address/add',$o->id) }}" novalidate>
<form class="needs-validation" method="post" action="{{ url('system/address/add',$o->id) }}" autocomplete="off" novalidate>
@csrf
<input type="hidden" id="action" name="action" value="">
@ -10,7 +10,7 @@
<div class="row">
<!-- Select Zone -->
<div class="col-3">
<x-form.select name="zone_id" icon="bi-hash" label="Zone" :options="Zone::select(['id','zone_id','domain_id'])->active()->domainZoneOrder()->with(['domain'])->get()->map(fn($item,$key)=>['id'=>$item->id,'value'=>sprintf('%d [%s]',$item->zone_id,$item->domain->name)])" required="true" />
<x-form.select name="zone_id" icon="bi-hash" label="Zone" :options="Zone::select(['id','zone_id','domain_id'])->active()->domainZoneOrder()->with(['domain'])->cursor()->map(fn($item,$key)=>['id'=>$item->id,'value'=>sprintf('%d [%s]',$item->zone_id,$item->domain->name)])" required="true" />
</div>
<!-- Select Region -->

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'])
@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(['zone'])
->whereRaw('systems.id NOT IN (SELECT system_id FROM "system_user")')
->with(['system','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>
->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>
@ -73,17 +60,3 @@
</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>

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>
@ -176,16 +156,3 @@
</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