add methods to get icon on article natures

This commit is contained in:
Ludovic CANDELLIER
2023-09-12 23:00:36 +02:00
parent 470560efb6
commit a29faabbf2
22 changed files with 583 additions and 155 deletions

View File

@@ -4,11 +4,14 @@
'breadcrumb' => [__('shop.article_natures.title'), __('shop.article_natures.edit')]
])
@include('boilerplate::load.fileinput')
@section('content')
{{ Form::open(['route' => 'Admin.Shop.ArticleNatures.store', 'id' => 'article_nature-form', 'autocomplete' => 'off', 'files' => true]) }}
{{ Form::open([
'route' => 'Admin.Shop.ArticleNatures.store',
'id' => 'article_nature-form',
'autocomplete' => 'off',
'files' => true,
]) }}
<input type="hidden" name="id" value="{{ $article_nature['id'] }}">
@include('Admin.Shop.ArticleNatures.form')
</form>

View File

@@ -1,41 +1,59 @@
<div class="row">
<div class="col-4">
{{ Form::label('product_type', 'Famille de produit') }}
@include('components.form.select', [
'name' => 'product_type',
'value' => $article_nature['product_type'] ?? null,
'list' => $product_types ?? null,
'required' => true,
])
</div>
</div>
<div class="row">
<div class="col-md-8">
<div class="row mb-3">
<div class="col-8">
<div class="row mb-3">
<div class="col-12">
<div class="col-6">
{{ Form::label('product_type', 'Famille de produit') }}
@include('components.form.select', [
'name' => 'product_type',
'value' => $article_nature['product_type'] ?? null,
'list' => $product_types ?? null,
'required' => true,
])
</div>
<div class="col-6">
{{ Form::label('name', 'Nom') }}
@include('components.form.input', ['name' => 'name', 'value' => $article_nature['name'] ?? null, 'required' => true])
@include('components.form.input', [
'name' => 'name',
'value' => $article_nature['name'] ?? null,
'required' => true,
])
</div>
</div>
<div class="row mb-3">
<div class="col-12">
{{ Form::label('description', 'Description') }}
@include('components.form.textarea', ['name' => 'description', 'value' => $article_nature['description'] ?? null, 'class' => 'editor', 'required' => false])
@include('components.form.textarea', [
'name' => 'description',
'value' => $article_nature['description'] ?? null,
'class' => 'editor',
'required' => false,
])
</div>
</div>
</div>
<div class="col-4">
<x-card title="{{ __('icone') }}">
@include('components.widgets.imgUpload', [
'name' => 'icon',
'id_name' => 'icon',
'file' => $article_nature['icon'] ?? false,
])
</x-card>
</div>
</div>
@include('components.save')
<x-save />
@include('load.form.editor')
@include('load.form.upload.fileinput')
@include('load.form.save')
@push('js')
<script>
$(function() {
initEditor();
initUploadImage();
initSaveForm('#article_nature-form');
});
</script>

View File

@@ -4,10 +4,10 @@
@section('content')
<div class="row">
<div class="col-3">
<div class="col-lg-3 col-md-12">
@include('Shop.Customers.partials.user')
</div>
<div class="col-9">
<div class="col-lg-9 col-md-12">
@include('Shop.Customers.partials.sale')
</div>
</div>

View File

@@ -26,7 +26,7 @@
<div class="row">
<div class="col-12">
@include('Shop.Shelves.partials.category_add')
@include('Shop.Shelves.partials.category_add')
</div>
</div>

View File

@@ -0,0 +1,21 @@
<div class="row">
<div class="col-12">
<div id="{{ $id_name ?? $name }}_preview" class="{{ ($file ?? false) ? '' : 'd-none' }}">
<img src="{{ $file ?? null }}" class="img-fluid">
@if (!($disabled ?? false))
<div class="mt-2 text-right">
<button type="button" class="btn btn-sm btn-danger img-delete"><i class="fa fa-trash"></i></button>
</div>
@endif
</div>
@if (!($disabled ?? false))
<div id="{{ $id_name ?? $name }}_uploader" class="{{ ($file ?? false) ? 'd-none' : '' }} uploader-input">
@include('components.form.file', [
'name' => $name,
'value' => $file ?? null,
])
</div>
@endif
</div>
</div>

View File

