More changes to use form.select component. Re-engineered user BBS registration

This commit is contained in:
2024-12-06 08:33:24 +11:00
parent fd780d1756
commit e7336a942b
13 changed files with 253 additions and 422 deletions

View File

@@ -1,16 +1,15 @@
@use(App\Models\System)
@extends('layouts.app')
@section('htmlheader_title')
Register System
@endsection
@php
use App\Models\System;
@endphp
@section('content')
<form class="needs-validation" method="post" autocomplete="off" novalidate>
<form method="POST" autocomplete="off">
@csrf
<input type="hidden" name="action" value="register">
<div class="row">
<div class="col-12">
@@ -27,13 +26,13 @@ use App\Models\System;
->whereRaw('id NOT IN (SELECT system_id FROM "system_user")')
->cursor())
<x-form.select id="system" name="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])" />
</div>
</div>
<div class="row">
<div class="col-12 pb-2">
<button type="button" name="submit" class="btn btn-success">Next</button><span id="next" class="m-2"><i class="spinner-border spinner-border-sm text-light d-none"></i></span>
<button type="submit" class="btn btn-success">Next</button><span id="next" class="m-2"><i class="spinner-border spinner-border-sm text-light d-none"></i></span>
</div>
</div>
</div>
@@ -41,104 +40,4 @@ use App\Models\System;
</div>
</div>
</form>
<div class="modal fade" id="no-auth" tabindex="-1">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header bg-danger">
<h5 class="modal-title">ERROR: No authorisation</h5>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p>It appears that you are not allowed to create this entry.</p>
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-bs-dismiss="modal">Close</button>
</div>
</div>
</div>
</div>
@endsection
@section('page-scripts')
<script type='text/javascript'>
var system_id;
var noauth = new bootstrap.Modal(document.getElementById('no-auth'), {});
function validation(item,message) {
var attr = $('input[id='+item+']');
attr.addClass('is-invalid')
attr.parent().find('.invalid-feedback').empty().append(message);
}
/**
* We have selected a BBS from the link/register form, and it's either a new entry or an existing one
* @param icon
*/
function getform(icon) {
$.ajax({
url : '{{ url('user/system/register') }}',
type : 'POST',
data : { system_id: system_id,name: $('#system').val(),action: 'register',old: {!! json_encode(old()) !!} },
dataType : 'json',
async : true,
cache : false,
beforeSend : function() {
if (icon)
icon.toggleClass('d-none');
},
complete : function(data) {
switch (data.status) {
case 200:
// if json is null, means no match, won't do again.
if(data.responseText===null || (data.responseText.length===0)) return;
$('#create').empty().append(data.responseText);
@if($errors->count())
@foreach($errors->keys() as $key)
validation('{{ $key }}','{{ $errors->first($key) }}');
@endforeach
@endif
break;
case 403:
if (icon)
icon.toggleClass('d-none');
noauth.show();
break;
case 419:
location.reload();
break;
case 422:
validation('name',data.responseJSON.errors.name[0]);
if (icon)
icon.toggleClass('d-none');
break;
default:
return false;
}
}
})
}
if ({{ old('submit') === 'create' ? 'true' : 'false' }}) {
getform();
}
$(document).ready(function() {
$('button[name=submit]').on('click',function() {
icon = $(this).parent().find('i');
if (! $('#system').val())
return;
getform(icon);
})
});
</script>
@append
@endsection

View File

@@ -0,0 +1,57 @@
<!-- $so=System::class -->
@use(App\Models\System)
@extends('layouts.app')
@section('htmlheader_title')
Register System
@endsection
@section('content')
@if(! $so->address)
<h3 class="pt-2">Enable to complete registration</h3>
<p>The system you selected <strong class="highlight">{{ $so->name }}</strong> doesnt have mailer details, please contact that system administration to update those details first</p>
@else
<h3 class="pt-2">System Details:</h3>
<table class="monotable">
<tr>
<th>System</th>
<th>{{ $so->name }}</th>
</tr>
<tr>
<th>Sysop</th>
<th>{{ $so->sysop }}</th>
</tr>
<tr>
<th>Location</th>
<th>{{ $so->location }}</th>
</tr>
<tr>
<th>Networks</th>
<th>{{ $so->akas->pluck('ftn')->join(', ') }}</th>
</tr>
<tr>
<th>Address</th>
<th>{{ $so->access_mailer }}</th>
</tr>
</table>
<p>If the details are above are not correct, then please contact the (ZC) to have them corrected first.</p>
<p>Otherwise, if all is good, we'll send a netmail to <strong class="highlight">{{ $so->sysop }}</strong> at <strong class="highlight">{{ $so->access_mailer }}</strong></p> with further details.
<form class="needs-validation" method="post" autocomplete="off" action="{{ url('user/system/link') }}" novalidate>
@csrf
<input type="hidden" name="system_id" value="{{ $so->id }}">
<input type="hidden" name="name" value="{{ $so->name }}">
<div class="row pb-2">
<div class="col-12">
<input type="submit" name="action" class="btn btn-success" value="Link">
</div>
</div>
</form>
@endif
@endsection

View File

@@ -1,41 +0,0 @@
<!-- $o = System::class -->
<h3>System Details:</h3>
<table class="monotable">
<tr>
<th>System</th>
<th>{{ $o->name }}</th>
</tr>
<tr>
<th>Sysop</th>
<th>{{ $o->sysop }}</th>
</tr>
<tr>
<th>Location</th>
<th>{{ $o->location }}</th>
</tr>
<tr>
<th>Networks</th>
<th>{{ $o->akas->pluck('ftn')->join(', ') }}</th>
</tr>
<tr>
<th>Address</th>
<th>{{ $o->access_mailer }}</th>
</tr>
</table>
<p>If the details are above are not correct, then please contact the (ZC) to have them corrected first.</p>
<p>Otherwise, if all is good, we'll send a netmail to <strong class="highlight">{{ $o->sysop }}</strong> at <strong class="highlight">{{ $o->access_mailer }}</strong></p> with further details.
<form class="needs-validation" method="post" autocomplete="off" action="{{ url('user/system/link') }}" novalidate>
@csrf
<input type="hidden" name="system_id" value="{{ $o->id }}">
<input type="hidden" name="name" value="{{ $o->name }}">
<div class="row pb-2">
<div class="col-12">
<input type="submit" name="action" class="btn btn-success" value="Link">
</div>
</div>
</form>