enhance components, add mailtemplate, add traits for translations, for stats

This commit is contained in:
Ludovic CANDELLIER
2023-02-13 22:52:39 +01:00
parent f2f4788ce1
commit 0ecc7c73c7
32 changed files with 891 additions and 277 deletions

View File

@@ -1,12 +1,10 @@
@extends('layout.index', [
'title' => __('Core.mail_templates.title'),
'subtitle' => __('Core.mail_templates.list'),
'breadcrumb' => [
]
'breadcrumb' => []
])
@section('content')
<x-card>
@include('components.datatable', [
'route' => route('Admin.Core.Mail.MailTemplate.index'),
@@ -23,13 +21,14 @@
@component('components.layout.modal-filters', ['title' => 'Filters', 'id' => 'modal-mail_templates-filters'])
@include('admin.Core.Mail.MailTemplate.partials.filters', ['model' => 'mail_templates'])
@endcomponent
@endsection
@include('load.form.datepicker')
@include('load.form.select2')
@include('load.form.editor')
@include('load.form.toggle')
@include('load.form.upload.fileinput')
@include('load.layout.modal')
@push('js')
<script>

View File

@@ -21,16 +21,11 @@
'required' => true,
])
</div>
<div class="col-4">
<div class="col-6">
<div id="mail_template-vars">
@include('admin.Core.Mail.MailTemplate.partials.vars', ['vars' => $mail_template['vars'] ?? []])
</div>
</div>
<div class="col-2 text-right">
<label>@lang('Core.change_to')</label><br/>
<img id="lang_en" class="lang" data-lang="en" role="button" src="{{ asset('vendor/blade-flags/language-en.svg') }}" width="32" height="32"/>
<img id="lang_fr" class="lang d-none" data-lang="fr" role="button" src="{{ asset('vendor/blade-flags/language-fr.svg') }}" width="32" height="32"/>
</div>
</div>
<div id="mode_fr" class="">
@@ -67,42 +62,6 @@
</div>
</div>
<div id="mode_en" class="d-none">
<div class="row mb-3">
<div class="col-6">
@include('components.form.input', [
'name' => 'subject[en]',
'value' => $mail_template['subject_translations']['en'] ?? '',
'label' => __('Core.subject'),
'required' => true,
])
</div>
<div class ="col-6">
</div>
</div>
<div class="row mb-3">
<div class="col-12">
@include('components.form.editor', [
'name' => 'html_template[en]',
'value' => $mail_template['html_template_translations']['en'] ?? '',
'label' => 'HTML',
'rows' => 10,
])
</div>
</div>
<div class="row mb-3">
<div class="col-12">
@include('components.form.textarea', [
'name' => 'text_template[en]',
'value' => $mail_template['text_template_translations']['en'] ?? '',
'label' => 'Text',
])
</div>
</div>
</div>
{{ Form::close() }}

View File

@@ -1,6 +1,6 @@
<div class="row mb-3">
<div class="col-4">
<div class="row h-100 products @if($article_nature == 1) shadow2 @endif" data-id="semences">
<div class="row btn h-100 products @if($article_nature == 1) shadow2 @endif" data-id="semences">
<div class="col-lg-6 col-xs-12">
<img src="/img/article_natures/semences.png" class="img-fluid">
</div>
@@ -8,7 +8,7 @@
</div>
</div>
<div class="col-4">
<div class="row h-100 products @if($article_nature == 2) shadow2 @endif" data-id="plants">
<div class="row btn h-100 products @if($article_nature == 2) shadow2 @endif" data-id="plants">
<div class="col-lg-6 col-xs-12">
<img src="/img/article_natures/plants.png" class="img-fluid" class="img-fluid">
</div>
@@ -16,7 +16,7 @@
</div>
</div>
<div class="col-4">
<div class="row h-100 products @if($article_nature == 3) shadow2 @endif" data-id="legumes">
<div class="row btn h-100 products @if($article_nature == 3) shadow2 @endif" data-id="legumes">
<div class="col-lg-6 col-xs-12">
<img src="/img/article_natures/legumes.png" class="img-fluid" class="img-fluid">
</div>

View File

