Enhancements to components, move simplemde over to PageAssets

This commit is contained in:
Deon George 2024-08-14 22:19:53 +10:00
parent d5d7f4f4a0
commit 83470c3ff5
8 changed files with 80 additions and 43 deletions

View File

@ -1,15 +1,15 @@
@if(isset($label))
<label {{ $attributes->only(['class']) }} for="{{ $id ?? $name }}">{{ $label }}</label>
@endisset
<div class="form-group">
@if(isset($label))
<label {{ $attributes->only(['class']) }} for="{{ $id ?? $name }}">{{ $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()
@endif
{{ $slot }}
<span class="invalid-feedback" role="alert">
<span class="invalid-feedback">
@error($old ?? $name)
{{ $message }}
@elseif(isset($feedback))
@ -20,4 +20,4 @@
@isset($helper)
<span class="input-helper">{{ $helper }}</span>
@endif
</div>
</div>

View File

@ -8,22 +8,24 @@
@endisset
@endif
@empty($groupby)
@foreach($options as $option)
@continue(! Arr::get($option,'value'))
<option value="{{ Arr::get($option,'id') }}" @selected(Arr::get($option,'id') == old($old ?? $name,$value ?? ''))>{{ Arr::get($option,'value') }}</option>
@endforeach
@isset($options)
@empty($groupby)
@foreach($options as $option)
@continue(! Arr::get($option,'value'))
<option value="{{ Arr::get($option,'id') }}" @selected(Arr::get($option,'id') == old($old ?? $name,$value ?? ''))>{{ Arr::get($option,'value') }}</option>
@endforeach
@else
@foreach($options->groupBy($groupby) as $group)
<optgroup label="{{ $groupby == 'active' ? (Arr::get($group->first(),$groupby) ? 'Active' : 'Not Active') : Arr::get($group->first(),$groupby) }}">
@foreach($group as $option)
@continue(! Arr::get($option,'value'))
<option value="{{ Arr::get($option,'id') }}" @selected(Arr::get($option,'id') == old($old ?? $name,$value ?? ''))>{{ Arr::get($option,'value') }}</option>
@endforeach
</optgroup>
@endforeach
@endempty
@else
@foreach($options->groupBy($groupby) as $group)
<optgroup label="{{ $groupby == 'active' ? (Arr::get($group->first(),$groupby) ? 'Active' : 'Not Active') : Arr::get($group->first(),$groupby) }}">
@foreach($group as $option)
@continue(! Arr::get($option,'value'))
<option value="{{ Arr::get($option,'id') }}" @selected(Arr::get($option,'id') == old($old ?? $name,$value ?? ''))>{{ Arr::get($option,'value') }}</option>
@endforeach
</optgroup>
@endforeach
@endempty
@endisset
</select>
</x-leenooks::form.base>

View File

@ -1,3 +1,43 @@
<x-leenooks::form.base {{ $attributes }}>
<textarea class="form-control {{ $classes ?? ''}} @error($old ?? $name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" @isset($placeholder)placeholder="{{ $placeholder }}"@endisset @readonly(isset($readonly)) @required(isset($required)) @disabled(isset($disabled))>{{ old($old ?? $name,$value ?? '') }}</textarea>
</x-leenooks::form.base>
<div class="form-group">
@if(isset($label))
<label {{ $attributes->only(['class']) }} for="{{ $id ?? $name }}">{{ $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 {{ $classes ?? ''}} @error($old ?? $name) is-invalid @enderror" id="{{ $id ?? $name }}" name="{{ $name }}" @isset($placeholder)placeholder="{{ $placeholder }}"@endisset @readonly(isset($readonly)) @required(isset($required)) @disabled(isset($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>
@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

View File

@ -6,7 +6,7 @@
<label class="custom-control-label" for="{{ $id ?? $name }}">{{ $label }}</label>
@endif
</div>
<span class="invalid-feedback" role="alert">
<span class="invalid-feedback">
@error($name)
{{ $message }}
@elseif(isset($feedback))

View File

@ -26,7 +26,7 @@
<!-- Sidebar Menu -->
<nav class="mt-2">
<ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
<ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" data-accordion="false">
<!-- Add icons to the links using the .nav-icon class with font-awesome or any other icon font library -->
@include('adminlte::layouts.partials.sidebarmenu')
</ul>

View File

@ -121,6 +121,16 @@ class PageAssets
],
]
],
'simplemde' => [
'base' => [
'css' => [
'//cdn.jsdelivr.net/simplemde/latest/simplemde.min.css',
],
'js' => [
'//cdn.jsdelivr.net/simplemde/latest/simplemde.min.js',
],
],
],
];
// Items to manage

View File

@ -42,6 +42,7 @@ class CustomBladeServiceProvider extends ServiceProvider
switch ($type) {
case 'datatables':
case 'select2':
case 'simplemde':
Log::alert(sprintf('Blade @css/@js for %s deprecicated, use @pa',$type));
break;
@ -147,21 +148,6 @@ class CustomBladeServiceProvider extends ServiceProvider
break;
case 'simplemde':
switch ($content) {
case 'css':
// Base
$css->put($type,'https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.css');
break;
case 'js':
// Base
$js->put($type,'https://cdn.jsdelivr.net/simplemde/latest/simplemde.min.js');
}
break;
case 'summernote':
switch ($content) {
case 'css':

View File

@ -4,13 +4,12 @@ namespace Leenooks\Providers;
use Illuminate\Foundation\AliasLoader;
use Illuminate\Support\Facades\Blade;
use Leenooks\Http\Middleware\GuestUser;
use Illuminate\Routing\Router;
use Illuminate\Support\Collection;
use Illuminate\Support\ServiceProvider;
use Leenooks\Http\Middleware\GuestUser;
use Leenooks\PageAssets;
use Leenooks\Traits\SingleOrFail;
use Orchestra\Support\Facades\Asset;
/**
* Class GuestUserServiceProvider.