Use components for form buttons and file notes

This commit is contained in:
Deon George 2025-01-15 18:32:41 +11:00
parent db4b90183f
commit 026b3f5a20
12 changed files with 101 additions and 129 deletions

View File

@ -11,14 +11,7 @@
<div class="h-100 bg-animation"> <div class="h-100 bg-animation">
<div class="d-flex h-100 justify-content-center align-items-center"> <div class="d-flex h-100 justify-content-center align-items-center">
<div class="mx-auto app-login-box col-md-8"> <div class="mx-auto app-login-box col-md-8">
@if(file_exists('login-note.html')) <x-file-note file="login-note.html"/>
<div class="mx-auto card text-white card-body bg-primary w-50">
<h5 class="text-white card-title"><i class="icon fa-2x fas fa-info pe-3"></i><span class="font-size-xlg">NOTE</span></h5>
<span class="w-100 pb-0">
{!! file_get_contents('login-note.html') !!}
</span>
</div>
@endif
<div class="modal-dialog w-100 mx-auto"> <div class="modal-dialog w-100 mx-auto">
<div class="modal-content"> <div class="modal-content">

View File

@ -0,0 +1,11 @@
@if($errors->any())
<div class="alert alert-danger">
<h4 class="alert-heading"><i class="fas fa-fw fa-thumbs-down"></i> Error?</h4>
<hr>
<ul style="list-style-type: square;">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif

View File

@ -0,0 +1,12 @@
@if(file_exists($file))
<div class="row pb-3">
<div class="col-12">
<div class="mx-auto card text-white card-body bg-primary w-50">
<h5 class="text-white card-title"><i class="icon fa-2x fas fa-info pe-3"></i><span class="font-size-xlg">NOTE</span></h5>
<span class="w-100 pb-0">
{!! file_get_contents($file) !!}
</span>
</div>
</div>
</div>
@endif

View File

@ -0,0 +1,9 @@
<button id="cancel" class="btn btn-sm btn-outline-dark">Cancel</button>
@section('page-scripts')
<script type="text/javascript">
$(document).ready(function() {
$('#cancel').on('click',()=>history.back());
});
</script>
@append

View File

@ -0,0 +1,9 @@
<button id="form-reset" class="btn btn-outline-danger">@lang('Reset')</button>
@section('page-scripts')
<script>
$(document).ready(function() {
$('#form-reset').on('click',()=>$('#{{$form}}')[0].reset());
});
</script>
@append

View File

@ -0,0 +1,9 @@
<button id="form-submit" class="btn btn-sm btn-success">@lang($action)</button>
@section('page-scripts')
<script type="text/javascript">
$(document).ready(function() {
$('#form-submit').on('click',()=>$('#{{$form}}')[0].submit());
});
</script>
@append

View File

@ -0,0 +1,7 @@
@if(session()->has('note'))
<div class="alert alert-info">
<h4 class="alert-heading"><i class="fas fa-fw fa-note-sticky"></i> Note:</h4>
<hr>
<p>{{ session()->pull('note') }}</p>
</div>
@endif

View File

@ -0,0 +1,12 @@
@if(session()->has('success'))
<div class="alert alert-success">
<h4 class="alert-heading"><i class="fas fa-fw fa-thumbs-up"></i> Success!</h4>
<hr>
<p>{{ session()->pull('success') }}</p>
<ul style="list-style-type: square;">
@foreach (session()->pull('updated') as $key => $values)
<li>{{ $key }}: {{ join(',',$values) }}</li>
@endforeach
</ul>
</div>
@endif

View File