@@ -1,8 +1,19 @@
@include('load.form.datepicker')
@if (($readonly ?? false) || ($disabled ?? false))
@include('components.form.input')
@else
@include('components.form.label')
<div class="input-group date" data-target-input="nearest">
@include('components.form.input', [
'type' => 'text',
'class' => $class ?? ' datepicker',
'meta' => 'data-target="#' . ($id_name ?? str_slug($name, '-')) . '"',
'placeholder' => $placeholder ?? App\Repositories\Core\DateTime::getLocaleFormatDate(),
'label' => false,
])
<div class="input-group-append" data-target="#{{ $id_name ?? str_slug($name, '-') }}" data-toggle="datetimepicker">
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
</div>
</div>
@endif
<div class="input-group date" data-target-input="nearest">
@include('components.form.input', ['class' => 'datepicker', 'meta' => 'data-target="#'.str_slug($name).'"', 'placeholder' => App\Repositories\Core\DateTime::getLocaleFormatDate() ])
<div class="input-group-append" data-target="#{{ str_slug($name) }}" data-toggle="datetimepicker">
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
</div>
</div>
@include('load.form.datepicker')

View File

@@ -0,0 +1,11 @@
@include('load.form.daterangepicker')
<div class="input-group date {{ $classGroup ?? '' }}" data-target-input="nearest">
@include('components.form.input', [
'class' => ($class ?? '') . ' daterangepickerItems',
'placeholder' => $placeholder ?? App\Repositories\Core\DateTime::getLocaleFormatDate(),
])
<div class="input-group-append">
<div class="input-group-text"><i class="fa fa-calendar"></i></div>
</div>
</div>

View File

@@ -1,19 +1,9 @@
<textarea
name="{{ $name }}"
@if (isset($id_name))id="{{ $id_name }}"@endif
class="editor form-control @if (isset($class)){{ $class }}@endif"
@if (isset($rows)) rows="{{ $rows }}"@endif
>@if (isset($value)){{ $value }}@endif</textarea>
@include('components.form.textarea', [
'rows' => $rows ?? 3,
'class' => 'editor ' . ($class ?? ''),
])
@if(!defined('LOAD_EDITOR'))
@if(!defined('LOAD_EDITOR'))
@include('load.form.editor')
@push('js')
<script>
$(function() {
initEditor();
});
</script>
@endpush
@endif

View File

@@ -1,13 +1,13 @@
@include('components.form.label')
<div class="input-group">
@include('components.form.input')
@include('components.form.input', ['label' => false])
<div class="input-group-append">
<button class="btn btn-outline-secondary dropdown-toggle" type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
<i class="fa fa-globe"></i>
</button>
<div class="dropdown-menu">
@if (is_array($translations))
@if (is_array($translations ?? false))
@foreach ($translations as $lang => $translation)
<a class="dropdown-item" href="#">{{ $lang }} : {{ $translation }}</a>
@endforeach

View File

@@ -0,0 +1,51 @@
@if(empty($name))
<code>
&lt;x-boilerplate::input>
The name attribute has not been set
</code>
@else
<div class="form-group{{ isset($groupClass) ? ' '.$groupClass : '' }}"{!! isset($groupId) ? ' id="'.$groupId.'"' : '' !!}>
@isset($label)
<label>{!! __($label) !!}</label>
@endisset
@if($prepend || $prependText || $append || $appendText)
<div class="input-group">
@endif
@if($prepend || $prependText)
<div class="input-group-prepend">
@if($prepend)
{!! $prepend !!}
@else
<span class="input-group-text">{!! $prependText !!}</span>
@endif
</div>
@endif
@if($type === 'password')
{!! Form::password($name, array_merge(['class' => 'form-control'.$errors->first($name,' is-invalid').(isset($class) ? ' '.$class : '')], $attributes)) !!}
@elseif($type === 'file')
{!! Form::file($name, array_merge(['class' => 'form-control-file'.$errors->first($name,' is-invalid').(isset($class) ? ' '.$class : '')], $attributes)) !!}
@elseif($type === 'select')
{!! Form::select($name, $options ?? [], old($name, $value ?? ''), array_merge(['class' => 'form-control'.$errors->first($name,' is-invalid').(isset($class) ? ' '.$class : '')], $attributes)) !!}
@else
{!! Form::{$type ?? 'text'}($name, old($name, $value ?? ''), array_merge(['class' => 'form-control'.$errors->first($name,' is-invalid').(isset($class) ? ' '.$class : '')], $attributes)) !!}
@endif
@if($append || $appendText)
<div class="input-group-append">
@if($append)
{!! $append !!}
@else
<span class="input-group-text">{!! $appendText !!}</span>
@endif
</div>
@endif
@if($prepend || $prependText || $append || $appendText)
</div>
@endif
@if($help ?? false)
<small class="form-text text-muted">@lang($help)</small>
@endif
@error($name)
<div class="error-bubble"><div>{{ $message }}</div></div>
@enderror
</div>
@endif

