Fixes on widget uploder
This commit is contained in:
@@ -55,10 +55,11 @@ class VarietyController extends Controller
|
|||||||
return Varieties::destroy($id);
|
return Varieties::destroy($id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getImages(Request $request, $id = false)
|
public function getImages(Request $request, $id = false, $can_edit = true)
|
||||||
{
|
{
|
||||||
$id = $id ? $id : $request->input('id');
|
$id = $id ? $id : $request->input('id');
|
||||||
$data['images'] = Varieties::getImages($id);
|
$data['images'] = Varieties::getImages($id);
|
||||||
|
$data['can_edit'] = $can_edit;
|
||||||
return view('components.uploader.mini-gallery-items', $data);
|
return view('components.uploader.mini-gallery-items', $data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ class Articles
|
|||||||
|
|
||||||
public static function getMeta(&$data = [])
|
public static function getMeta(&$data = [])
|
||||||
{
|
{
|
||||||
$data['products'] = ( ($data['product_type'] ?? false) == 'App\Models\Botanic\Variety') ? Varieties::getOptionsWithSpecie() : Species::getOptions();
|
$data['products'] = ( ($data['article']['product_type'] ?? false) == 'App\Models\Botanic\Variety') ? Varieties::getOptionsWithSpecie() : Species::getOptions();
|
||||||
$data['categories_options'] = Categories::getOptions();
|
$data['categories_options'] = Categories::getOptions();
|
||||||
$data['price_generics'] = PriceGenericCategories::getOptionsWithChildrens();
|
$data['price_generics'] = PriceGenericCategories::getOptionsWithChildrens();
|
||||||
$data['families_options'] = ArticleFamilies::getOptions();
|
$data['families_options'] = ArticleFamilies::getOptions();
|
||||||
|
|||||||
@@ -7,25 +7,25 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
{{ Form::label('name', 'Nom') }}
|
{{ Form::label('name', 'Nom') }}
|
||||||
@include('components.input', ['name' => 'name', 'value' => isset($name) ? $name : null, 'required' => true])
|
@include('components.input', ['name' => 'name', 'value' => $name ?? null, 'required' => true])
|
||||||
</div>
|
</div>
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
{{ Form::label('genre', 'Espèce') }}
|
{{ Form::label('genre', 'Espèce') }}
|
||||||
@include('components.select', ['name' => 'specie_id', 'list' => $species, 'value' => isset($specie_id) ? $specie_id : null, 'class' => 'select2 form-control', 'required' => false])
|
@include('components.select', ['name' => 'specie_id', 'list' => $species, 'value' => $specie_id ?? null, 'class' => 'select2 form-control', 'required' => false])
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{{ Form::label('tags', 'Tags') }}
|
{{ Form::label('tags', 'Tags') }}
|
||||||
@include('components.select-tree', ['name' => 'tags[]', 'list' => $tags_list, 'values' => isset($tags) ? $tags : null, 'class' => 'select2 form-control', 'multiple' => true])
|
@include('components.select-tree', ['name' => 'tags[]', 'list' => $tags_list, 'values' => $tags ?? null, 'class' => 'select2 form-control', 'multiple' => true])
|
||||||
|
|
||||||
|
|
||||||
{{ Form::label('description', 'Description') }}
|
{{ Form::label('description', 'Description') }}
|
||||||
@include('components.textarea', ['name' => 'description', 'value' => isset($description) ? $description : null, 'class' => 'editor', 'rows' => 5, 'required' => false])
|
@include('components.textarea', ['name' => 'description', 'value' => $description ?? null, 'class' => 'editor', 'rows' => 5, 'required' => false])
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
@include('components.uploader.widget', ['load_url' => route('Botanic.Admin.Varieties.getImages', ['id' => (isset($id)) ? $id : false]), 'delete_url' => route('Botanic.Admin.Varieties.deleteImage') ])
|
@include('components.uploader.widget', ['load_url' => route('Botanic.Admin.Varieties.getImages', ['id' => $id ?? false]), 'delete_url' => route('Botanic.Admin.Varieties.deleteImage'), 'name' => 'images'])
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -78,6 +78,7 @@
|
|||||||
@include('boilerplate::load.tinymce')
|
@include('boilerplate::load.tinymce')
|
||||||
@include('load.appender')
|
@include('load.appender')
|
||||||
@include('load.toggle')
|
@include('load.toggle')
|
||||||
|
@include('load.form.save')
|
||||||
|
|
||||||
@push('js')
|
@push('js')
|
||||||
<script>
|
<script>
|
||||||
@@ -92,6 +93,8 @@
|
|||||||
// handleAdmin.toggle(id, $(this).prop('checked'));
|
// handleAdmin.toggle(id, $(this).prop('checked'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
initSaveForm('.save', '#article-form');
|
||||||
|
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
@@ -37,6 +37,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
{{ Form::label('tags', 'Tags') }}<br>
|
{{ Form::label('tags', 'Tags') }}<br>
|
||||||
|
@include('Shop.Admin.Articles.partials.product.tags')
|
||||||
@include('components.select-tree', ['name' => 'tags[]', 'list' => $tags_list, 'values' => $article['tags'] ?? null, 'class' => 'select2 form-control', 'multiple' => true])
|
@include('components.select-tree', ['name' => 'tags[]', 'list' => $tags_list, 'values' => $article['tags'] ?? null, 'class' => 'select2 form-control', 'multiple' => true])
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
@@ -44,18 +45,15 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
{{ Form::label('description', 'Description') }}
|
{{ Form::label('description', 'Description') }}
|
||||||
@if (!empty($article['product']['description']))
|
@include('Shop.Admin.Articles.partials.product.description')
|
||||||
@component('components.layout.box-collapse', ['id' => 'product_description', 'title' => 'Description produit'])
|
|
||||||
{{ $article['product']['description'] }}
|
|
||||||
@endcomponent
|
|
||||||
@endif
|
|
||||||
@include('components.textarea', ['name' => 'description', 'value' => $article['description'] ?? null, 'class' => 'editor', 'required' => true])
|
@include('components.textarea', ['name' => 'description', 'value' => $article['description'] ?? null, 'class' => 'editor', 'required' => true])
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-4">
|
<div class="col-md-4">
|
||||||
@include('components.uploader.widget', ['load_url' => route('Shop.Admin.Articles.getImages', ['id' => $article['id'] ?? false]), 'delete_url' => route('Shop.Admin.Articles.deleteImage'), 'title' => 'Photos' ])
|
@include('Shop.Admin.Articles.partials.product.images', ['name' => 'product_images'])
|
||||||
|
@include('components.uploader.widget', ['load_url' => route('Shop.Admin.Articles.getImages', ['id' => $article['id'] ?? false]), 'delete_url' => route('Shop.Admin.Articles.deleteImage'), 'title' => 'Photos', 'name' => 'images' ])
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
@if (!empty($article['product']['description']))
|
||||||
|
@component('components.layout.box-collapse', ['id' => 'product_description', 'title' => 'Description produit'])
|
||||||
|
{{ $article['product']['description'] }}
|
||||||
|
@endcomponent
|
||||||
|
@endif
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
@include('components.uploader.widget', ['load_url' => route('Botanic.Admin.Varieties.getImages', ['id' => $article['product_id'] ?? false]), 'title' => 'Photos produits', 'prefix' => 'product_', 'can_edit' => false ])
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
@if (!empty($article['product']['tags']))
|
||||||
|
@component('components.layout.box-collapse', ['id' => 'product_tags', 'title' => 'Tags produit'])
|
||||||
|
@foreach ($article['product']['tags'] as $tag)
|
||||||
|
{{ $tag->name }}
|
||||||
|
@endforeach
|
||||||
|
@endcomponent
|
||||||
|
@endif
|
||||||
@@ -3,7 +3,7 @@
|
|||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-6">
|
<div class="col-6">
|
||||||
<button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#{{ $id }}" aria-expanded="false" aria-controls="{{ $id }}">
|
<button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#{{ $id }}" aria-expanded="false" aria-controls="{{ $id }}">
|
||||||
<i class="fa fa-chevron-right"></i>
|
<i class="fa {{ ($collapsed ?? true) ? 'fa-chevron-right' : 'fa-chevron-down' }}"></i>
|
||||||
</button>
|
</button>
|
||||||
{!! $title ?? null !!}
|
{!! $title ?? null !!}
|
||||||
@if (isset($required) && $required)
|
@if (isset($required) && $required)
|
||||||
@@ -19,7 +19,9 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div id="{{ $id }}" class="card-body collapse {{ $class_body ?? '' }}">
|
<div id="{{ $id }}" class="card-body collapse {{ ($collapsed ?? true) ? '' : 'show' }} {{ $class_body ?? '' }}">
|
||||||
{{ $slot }}
|
{{ $slot }}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
@include('load.layout.chevron')
|
||||||
|
|||||||
@@ -2,23 +2,23 @@
|
|||||||
@foreach($images as $key => $image)
|
@foreach($images as $key => $image)
|
||||||
<figure class="mr-2">
|
<figure class="mr-2">
|
||||||
<img src="{{ $image['url'] }}" class="img-thumbnail img-caption" style="max-height:92px;">
|
<img src="{{ $image['url'] }}" class="img-thumbnail img-caption" style="max-height:92px;">
|
||||||
@if ($can_edit ?? true)
|
|
||||||
<figcaption class="text-center pt-2">
|
<figcaption class="text-center pt-2">
|
||||||
<button type="button" class="btn btn-xs btn-outline-secondary">
|
<button type="button" class="btn btn-xs btn-outline-secondary">
|
||||||
<i class="fas fa-expand-alt"></i>
|
<i class="fas fa-expand-alt"></i>
|
||||||
</button>
|
</button>
|
||||||
|
@if ($can_edit ?? true)
|
||||||
<button type="button" class="btn btn-xs btn-outline-danger">
|
<button type="button" class="btn btn-xs btn-outline-danger">
|
||||||
<i class="fas fa-trash" data-index="{{ $key }}"></i>
|
<i class="fas fa-trash" data-index="{{ $key }}"></i>
|
||||||
</button>
|
</button>
|
||||||
</figcaption>
|
|
||||||
@endif
|
@endif
|
||||||
|
</figcaption>
|
||||||
</figure>
|
</figure>
|
||||||
@endforeach
|
@endforeach
|
||||||
@endif
|
@endif
|
||||||
|
|
||||||
@if ($can_edit ?? true)
|
<script>
|
||||||
<script>
|
@if ($can_edit ?? true)
|
||||||
{{ $prefix ?? '' }}handleDeleteImages();
|
{{ $prefix ?? '' }}handleDeleteImages();
|
||||||
|
@endif
|
||||||
{{ $prefix ?? '' }}handleEnlargeImages();
|
{{ $prefix ?? '' }}handleEnlargeImages();
|
||||||
</script>
|
</script>
|
||||||
@endif
|
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
|
|
||||||
@push('js')
|
@push('js')
|
||||||
<script>
|
<script>
|
||||||
|
@if ($can_edit ?? true)
|
||||||
function {{ $prefix ?? '' }}handleDeleteImages() {
|
function {{ $prefix ?? '' }}handleDeleteImages() {
|
||||||
$('#{{ $prefix ?? '' }}uploader-mini-gallery .fa-trash').click(function() {
|
$('#{{ $prefix ?? '' }}uploader-mini-gallery .fa-trash').click(function() {
|
||||||
id = $('#id').val();
|
id = $('#id').val();
|
||||||
@@ -23,7 +24,7 @@
|
|||||||
console.log(id);
|
console.log(id);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
type: 'post',
|
type: 'post',
|
||||||
url: "{{ $delete_url }}",
|
url: "{{ $delete_url ?? '' }}",
|
||||||
data: {
|
data: {
|
||||||
id: id,
|
id: id,
|
||||||
index: index
|
index: index
|
||||||
@@ -34,6 +35,7 @@
|
|||||||
});
|
});
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
@endif
|
||||||
|
|
||||||
function {{ $prefix ?? '' }}handleEnlargeImages() {
|
function {{ $prefix ?? '' }}handleEnlargeImages() {
|
||||||
$('#{{ $prefix ?? '' }}uploader-mini-gallery .fa-expand-alt').click(function() {
|
$('#{{ $prefix ?? '' }}uploader-mini-gallery .fa-expand-alt').click(function() {
|
||||||
@@ -44,5 +46,6 @@
|
|||||||
$('#{{ $prefix ?? '' }}mini-gallery-lightbox').modal('show');
|
$('#{{ $prefix ?? '' }}mini-gallery-lightbox').modal('show');
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
@@ -1,31 +1,25 @@
|
|||||||
@include('boilerplate::load.fileinput')
|
@include('boilerplate::load.fileinput')
|
||||||
|
|
||||||
<div class="card">
|
@component('components.layout.box-collapse', ['id' => ($prefix ?? '') . $name ?? 'images', 'title' => $title ?? 'Photos', 'collapsed' => $collapsed ?? false])
|
||||||
<div class="card-header">
|
|
||||||
<h3 class="card-title">{{ $title }}</h3>
|
|
||||||
<div class="card-tools">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="card-body pt-3 pb-0">
|
|
||||||
@if (isset($article['id']))
|
|
||||||
@include('components.uploader.mini-gallery')
|
@include('components.uploader.mini-gallery')
|
||||||
@endif
|
|
||||||
|
|
||||||
@if ($can_edit ?? true)
|
@if ($can_edit ?? true)
|
||||||
<div id="{{ $prefix ?? '' }}uploader-new-images"></div>
|
<div id="{{ $prefix ?? '' }}uploader-new-images"></div>
|
||||||
@include('components.uploader.block_image_new', ['name' => 'images[]', 'required' => true])
|
@include('components.uploader.block_image_new', ['name' => ($name ?? 'images') . '[]'])
|
||||||
@endif
|
@endif
|
||||||
</div>
|
|
||||||
@if ($can_edit ?? true)
|
@if ($can_edit ?? true)
|
||||||
<div class="card-footer">
|
<div class="card-footer">
|
||||||
<button type="button" class="btn btn-xs btn-primary {{ $prefix ?? '' }}add-image pull-right">Ajout <i class="fa fa-plus"></i></button>
|
<button type="button" class="btn btn-xs btn-primary {{ $prefix ?? '' }}add-image pull-right">Ajout <i class="fa fa-plus"></i></button>
|
||||||
</div>
|
</div>
|
||||||
@endif
|
@endif
|
||||||
</div>
|
|
||||||
|
@endcomponent
|
||||||
|
|
||||||
@push('js')
|
@push('js')
|
||||||
<script>
|
<script>
|
||||||
|
@if ($can_edit ?? true)
|
||||||
function {{ $prefix ?? '' }}append_image() {
|
function {{ $prefix ?? '' }}append_image() {
|
||||||
$("#{{ $prefix ?? '' }}uploader-new-images .file").fileinput();
|
$("#{{ $prefix ?? '' }}uploader-new-images .file").fileinput();
|
||||||
$("#{{ $prefix ?? '' }}uploader-new-images .file").focus();
|
$("#{{ $prefix ?? '' }}uploader-new-images .file").focus();
|
||||||
@@ -42,8 +36,9 @@
|
|||||||
callback: {{ $prefix ?? '' }}append_image,
|
callback: {{ $prefix ?? '' }}append_image,
|
||||||
hideSection: true
|
hideSection: true
|
||||||
});
|
});
|
||||||
|
@endif
|
||||||
|
|
||||||
function loadImages()
|
function {{ $prefix ?? '' }}loadImages()
|
||||||
{
|
{
|
||||||
$gallery = $("#{{ $prefix ?? '' }}uploader-mini-gallery");
|
$gallery = $("#{{ $prefix ?? '' }}uploader-mini-gallery");
|
||||||
if ($gallery) {
|
if ($gallery) {
|
||||||
@@ -52,7 +47,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
$(function() {
|
$(function() {
|
||||||
loadImages();
|
{{ $prefix ?? '' }}loadImages();
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
|||||||
@@ -8,6 +8,10 @@
|
|||||||
$(this).find('i').toggleClass('fa-chevron-right fa-chevron-down')
|
$(this).find('i').toggleClass('fa-chevron-right fa-chevron-down')
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$(function() {
|
||||||
|
initChevron();
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
@endpush
|
@endpush
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ Route::prefix('Varieties')->name('Varieties.')->group(function () {
|
|||||||
Route::get('edit/{id}', 'VarietyController@edit')->name('edit');
|
Route::get('edit/{id}', 'VarietyController@edit')->name('edit');
|
||||||
Route::post('getSelect', 'VarietyController@getOptionsWithSpecie')->name('getSelect');
|
Route::post('getSelect', 'VarietyController@getOptionsWithSpecie')->name('getSelect');
|
||||||
Route::post('deleteImage', 'VarietyController@deleteImage')->name('deleteImage');
|
Route::post('deleteImage', 'VarietyController@deleteImage')->name('deleteImage');
|
||||||
Route::any('getImages/{id?}', 'VarietyController@getImages')->name('getImages');
|
Route::any('getImages/{id?}/{can_edit?}', 'VarietyController@getImages')->name('getImages');
|
||||||
|
|
||||||
Route::any('exportExcel', 'VarietyController@exportExcel')->name('exportExcel');
|
Route::any('exportExcel', 'VarietyController@exportExcel')->name('exportExcel');
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user