@ -28,39 +28,11 @@
@endsection @endsection
@section('main-content') @section('main-content')
@if(session()->has('note')) <x-note/>
<div class="alert alert-info"> <x-success/>
<h4 class="alert-heading"><i class="fas fa-fw fa-note-sticky"></i> Note:</h4> <x-error/>
<hr>
<p>{{ session()->pull('note') }}</p>
</div>
@endif
@if(session()->has('success'))
<div class="alert alert-success">
<h4 class="alert-heading"><i class="fas fa-fw fa-thumbs-up"></i> Success!</h4>
<hr>
<p>{{ session()->pull('success') }}</p>
<ul style="list-style-type: square;">
@foreach (session()->pull('updated') as $key => $values)
<li>{{ $key }}: {{ join(',',$values) }}</li>
@endforeach
</ul>
</div>
@endif
<!-- @todo If we are redirected here, check old() and add back any attributes that were in the original submission --> <!-- @todo If we are redirected here, check old() and add back any attributes that were in the original submission -->
@if($errors->any())
<div class="alert alert-danger">
<h4 class="alert-heading"><i class="fas fa-fw fa-thumbs-down"></i> Error?</h4>
<hr>
<ul style="list-style-type: square;">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<div class="main-card mb-3 card"> <div class="main-card mb-3 card">
<div class="card-body"> <div class="card-body">
@ -116,14 +88,14 @@
</div> </div>
<div class="col-2"></div> <div class="col-2"></div>
</div> </div>
</form>
<div class="row d-none pt-3"> <div class="row d-none pt-3">
<div class="col-12 offset-sm-2 col-sm-4 col-lg-2"> <div class="col-12 offset-sm-2 col-sm-4 col-lg-2">
<span id="form-reset" class="btn btn-outline-danger">@lang('Reset')</span> <x-form.reset form="dn-edit"/>
<span id="form-submit" class="btn btn-success">@lang('Update')</span> <x-form.submit action="Update" form="dn-edit"/>
</div> </div>
</div> </div>
</form>
</div> </div>
<!-- Internal Attributes --> <!-- Internal Attributes -->
@ -223,14 +195,6 @@
} }
$(document).ready(function() { $(document).ready(function() {
$('#form-reset').click(function() {
$('#dn-edit')[0].reset();
});
$('#form-submit').click(function() {
$('#dn-edit')[0].submit();
});
$('#newattr').on('change',function(item) { $('#newattr').on('change',function(item) {
$.ajax({ $.ajax({
type: 'GET', type: 'GET',

View File

@ -52,13 +52,13 @@
</div> </div>
</div> </div>
</div> </div>
</form>
<div class="card-footer"> <div class="card-footer">
<span class="ms-auto"> <span class="ms-auto">
<button type="submit" class="btn btn-success btn-sm">Process</button> <x-form.submit action="Process" form="import-form"/>
</span> </span>
</div> </div>
</form>
</div> </div>
</div> </div>
</div> </div>

View File

@ -12,7 +12,7 @@
--}} --}}
@section('main-content') @section('main-content')
<div class="card card-solid"> <div class="card card-solid mb-3">
<div class="card-body"> <div class="card-body">
<div class="row"> <div class="row">
<div class="col-12 col-sm-4"> <div class="col-12 col-sm-4">
@ -38,19 +38,7 @@
</div> </div>
</div> </div>
@if(file_exists('home-note.html')) <x-file-note file="home-note.html"/>
<hr>
<div class="row">
<div class="col-12 offset-lg-2 col-lg-8">
<div class="mx-auto card text-white card-body bg-primary">
<h5 class="text-white card-title"><i class="icon fa-2x fas fa-info pe-3"></i><span class="font-size-xlg">NOTE</span></h5>
<span class="w-100 pb-0">
{!! file_get_contents('home-note.html') !!}
</span>
</div>
</div>
</div>
@endif
@endsection @endsection
@section('page-scripts') @section('page-scripts')

View File

@ -34,44 +34,15 @@
@endsection @endsection
@section('main-content') @section('main-content')
@if(session()->has('note')) <x-note/>
<div class="alert alert-info"> <x-success/>
<h4 class="alert-heading"><i class="fas fa-fw fa-note-sticky"></i> Note:</h4> <x-error/>
<hr>
<p>{{ session()->pull('note') }}</p>
</div>
@endif
@if(session()->has('success'))
<div class="alert alert-success">
<h4 class="alert-heading"><i class="fas fa-fw fa-thumbs-up"></i> Success!</h4>
<hr>
<p>{{ session()->pull('success') }}</p>
<ul style="list-style-type: square;">
@foreach (session()->pull('updated') as $key => $values)
<li>{{ $key }}: {{ join(',',$values) }}</li>
@endforeach
</ul>
</div>
@endif
@if($errors->any())
<div class="alert alert-danger">
<h4 class="alert-heading"><i class="fas fa-fw fa-thumbs-down"></i> Error?</h4>
<hr>
<ul style="list-style-type: square;">
@foreach ($errors->all() as $error)
<li>{{ $error }}</li>
@endforeach
</ul>
</div>
@endif
<div class="main-card mb-3 card"> <div class="main-card mb-3 card">
<form id="dn-update" method="POST" class="needs-validation" action="{{ url('entry/update/commit') }}" novalidate> <form id="dn-update" method="POST" class="needs-validation" action="{{ url('entry/update/commit') }}" novalidate>
@csrf @csrf
<input type="hidden" name="dn" value="{{ $o->getDNSecure() }}"> <input type="hidden" name="dn" value="{{ $o->getDNSecure() }}">
<div class="card-body"> <div class="card-body">
<div class="row"> <div class="row">
<div class="col-12 col-lg-6 col-xl-4 mx-auto pt-3"> <div class="col-12 col-lg-6 col-xl-4 mx-auto pt-3">
@ -104,28 +75,15 @@
</table> </table>
</div> </div>
</div> </div>
<div class="row pt-3">
<div class="col-12 offset-sm-2 col-sm-4 col-lg-2 mx-auto">
<span id="form-reset" class="btn btn-outline-danger">@lang('Reset')</span>
<span id="form-submit" class="btn btn-success">@lang('Update')</span>
</div>
</div>
</div> </div>
</form> </form>
<div class="row p-3">
<div class="col-12 offset-sm-2 col-sm-4 col-lg-2 mx-auto">
<x-form.cancel/>
<x-form.submit action="Update" form="dn-update"/>
</div>
</div>
</div> </div>
@endsection @endsection
@section('page-scripts')
<script type="text/javascript">
$(document).ready(function() {
$('#form-reset').click(function() {
$('#dn-update')[0].reset();
});
$('#form-submit').click(function() {
$('#dn-update')[0].submit();
});
});
</script>
@append