View File

@@ -1,17 +1,18 @@
@include('components.form.label')
<div class="input-group">
@include('components.form.input')
@include('components.form.input', ['label' => false])
<div class="input-group-append">
<div class="input-group-text btn btn-{{ $class ?? '' }}" role="button"><i class="fa fa-{{ $icon ?? '' }}"></i></div>
</div>
</div>
@if (isset($click))
@isset($click)
@push('js')
<script>
$('.btn-{{ $class ?? '' }}').off().click(function() {
var value = $(this).closest('.input-group').find('input').val();
console.log(value);
});
</script>
@endpush
@endif
@endisset

View File

@@ -1,12 +1,17 @@
@include('components.form.label')
<input type="number" name="{{ $name }}" id="{{ $id_name ?? str_slug($name,'-') }}" class="form-control {{ $class ?? ''}}" value="{{ $value ?? ''}}"
@if (isset($data_id))
data-id="{{ $data_id }}"
@endif
@if (isset($required))
required="required"
@endif
{{ isset($min) ? 'min="' . $min . '"' : ''}}
{{ isset($max) ? 'max="' . $max . '"' : ''}}
{{ isset($step) ? 'step="' . $step . '"' : ''}}
{{ isset($placeholder) ? 'placeholder="' . $placeholder. '"' : ''}}
>
@if ($required ?? false) required @endif
@if ($disabled ?? false) disabled @endif
@if ($readonly ?? false) readonly @endif
@if ($autofocus ?? false) autofocus @endif
@if ($size ?? false) size="{{ $size }}" @endif
@if ($autocomplete ?? false) autocomplete="{{ $autocomplete }}" @endif
@if ($min ?? false) min={{ $min }} @endif
@if ($max ?? false) max={{ $max }} @endif
@if ($step ?? false) step={{ $step }} @endif
@if ($formid ?? false) form="{{ $formid }}" @endif
@if ($mask ?? false) data-inputmask="'mask': '{{ $mask }}'" @endif
@if ($pattern ?? false) pattern="{{ $pattern }}" @endif
@if ($placeholder ?? false) placeholder="{{ $placeholder }}" @endif
{!! $meta ?? '' !!} >

View File

@@ -1,7 +1,9 @@
@include('components.form.label')
<div class="input-group">
@include('components.form.input', ['type' => 'number', 'meta' => "step = '.01'"])
@include('components.form.input', ['type' => 'number', 'step' => '.01', 'label' => false])
<div class="input-group-append">
<button class="btn bg-light" type="button" aria-haspopup="false" aria-expanded="false">
%

View File

@@ -1 +1 @@
@include('components.form.input', ['mask' => '99.99.99.99.99'])
@include('components.form.input')

View File

@@ -0,0 +1,8 @@
<div class="input-group">
<div class="input-group-prepend">
<span class="input-group-text"><i class="fa fa-search"></i></span>
</div>
<input type="text" name="{{ $name }}" class="form-control search-btn" placeholder="{{ __('search') }}" value="">
</div>

View File

@@ -1,5 +1,7 @@
@include('components.form.label')
<div class="input-group">
@include('components.form.input', ['class' => 'url'])
@include('components.form.input', ['class' => 'url', 'label' => false])
<div class="input-group-append">
@if (isset($with_download) && $with_download)
<div class="input-group-text btn btn-web" role="button"><i class="fa {{ (isset($status) && $status) ? 'fa-check green' : 'fa-download' }}"></i></div>

View File

