Change all notes inputs to use notes component

This commit is contained in:
Deon George 2024-12-06 21:30:44 +11:00
parent e9b5783945
commit ec139b79a2
9 changed files with 87 additions and 58 deletions

12
public/css/fixes.css vendored
View File

@ -23,6 +23,18 @@ select2-container--bootstrap-5 .select2-selection--multiple .select2-selection__
font-size: 90%; font-size: 90%;
} }
/* SimpleMDE Toolbar fixes */
.editor-toolbar {
background-color: #fff;
color: #000;
opacity: 1;
}
div.CodeMirror-wrap.form-control.is-invalid {
border-top-left-radius: 0;
border-top-right-radius: 0;
}
/* Bootstrap 5 fixes */ /* Bootstrap 5 fixes */
/* select import, round the right side */ /* select import, round the right side */
.input-group .form-select { .input-group .form-select {

View File

@ -0,0 +1,44 @@
<div class="form-group">
@if(isset($label))
<label {{ $attributes->only(['class'])->merge(['class'=>'form-label']) }} for="{{ $id ?? $name }}">{!! html_entity_decode($label) !!}</label>
@endisset
<div class="input-group has-validation">
@if(isset($icon) || isset($prepend))
<div class="input-group-prepend">
<span class="input-group-text">@isset($icon)<i class="fas fa-fw {{ $icon }}"></i>@endisset @isset($prepend){!! $prepend !!}@endisset</span>
</div>
@endif
<div class="w-100">
<textarea class="form-control {{ $class ?? ''}} @error((! empty($old)) ? $old : $name) is-invalid @enderror" rows="{{ (($l=count(explode("\n",$value ?? ''))) < ($rows ?? 5) ? $rows : (($l > ($y=($max ?? 25))) ? $y : $l)) }}" id="{{ $id ?? $name }}" name="{{ $name }}" @isset($placeholder)placeholder="{{ $placeholder }}"@endisset @readonly(isset($readonly) && $readonly) @required(isset($required) && $required) @disabled(isset($disabled) && $disabled)>{{ old($old ?? $name,$value ?? '') }}</textarea>
<span class="invalid-feedback">
@error($old ?? $name)
{{ $message }}
@elseif(isset($feedback))
{{ $feedback }}
@enderror
</span>
</div>
</div>
@isset($helper)
<span class="input-helper">{{ $helper }}</span>
@endif
</div>
@if(isset($simplemde) && $simplemde)
@pa(simplemde)
@section('page-scripts')
<script type="text/javascript">
$(document).ready(function() {
new SimpleMDE({
element: $('#{{ $id ?? $name }}')[0],
forceSync: true
});
@error($old ?? $name)
$('div.CodeMirror-wrap').addClass('form-control is-invalid');
@enderror
});
</script>
@append
@endif

View File

@ -1,4 +1,5 @@
<!-- $o=Domain::class --> <!-- $o=Domain::class -->
@use(Illuminate\Support\Facades\Gate)
@use(App\Models\Echoarea) @use(App\Models\Echoarea)
@extends('layouts.app') @extends('layouts.app')
@ -149,8 +150,7 @@
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<label for="notes" class="form-label">Notes</label> <x-form.notes name="notes" label="Notes" rows=3 placeholder="Notes..." :value="$o->notes" :disabled="Gate::denies('admin',$o)"/>
<textarea class="form-control" rows=3 id="notes" name="notes" placeholder="Notes..." @cannot('admin',$o)disabled @endcannot>{{ old('notes',$o->notes) }}</textarea>
</div> </div>
</div> </div>
</div> </div>
@ -164,10 +164,7 @@
<div class="row"> <div class="row">
<div class="col-12" > <div class="col-12" >
<label for="homepage" class="form-label">Home Page Text</label> <x-form.notes name="homepage" label="Home Page Text" rows=5 placeholder="Home Page..." :value="$o->homepage" :disabled="Gate::denies('admin',$o)" :simplemde="true"/>
<div style="background-color: #fff;color: #000;">
<textarea class="form-control" rows=5 id="homepage" name="homepage" placeholder="Home Page..." @cannot('admin',$o)disabled @endcannot>{{ old('homepage',$o->homepage) }}</textarea>
</div>
</div> </div>
</div> </div>
</div> </div>
@ -184,11 +181,3 @@
</div> </div>
</form> </form>
@endsection @endsection
@pa(simplemde)
@section('page-scripts')
<script type="text/javascript">
var simplemde = new SimpleMDE({ element: $("#homepage")[0] });
</script>
@append

View File

@ -129,8 +129,7 @@
@can('admin',$o) @can('admin',$o)
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<label for="notes" class="form-label">Notes</label> <x-form.notes name="notes" label="Notes" rows=3 placeholder="Notes..." :value="$o->notes"/>
<textarea class="form-control" rows=3 name="notes" placeholder="Notes..." @cannot('admin',$o)disabled @endcannot>{{ old('notes',$o->notes) }}</textarea>
</div> </div>
</div> </div>

View File

@ -130,8 +130,7 @@
@can('admin',$o) @can('admin',$o)
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<label for="notes" class="form-label">Notes</label> <x-form.notes name="notes" label="Notes" rows=3 placeholder="Notes..." :value="$o->notes"/>
<textarea class="form-control" rows=3 name="notes" placeholder="Notes..." @cannot('admin',$o)disabled @endcannot>{{ old('notes',$o->notes) }}</textarea>
</div> </div>
</div> </div>

View File

@ -19,11 +19,11 @@
@csrf @csrf
<div class="row pt-0"> <div class="row pt-0">
<div class="col-2"> <div class="col-3">
<x-form.select name="to" icon="bi-robot" label="To" feedback="To name required" :value="($x=collect(config('fido.areafilefix')))->first()" :options="$x->map(fn($item)=>['id'=>$item,'value'=>$item])" required/> <x-form.select name="to" icon="bi-robot" label="To" feedback="To name required" :value="($x=collect(config('fido.areafilefix')))->first()" :options="$x->map(fn($item)=>['id'=>$item,'value'=>$item])" required/>
</div> </div>
<div class="offset-2 col-3"> <div class="offset-1 col-3">
<x-form.select name="tftn_id" icon="bi-ui-radios" label="Uplink Address" feedback="Uplink address required" :value="($x=collect(config('fido.areafilefix')))->first()" :options="$o->akas->where('zone_id',$zo->id)->map(fn($item)=>['id'=>$item->id,'value'=>$item->ftn])" required/> <x-form.select name="tftn_id" icon="bi-ui-radios" label="Uplink Address" feedback="Uplink address required" :value="($x=collect(config('fido.areafilefix')))->first()" :options="$o->akas->where('zone_id',$zo->id)->map(fn($item)=>['id'=>$item->id,'value'=>$item->ftn])" required/>
</div> </div>
</div> </div>
@ -53,15 +53,7 @@
<div class="row"> <div class="row">
<!-- Message --> <!-- Message -->
<div class="col-12"> <div class="col-12">
<label for="msg" class="form-label">Message</label> <x-form.notes name="msg" label="Message" rows=10 placeholder="Message..." helper="Area/filefix commands are required"/>
<textarea class="form-control @error('msg') is-invalid @enderror" rows=10 name="msg" placeholder="Message..." required>{{ old('msg') }}</textarea>
<span class="invalid-feedback" role="alert">
@error('msg')
{{ $message }}
@else
Area/filefix commands are required
@enderror
</span>
</div> </div>
</div> </div>

View File

@ -403,8 +403,7 @@
<div class="row"> <div class="row">
<!-- Notes --> <!-- Notes -->
<div class="col-12"> <div class="col-12">
<label for="notes" class="form-label">Notes</label> <x-form.notes name="notes" label="Notes" rows=3 placeholder="Notes..." :value="$o->notes"/>
<textarea class="form-control" rows=3 id="notes" name="notes" placeholder="Notes...">{{ old('notes',$o->notes) }}</textarea>
</div> </div>
</div> </div>
@endcan @endcan

View File

@ -1,4 +1,6 @@
<!-- $o=User::class --> <!-- $o=User::class -->
@use(Illuminate\Support\Facades\Gate)
@extends('layouts.app') @extends('layouts.app')
@section('htmlheader_title') @section('htmlheader_title')
@ -133,13 +135,7 @@
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<label for="pgp_pubkey" class="form-label">PGP Public Key</label> <x-form.notes name="pgp_pubkey" label="PGP Public Key" rows=5 max=25 placeholder="PGP Public Key..." :value="$o->pgp_pubkey" :disabled="Gate::denies('update',$o)"/>
<textarea class="form-control @error('pgp_pubkey')is-invalid @enderror" rows=3 id="pgp_pubkey" name="pgp_pubkey" placeholder="PGP Public Key..." @cannot('update',$o)disabled @endcannot>{{ old('pgp_pubkey',$o->pgp_pubkey) }}</textarea>
<span class="invalid-feedback" role="alert">
@error('pgp_pubkey')
{{ $message }}
@enderror
</span>
</div> </div>
</div> </div>

View File

@ -138,8 +138,7 @@
<div class="row"> <div class="row">
<div class="col-12"> <div class="col-12">
<label for="notes" class="form-label">Notes</label> <x-form.notes name="notes" label="Notes" rows=3 placeholder="Notes..." :value="$o->notes" :disabled="Gate::denies('admin',$o)"/>
<textarea class="form-control" rows=3 name="notes" placeholder="Notes..." @cannot('admin',$o)disabled @endcannot>{{ old('notes',$o->notes) }}</textarea>
</div> </div>
</div> </div>