@@ -1,25 +1,144 @@
@if(!defined('LOAD_FILEINPUT'))
@push('css')
<link rel="stylesheet" href="{!! asset('/assets/plugins/bootstrap-fileinput/css/fileinput.min.css') !!}">
<link rel="stylesheet" href="/assets/plugins/bootstrap-fileinput/css/fileinput.min.css">
@endpush
@push('js')
<script src="{!! asset('/assets/plugins/bootstrap-fileinput/js/fileinput.min.js') !!}"></script>
@push('scripts')
<script src="/assets/plugins/bootstrap-fileinput/js/fileinput.min.js"></script>
@if(App::getLocale() !== 'en')
<script src="{!! asset('/assets/plugins/bootstrap-fileinput/js/locales/'. App::getLocale() .'.js') !!}"></script>
<script src="/assets/plugins/bootstrap-fileinput/js/locales/{{ App::getLocale() }}.js"></script>
<script src="/assets/plugins/bootstrap-fileinput/themes/fas/theme.min.js"></script>
<script>
$.fn.fileinput.defaults.language = '{{ App::getLocale() }}';
</script>
@endif
@component('boilerplate::minify')
<script>
function initUpload(selector) {
var selector = '.file';
$(selector).fileinput({
function UploadInit(sel, options, callbackUploaded) {
// console.log(options);
var selector = (typeof(sel) == 'undefined') ? '.fileinput' : sel;
$(selector).fileinput(options)
.on("filebatchselected", function(event, files) {
$(selector).fileinput("upload");
}).on('fileuploaded', function (event, data, previewId, index, fileId) {
// console.log('File uploaded', previewId, index, fileId);
var file = data.files[0];
// console.log(file);
var response = data.response.initialPreviewConfig.extra;
// console.log(response);
response.model = $(this).data('model');
// console.log(response);
if (typeof(callbackUploaded) !== 'undefined') {
// console.log('Callback');
eval(callbackUploaded);
}
}).on('filebatchuploadcomplete', function(event, preview, config, tags, extraData) {
console.log('File Batch Uploaded', preview, config, tags, extraData);
}).on('filebatchuploadsuccess', function(event, data) {
console.log('File batch upload success');
console.log(data);
}).on('fileuploaderror', function(event, data, msg) {
console.log('File upload error');
console.log(data);
console.log(msg);
});
}
function UploadOptions(options) {
return {
allowedFileExtensions: (typeof(options.allowedFileExtensions) == 'undefined') ? ['doc','docx','jpg','jpeg','png','xls','xlsx','pdf'] : options.allowedFileExtensions,
browseOnZoneClick: (typeof(options.browseOnZoneClick) == 'undefined') ? true : options.browseOnZoneClick,
dropZoneEnabled: (typeof(options.dropZoneEnabled) == 'undefined') ? false : options.dropZoneEnabled,
initialPreview: (typeof(options.initialPreview) == 'undefined') ? false : options.initialPreview,
initialPreviewAsData: (typeof(options.initialPreviewAsData) == 'undefined') ? false : options.initialPreviewAsData,
maxFilesize: (typeof(options.maxFilesize) == 'undefined') ? false : options.maxFilesize,
overwriteInitial: (typeof(options.overwriteInitial) == 'undefined') ? false : options.overwriteInitial,
showCaption: (typeof(options.showCaption) == 'undefined') ? true : options.showCaption,
showPreview: (typeof(options.showPreview) == 'undefined') ? true : options.showPreview,
showRemove: (typeof(options.showRemove) == 'undefined') ? false : options.showRemove,
showUpload: (typeof(options.showUpload) == 'undefined') ? false : options.showUpload,
showUploadStats: (typeof(options.showUploadStats) == 'undefined') ? true : options.showUploadStats,
theme: (typeof(options.theme) == 'undefined') ? 'fas' : options.theme,
uploadAsync: (typeof(options.uploadAsync) == 'undefined') ? false : options.uploadAsync,
};
}
function initUpload(sel, options, callbackUploaded) {
UploadInit(sel, UploadOptions(options), callbackUploaded);
}
function initUploadMultiple(sel, options, callbackUploaded) {
UploadInit(sel, Object.assign({}, UploadOptions({
uploadUrl: "/site/test-upload",
enableResumableUpload: true,
initialPreviewAsData: true,
deleteUrl: '/upload',
dropZoneEnabled: true,
overwriteInitial: false,
showCaption: false,
showPreview: true,
showRemove: true,
showUpload: false,
uploadAsync: true,
maxFileCount: 5,
}), options), callbackUploaded);
}
function initRowUpload(sel, options, callbackUploaded) {
UploadInit(sel, Object.assign({}, UploadOptions({
showCaption: true,
showPreview: false,
showRemove: true,
uploadAsync: true,
}), options), callbackUploaded);
}
function initPdfUpload(sel, options, callbackUploaded) {
UploadInit(sel, Object.assign({}, UploadOptions({
allowedFileExtensions: ['pdf'],
showCaption: false,
dropZoneEnabled: false,
showUpload: false,
}), options), callbackUploaded);
}
function initUploadImage(image, sel) {
var selector = (typeof(sel) == 'undefined') ? '.fileinput' : sel;
var imgs = image ? [image] : false;
initFileInputImage(imgs, selector);
$('.img-delete').click(function() {
$container = $(this).parents('.row');
// console.log($container);
$(this).closest('.row').find('.uploader-input').toggleClass('d-none');
$(this).closest('.row').find('img').toggleClass('d-none');
$(this).toggleClass('d-none');
});
}
function initFileInputImage(images, sel)
{
UploadInit(sel, {
allowedFileExtensions: ['jpg', 'jpeg', 'png', 'gif'],
overwriteInitial: true,
showPreview: true,
showUpload: false,
maxFileSize: 10000,
initialPreview: images,
initialPreviewAsData: false,
theme: 'fas',
});
}
function uploadShowImage(id, image)
{
$('#' + id + '_preview').toggleClass('d-none');
$('#' + id + '_preview').find('img').attr('src', image);
$('#' + id + '_uploader').toggleClass('d-none');
}
</script>
@endif
@endpush
@endcomponent
@endpush
@php(define('LOAD_FILEINPUT', true))
@endif
@endif