@@ -1,16 +1,31 @@
<select name="{{ $name }}"
@if (isset($id_name))id="{{ $id_name }}"@endif
class="form-control {{ $class ?? null }}"
@if (isset($style))style="{{ $style }}" @endif
@if (isset($meta)) {{ $meta }} @endif
@if (isset($required))required="required"@endif
@if (isset($disabled) && $disabled)disabled="disabled"@endif
@if (isset($multiple))multiple="multiple"@endif
@include('components.form.label')
@if (($disabled ?? false) || ($readonly ?? false))
@include('components.form.input', ['type' => 'hidden', 'label' => false])
@endif
<select name="{{ $name }}" class="form-control {{ $class ?? null }}"
@if ($id_name ?? false) id="{{ $id_name }}" @endif
@if ($style ?? false) style="{{ $style }}" @endif
@if ($required ?? false) required @endif
@if ($readonly ?? false) readonly @endif
@if ($disabled ?? false) disabled @endif
@if ($multiple ?? false) multiple @endif
@if ($size ?? false) size="{{ $size }}" @endif
@if ($dataId ?? false) data-id="{{ $dataId }}" @endif
{{ $meta ?? null}}
>
@if (isset($with_empty))
<option value=''>{{ $with_empty }}</option>
@isset($with_empty)
<option value="{{ $with_empty_value ?? '' }}">{{ $with_empty }}</option>
@endisset
@if ($tree ?? false)
@include('components.form.options.options-tree')
@else
@if ($multiple ?? false)
@include('components.form.options.options-multiple')
@else
@include('components.form.options')
@endif
@endif
@include('components.form.options')
</select>
</select>

View File

@@ -1 +1,16 @@
@include('components.form.select', ['class' => 'duallist', 'multiple' => true])
@if ($disabled ?? false)
@if (count($list ?? []))
<ul>
@foreach($list as $key => $item)
@if (in_array($key, $values))
<li>{{ $item }}</li>
@endif
@endforeach
</ul>
@endif
@else
@include('components.form.select', [
'class' => 'duallist',
'multiple' => true,
])
@endif

View File

@@ -0,0 +1 @@
@include('components.form.select', ['class' => 'duallist', 'tree' => true])

View File

@@ -1,13 +1 @@
<select
name="{{ $name }}"
@if (isset($id_name))id="{{ $id_name }}"@endif
class="@if (isset($class)){{ $class }} @else form-control @endif"
@if (isset($style))style="{{ $style }}" @endif
@if (isset($required))required="required"@endif
@if (isset($multiple))multiple="multiple"@endif
>
@if (isset($with_empty))
<option>{{ $with_empty }}</option>
@endif
@include('components.form.options.options-tree')
</select>
@include('components.form.select', ['tree' => true])

View File

@@ -1,6 +1,14 @@
<textarea
name="{{ $name }}"
@if (isset($id_name))id="{{ $id_name }}"@endif
@include('components.form.label')
<textarea name="{{ $name }}"
@isset($id_name)id="{{ $id_name }}"@endisset
class="form-control {{ $class ?? null }}"
@if (isset($rows)) rows="{{ $rows }}"@endif
>{{ $value ?? null }}</textarea>
@isset($rows) rows="{{ $rows }}"@endisset
@if ($style ?? false) style="{{ $style }}" @endif
@if ($disabled ?? false) disabled @endif
@if ($required ?? false) required @endif
@if ($readonly ?? false) readonly @endif
@if ($autofocus ?? false) autofocus @endif
@if ($maxlength ?? false) maxlength="{{ $maxlength }}" @endif
{{ $meta ?? null}}
>{{ $value ?? ''}}</textarea>

View File

@@ -9,17 +9,17 @@
<script>
$.fn.fileinput.defaults.language = '{{ App::getLocale() }}';
</script>
<script>
function initUpload(selector) {
var selector = '.file';
$(selector).fileinput({
showCaption: false,
dropZoneEnabled: false,
showUpload: false,
});
}
</script>
@endif
@endpush
<script>
function initUpload(selector) {
var selector = '.file';
$(selector).fileinput({
showCaption: false,
dropZoneEnabled: false,
showUpload: false,
});
}
</script>
@endpush
@php(define('LOAD_FILEINPUT', true))
@endif

View File

@@ -1,16 +1,15 @@
@if(!defined('LOAD_CHEVRON'))
@push('scripts')
<script>
function initChevron(sel) {
var selector = (typeof(sel) == 'undefined') ? '.card-header .btn-link' : sel;
$(selector).click(function() {
$(this).find('i').toggleClass('fa-chevron-right fa-chevron-down')
});
}
</script>
@component('boilerplate::minify')
<script>
function initChevron(sel) {
var selector = (typeof(sel) == 'undefined') ? '.card-header .btn-link' : sel;
$(selector).click(function() {
$(this).find('i').toggleClass('fa-chevron-right fa-chevron-down')
});
}
</script>
@endcomponent
@endpush
@php(define('LOAD_CHEVRON', true))
@endif
@endif

View File

@@ -1,105 +1,205 @@
@if(!defined('LOAD_MODAL'))
@push('js')
@component('boilerplate::minify')
<script>
<script>
function openModal(title, form_id, url_open, url_save, callback, size, no_confirm, buttons, callback_after_loaded) {
var status = 0;
var dialog = bootbox.dialog({
title: title,
message: '<p><i class="fa fa-spin fa-spinner"></i> {{ __('loading') }} ...</p>',
size: size ? size : 'large',
scrollable: true,
buttons: buildModalButtons(form_id, no_confirm, buttons)
});
dialog.init(function() {
$.get(url_open, function(data) {
dialog.find('.bootbox-body').html(data);
if (callback_after_loaded) {
eval(callback_after_loaded);
}
if (typeof(url_save) !== 'undefined') {
handlePostModal(form_id,url_save, callback);
}
});
});
}
// bootbox.setLocale('{{ App::getLocale() }}');
function changeModalContent(dialog, url, callback) {
dialog.init(function() {
$.get(url, function(data) {
dialog.find('.bootbox-body').html(data);
if (callback) {
eval(callback);
}
});
});
}
function openModal(title, form_id, url_open, url_save, callback, size, no_confirm, options) {
var status = 0;
function viewModal(url, size, title) {
var dialog = bootbox.dialog({
title: title ? title : 'Web viewer',
message: '<iframe style="border:0;" src="' + url + '" height="400" width="100%"></iframe>',
size: size ? size : 'xl',
scrollable: true,
});
}
if (typeof(options) != 'undefined') {
var className = (typeof(options['className']) == 'undefined') ? '' : options['className'];
var onHide = (typeof(options['onHide']) == 'undefined') ? false : options['onHide'];
var onHidden = (typeof(options['onHidden']) == 'undefined') ? false : options['onHidden'];
var onShow = (typeof(options['onShow']) == 'undefined') ? false : options['onShow'];
var onShown = (typeof(options['onShown']) == 'undefined') ? false : options['onShown'];
var onPostModal = (typeof(options['onPostModal']) == 'undefined') ? false : options['onPostModal'];
}
function viewWindow(url, size, title) {
var width = (size == 'sm') ? 400 : 600;
var title = title ? title : 'Web viewer';
window.open(url,title,"menubar=no, status=no, scrollbars=no, menubar=no, width=" + width + ", height=400");
}
var dialog = bootbox.dialog({
title: title,
message: '<p><i class="fa fa-spin fa-spinner"></i> {{ __('loading') }} ...</p>',
size: size ? size : 'large',
scrollable: true,
className: className,
onHide: function(e) {
// console.log(status);
if (onHide) {
eval(onHide);
}
},
onHidden: function(e) {
// console.log(status);
if (onHidden) {
eval(onHidden);
}
},
onShow: function(e) {
var modal = e.target.firstChild;
// console.log(modal);
// console.log($('.close'));
if (onShow) {
eval(onShow);
}
},
onShown: function(e) {
var modal = e.target.firstChild;
// console.log(modal);
// console.log($('.close'));
if (onShown) {
eval(onShown);
}
},
buttons: buildModalButtons(form_id, no_confirm, callback)
});
function buildModalButtons(form_id, no_confirm, buttons) {
if (!no_confirm) {
var buttons = {
cancel: {
label: '{{ __('Annuler') }}',
className: 'btn-secondary'
},
confirm: {
label: '{{ __('Sauver') }}',
className: 'btn-success',
callback: function() {
submitModal(form_id);
}
},
};
}
return buttons;
}
changeModalContent(dialog, url_open);
function submitModal(form_id) {
if (typeof(tinyMCE) != 'undefined') {
tinyMCE.triggerSave();
}
$('form ' + form_id).submit();
status = 1;
}
if (! no_confirm) {
handlePostModal(form_id, url_save, callback, onPostModal);
}
return dialog;
}
function handlePostModal(form_id, url_save, callback) {
$('form ' + form_id).submit(function(e) {
e.preventDefault();
var formData = new FormData(this);
$.ajax({
url: url_save,
type: 'POST',
data: formData,
success: function (data) {
if (callback) {
eval(callback);
}
},
cache: false,
contentType: false,
processData: false
});
});
}
</script>
function changeModalContent(dialog, url, callback) {
dialog.init(function() {
$.get(url, function(data) {
dialog.find('.bootbox-body').html(data);
});
});
}
function viewModal(url, size, title) {
var dialog = bootbox.dialog({
title: title ? title : 'Web viewer',
message: '<iframe style="border:0;" src="' + url + '" height="400" width="100%"></iframe>',
size: size ? size : 'xl',
scrollable: true,
});
}
function viewWindow(url, size, title) {
var width = (size == 'sm') ? 400 : 600;
var title = title ? title : 'Web viewer';
window.open(url, title, "menubar=no, status=no, scrollbars=no, menubar=no, width=" + width + ", height=400");
}
function buildModalButtons(form_id, no_confirm, callback) {
return no_confirm ? '' : {
cancel: {
label: '<i class="fa fa-ban"></i> {{ __("Core.cancel") }}',
className: 'btn-secondary'
},
confirm: {
label: '<i class="fa fa-save"></i> {{ __("Core.save") }}',
className: 'btn-success',
callback: function() {
return submitModal(form_id, callback);
}
},
};
}
function submitModal(form_id, callback) {
if (typeof(tinyMCE) != 'undefined') {
tinyMCE.triggerSave();
}
var $form = $(form_id);
console.log('submitModal ' + form_id);
if ($form.valid()) {
deactivateButton($form);
console.log('check valid');
$form.submit();
}
return false;
}
function handlePostModal(form_id, url_save, callback, onPostModal) {
// console.log('handlePostModal');
// initValidator();
var response = false;
$(form_id).submit(function(e) {
e.preventDefault();
console.log('handlepostmodal submit');
if (onPostModal) {
response = eval(onPostModal);
} else {
response = postModal(form_id, url_save, callback);
}
// console.log(response);
});
return response;
}
function postModal(form_id, url_save, callback) {
console.log('postModal');
console.log(form_id);
console.log(callback);
var ret = false;
var $form = $(form_id);
var myForm = document.getElementById(form_id.substring(1));
$.ajax({
url: url_save,
type: 'POST',
data: new FormData(myForm),
success: function (data) {
if (callback) {
eval(callback);
}
if (!data.error) {
bootbox.hideAll();
}
},
crossDomain: true,
headers: {
"accept": "application/json",
"Access-Control-Allow-Origin":"*"
},
cache: false,
contentType: false,
processData: false
});
return ret;
}
function openWindow(url, target) {
target = (typeof(target) == 'undefined') ? '_blank' : target;
if (target == '_blank') {
var anchor = document.createElement('a');
anchor.href = url;
anchor.target = "_blank";
anchor.click();
} else {
window.location = url;
}
}
function reactivateButton($form) {
console.log('activateButton');
var $button = $form.closest('.modal-content').find('.bootbox-accept').first();
if ($button.attr("disabled")) {
$button.prop("disabled", false);
$button.html("<i class='fa fa-save'></i> {{ __('Core.save') }}");
}
}
function deactivateButton($form) {
console.log('deactivateButton');
console.log($form);
var $button = $form.closest('.modal-content').find('.bootbox-accept').first();
console.log($button);
$button.prop("disabled", true);
$button.html("<i class='fa fa-spinner fa-spin'></i> {{ __('Core.processing') }}");
}
</script>
@endcomponent
@endpush
@php(define('LOAD_MODAL', true))
@endif
@endif