diff --git a/Gruntfile.js b/Gruntfile.js
index 002f596f..7fe30cee 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -12,6 +12,7 @@ var jsMain = [
// 'node_modules/@activix/bootstrap-datetimepicker/js/bootstrap-datetimepicker.min.js',
// 'node_modules/@activix/bootstrap-datetimepicker/js/locales/bootstrap-datetimepicker.fr.js',
'node_modules/bootstrap-fileinput/js/plugins/piexif.min.js',
+ 'node_modules/bootstrap-fileinput/js/plugins/sortable.min.js',
// 'node_modules/bootstrap-slider/dist/bootstrap-slider.min.js',
// 'node_modules/bootstrap-validate/dist/bootstrap-validate.js',
// 'node_modules/jQuery-QueryBuilder/dist/js/jquery-builder.standalone.min.js',
@@ -30,7 +31,7 @@ var jsMain = [
'build/js/include/set_options.js',
// 'build/js/include/confirm.js',
'build/js/include/appender.js',
- // 'build/js/include/app.js',
+ 'build/js/include/app.js',
]
var cssMain = [
diff --git a/app/Http/Controllers/Botanic/Admin/VarietyController.php b/app/Http/Controllers/Botanic/Admin/VarietyController.php
index 9a719f24..0a1d8da0 100644
--- a/app/Http/Controllers/Botanic/Admin/VarietyController.php
+++ b/app/Http/Controllers/Botanic/Admin/VarietyController.php
@@ -54,20 +54,29 @@ class VarietyController extends Controller
public function edit($id)
{
- $data = Varieties::getWithImages($id)->toArray();
+ $data = Varieties::get($id)->toArray();
$data['species'] = Species::getOptions();
$data['tags_list'] = TagGroups::getTreeTags();
return view('Botanic.Admin.Varieties.edit', $data);
}
+ public function getImages(Request $request, $id = false)
+ {
+ $id = $id ? $id : $request->input('id');
+ $data['images'] = Varieties::getImages($id);
+ return view('components.uploader.mini-gallery-items', $data);
+ }
+
public function destroy($id)
{
return Varieties::destroy($id);
}
- public function deleteImage($id)
+ public function deleteImage(Request $request)
{
-
+ $id = $request->input('id');
+ $index = $request->input('index');
+ return Varieties::deleteImage($id, $index);
}
}
diff --git a/app/Http/Controllers/Shop/Admin/ArticleController.php b/app/Http/Controllers/Shop/Admin/ArticleController.php
index bda0d562..5b7e10ca 100644
--- a/app/Http/Controllers/Shop/Admin/ArticleController.php
+++ b/app/Http/Controllers/Shop/Admin/ArticleController.php
@@ -68,4 +68,10 @@ class ArticleController extends Controller
return Articles::destroy($id);
}
+ public function deleteImage(Request $request)
+ {
+ $id = $request->input('id');
+ $index = $request->input('index');
+ return Articles::deleteImage($id, $index);
+ }
}
diff --git a/app/Repositories/Botanic/Varieties.php b/app/Repositories/Botanic/Varieties.php
index 452274aa..0d55eb53 100644
--- a/app/Repositories/Botanic/Varieties.php
+++ b/app/Repositories/Botanic/Varieties.php
@@ -45,17 +45,6 @@ class Varieties
return Variety::find($id);
}
- public static function getWithImages($id)
- {
- $variety = self::get($id);
- $variety->getMedia();
- // $variety = $variety->toArray();
- foreach ($variety->media as $key => $media) {
- $variety->media[$key]['url'] = $media->getUrl();
- }
- return $variety;
- }
-
public static function store($data)
{
return isset($data['id']) ? self::update($data) : self::create($data);
@@ -82,9 +71,27 @@ class Varieties
{
if ($files) {
foreach ($files as $file) {
- $variety->addMedia($file)->toMediaCollection('images');
+ $variety->addMedia($file)->withResponsiveImages()->toMediaCollection('images');
}
}
}
+ public static function getImages($id)
+ {
+ $variety = self::get($id);
+ $variety->getMedia();
+ foreach ($variety->media as $key => $media) {
+ $variety->media[$key]['url'] = $media->getUrl();
+ }
+ return $variety->media;
+ }
+
+ public static function deleteImage($id, $index)
+ {
+ $variety = self::get($id);
+ $variety->getMedia();
+ $ret = $variety->media[$index]->delete();
+ return "1";
+ }
+
}
diff --git a/app/Repositories/Shop/Articles.php b/app/Repositories/Shop/Articles.php
index 27771371..24eec32a 100644
--- a/app/Repositories/Shop/Articles.php
+++ b/app/Repositories/Shop/Articles.php
@@ -51,4 +51,13 @@ class Articles
return Article::destroy($id);
}
+ public static function deleteImage($id, $index)
+ {
+ $article = self::get($id);
+ $article->getMedia();
+ $ret = $article->media[$index]->delete();
+ return "1";
+ }
+
+
}
diff --git a/build/js/include/appender.js b/build/js/include/appender.js
index 6c2f2a60..7dc4a8f2 100644
--- a/build/js/include/appender.js
+++ b/build/js/include/appender.js
@@ -12,7 +12,6 @@
}
$(document).on('click', settings.addBtn, function (event) {
-
$(appendArea).append(rowHtml);
if (settings.appendEffect === 'fade') {
@@ -25,31 +24,27 @@
$(settings.rowNumber).last().text(rowCounter);
- if (settings.type) {
- type = settings.type;
- } else {
- type = settings.rowSection;
- }
+ type = (settings.type) ? settings.type : settings.rowSection;
$(type).each(function(rowIndex) {
- $(this).find('input[name]').each(function(){
- var name;
- name = $(this).attr('name');
- name = name.replace(/\[[0-9]?\]/g, '['+rowIndex+']');
+ $(this).find('input[name]').each(function() {
+ var name = $(this).attr('name');
+ name = name.replace(/\[[0-9]?\]$/, '['+rowIndex+']');
$(this).attr('name',name);
});
- $(this).find('select[name]').each(function(){
- var name;
- name = $(this).attr('name');
- name = name.replace(/\[[0-9]?\]/g, '['+rowIndex+']');
+ $(this).find('select[name]').each(function() {
+ var name = $(this).attr('name');
+ name = name.replace(/\[[0-9]?\]$/, '['+rowIndex+']');
$(this).attr('name',name);
});
- $(this).find('textarea[name]').each(function(){
- var name;
- name = $(this).attr('name');
- name = name.replace(/\[[0-9]?\]/g, '['+rowIndex+']');
+ $(this).find('textarea[name]').each(function() {
+ var name = $(this).attr('name');
+ name = name.replace(/\[[0-9]?\]$/, '['+rowIndex+']');
$(this).attr('name',name);
});
+ $(this).find('.appender').each(function() {
+ $(this).data('id',rowIndex);
+ });
});
rowCounter++;
@@ -61,14 +56,13 @@
});
- if(settings.deleteBtn) {
+ if (settings.deleteBtn) {
$(document).on('click', settings.deleteBtn, function (e) {
$(e.target).closest(settings.rowSection).remove();
if (settings.callback) {
settings.callback();
}
})
-
}
};
diff --git a/resources/views/Botanic/Admin/Varieties/edit.blade.php b/resources/views/Botanic/Admin/Varieties/edit.blade.php
index ecf6e1d8..7903b8b7 100644
--- a/resources/views/Botanic/Admin/Varieties/edit.blade.php
+++ b/resources/views/Botanic/Admin/Varieties/edit.blade.php
@@ -7,10 +7,8 @@
@section('content')
{{ Form::open(['route' => 'Botanic.Admin.Varieties.store', 'id' => 'form', 'autocomplete' => 'off', 'files' => true]) }}
-
-
+
@include('Botanic.Admin.Varieties.form')
-
@endsection
diff --git a/resources/views/Botanic/Admin/Varieties/form.blade.php b/resources/views/Botanic/Admin/Varieties/form.blade.php
index 16552da3..cc9726b3 100644
--- a/resources/views/Botanic/Admin/Varieties/form.blade.php
+++ b/resources/views/Botanic/Admin/Varieties/form.blade.php
@@ -11,7 +11,7 @@
{{ Form::label('genre', 'Espèce') }}
- @include('components.select', ['name' => 'specie_id', 'list' => $species, 'value' => isset($specie_id) ? $specie_id : null, 'required' => false])
+ @include('components.select', ['name' => 'specie_id', 'list' => $species, 'value' => isset($specie_id) ? $specie_id : null, 'class' => 'select2 form-control', 'required' => false])
@@ -24,7 +24,7 @@
- @include('components.uploader.widget', ['images' => $media])
+ @include('components.uploader.widget', ['delete_url' => route('Botanic.Admin.Varieties.deleteImage') ])
diff --git a/resources/views/Shop/Admin/ArticlePhotos/partials/block_photo.blade.php b/resources/views/Shop/Admin/ArticlePhotos/partials/block_photo.blade.php
deleted file mode 100644
index ae3b315d..00000000
--- a/resources/views/Shop/Admin/ArticlePhotos/partials/block_photo.blade.php
+++ /dev/null
@@ -1,13 +0,0 @@
-
-
-
-
-
-
-
-
{{ $photo['title'] }}
-
Poids : {{ $photo['filesize'] }}
-
-
-
-
\ No newline at end of file
diff --git a/resources/views/Shop/Admin/ArticlePhotos/partials/block_photo_new.blade.php b/resources/views/Shop/Admin/ArticlePhotos/partials/block_photo_new.blade.php
deleted file mode 100644
index c33c6cd3..00000000
--- a/resources/views/Shop/Admin/ArticlePhotos/partials/block_photo_new.blade.php
+++ /dev/null
@@ -1,15 +0,0 @@
-
-
-
-
- Photo
-
-
-
-
Titre
-
-
-
Type de photo
- @include('components.select',['name' => 'lot_photos[][type_photo_id]' , 'list' => $type_photos])
-
-
\ No newline at end of file
diff --git a/resources/views/Shop/Admin/ArticlePhotos/partials/list-photos.blade.php b/resources/views/Shop/Admin/ArticlePhotos/partials/list-photos.blade.php
deleted file mode 100644
index 427d14a8..00000000
--- a/resources/views/Shop/Admin/ArticlePhotos/partials/list-photos.blade.php
+++ /dev/null
@@ -1,41 +0,0 @@
-@if (isset($photos) && count($photos))
-
-
-
- Photo
- Type
- Titre
- Poids
-
-
-
-
- @foreach($photos as $photo)
-
-
-
-
-
- {{ $photo['type_photo']['nom'] }}
-
-
- {{ $photo['title'] }}
-
-
- {{ $photo['filesize'] }}
-
-
-
-
-
-
-
-
- @endforeach
-
-
-@endif
\ No newline at end of file
diff --git a/resources/views/Shop/Admin/Articles/partials/block_price_new.blade.php b/resources/views/Shop/Admin/Articles/partials/block_price_new.blade.php
deleted file mode 100644
index ff784056..00000000
--- a/resources/views/Shop/Admin/Articles/partials/block_price_new.blade.php
+++ /dev/null
@@ -1,69 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- {{ Form::label('quantity', 'Quantité') }}
- @include('components.input', ['name' => 'prices[][quantity][]', 'value' => (isset($quantity)) ? $quantity : 1, 'required' => true, 'class' => 'form-control-sm'])
-
-
- {{ Form::label('attribute_family_id', 'Attributs') }}
- @include('components.select', ['name' => 'prices[][attribute_family_id][]', 'value' => (isset($attribute_value['attribute_family_id'])) ? $attribute_value['attribute_family_id'] : null, 'list' => $attribute_families, 'required' => true, 'class' => 'form-control-sm'])
-
-
-
- {{ Form::label('attribute_value_id', 'Valeur') }}
- @include('components.select', ['name' => 'prices[][attribute_value_id][]', 'value' => (isset($attribute_value['id'])) ? $attribute_value['id'] : null, 'list' => (isset($attribute_values)) ? $attribute_values : null, 'required' => true, 'class' => 'form-control-sm'])
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/resources/views/Shop/Admin/Articles/partials/characteristics.blade.php b/resources/views/Shop/Admin/Articles/partials/characteristics.blade.php
index 5e81c7de..f9f3b05a 100644
--- a/resources/views/Shop/Admin/Articles/partials/characteristics.blade.php
+++ b/resources/views/Shop/Admin/Articles/partials/characteristics.blade.php
@@ -46,6 +46,6 @@
- @include('components.uploader.widget', ['images' => isset($media) ? $media : null])
+ @include('components.uploader.widget', ['delete_url' => route('Shop.Admin.Articles.deleteImage') ])
diff --git a/resources/views/Shop/Admin/Articles/partials/prices.blade.php b/resources/views/Shop/Admin/Articles/partials/prices.blade.php
index cd85287c..30e1ac1a 100644
--- a/resources/views/Shop/Admin/Articles/partials/prices.blade.php
+++ b/resources/views/Shop/Admin/Articles/partials/prices.blade.php
@@ -1,15 +1,16 @@
-@include('Shop.Admin.Articles.partials.block_price_new')
+@include('Shop.Admin.Articles.partials.prices.block_price_new')
- @include('Shop.Admin.Articles.partials.list-prices')
+ @include('Shop.Admin.Articles.partials.prices.list-prices')
-Ajouter un tarif
+Ajouter un tarif
@push('js')
diff --git a/resources/views/Shop/Admin/Articles/partials/prices/attributes.blade.php b/resources/views/Shop/Admin/Articles/partials/prices/attributes.blade.php
new file mode 100644
index 00000000..c075fe44
--- /dev/null
+++ b/resources/views/Shop/Admin/Articles/partials/prices/attributes.blade.php
@@ -0,0 +1,4 @@
+
+ @include('Shop.Admin.Articles.partials.prices.block_attribute_new')
+
+
diff --git a/resources/views/Shop/Admin/Articles/partials/prices/block_attribute_new.blade.php b/resources/views/Shop/Admin/Articles/partials/prices/block_attribute_new.blade.php
new file mode 100644
index 00000000..428122ee
--- /dev/null
+++ b/resources/views/Shop/Admin/Articles/partials/prices/block_attribute_new.blade.php
@@ -0,0 +1,15 @@
+
+
+ {{ Form::label('quantity', 'Quantité') }}
+ @include('components.input', ['name' => 'prices[][quantity][]', 'value' => (isset($quantity)) ? $quantity : 1, 'required' => true, 'class' => 'form-control-sm'])
+
+
+ {{ Form::label('attribute_family_id', 'Attributs') }}
+ @include('components.select', ['name' => 'prices[][attribute_family_id][]', 'value' => (isset($attribute_value['attribute_family_id'])) ? $attribute_value['attribute_family_id'] : null, 'list' => $attribute_families, 'required' => true, 'class' => 'form-control form-control-sm'])
+
+
+
+ {{ Form::label('attribute_value_id', 'Valeur') }}
+ @include('components.select', ['name' => 'prices[][attribute_value_id][]', 'value' => (isset($attribute_value['id'])) ? $attribute_value['id'] : null, 'list' => (isset($attribute_values)) ? $attribute_values : null, 'required' => true, 'class' => 'form-control form-control-sm'])
+
+
diff --git a/resources/views/Shop/Admin/Articles/partials/block_price.blade.php b/resources/views/Shop/Admin/Articles/partials/prices/block_price.blade.php
similarity index 100%
rename from resources/views/Shop/Admin/Articles/partials/block_price.blade.php
rename to resources/views/Shop/Admin/Articles/partials/prices/block_price.blade.php
diff --git a/resources/views/Shop/Admin/Articles/partials/prices/block_price_new.blade.php b/resources/views/Shop/Admin/Articles/partials/prices/block_price_new.blade.php
new file mode 100644
index 00000000..31cae55e
--- /dev/null
+++ b/resources/views/Shop/Admin/Articles/partials/prices/block_price_new.blade.php
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+ {{ Form::label('tax_id', 'TVA') }}
+ @include('components.select', ['name' => 'prices[][tax_id]', 'value' => (isset($tax_id)) ? $tax_id : null, 'list' => isset($taxes) ? $taxes : null, 'required' => true, 'class' => 'form-control form-control-sm'])
+
+
+
+ {{ Form::label('quantity', 'Quantité') }}
+ @include('components.number', ['name' => 'prices[][quantity}', 'value' => (isset($quantity)) ? $quantity : 1, 'required' => true, 'class' => 'form-control-sm'])
+
+
+
+ {{ Form::label('price', 'Prix HT') }}
+ @include('components.money', ['name' => 'prices[][price}', 'value' => (isset($price)) ? $price : 0, 'required' => true, 'class' => 'form-control-sm'])
+
+
+
+ {{ Form::label('price_taxed', 'Prix TTC') }}
+ @include('components.money', ['name' => 'prices[][price_taxed]', 'value' => (isset($price_ht)) ? $price_ht : 0, 'required' => true, 'class' => 'form-control-sm'])
+
+
+
+
+
+ Ajout d'un attribut
+
+
+
+
+
+
+
+
+
+
+
+
+ @include('Shop.Admin.Articles.partials.prices.attributes')
+
+
+
+
\ No newline at end of file
diff --git a/resources/views/Shop/Admin/Articles/partials/list-prices.blade.php b/resources/views/Shop/Admin/Articles/partials/prices/list-prices.blade.php
similarity index 100%
rename from resources/views/Shop/Admin/Articles/partials/list-prices.blade.php
rename to resources/views/Shop/Admin/Articles/partials/prices/list-prices.blade.php
diff --git a/resources/views/Shop/_partials/header.twig b/resources/views/Shop/_partials/header.twig
index c31e6991..904c0b3f 100644
--- a/resources/views/Shop/_partials/header.twig
+++ b/resources/views/Shop/_partials/header.twig
@@ -9,10 +9,6 @@
{{ include("Shop._partials.sections")}}
-
-
-
-
diff --git a/resources/views/components/uploader/block_image.blade.php b/resources/views/components/uploader/block_image.blade.php
index b68c7ac3..f8909347 100644
--- a/resources/views/components/uploader/block_image.blade.php
+++ b/resources/views/components/uploader/block_image.blade.php
@@ -1,5 +1,5 @@
-
+TEST
diff --git a/resources/views/components/uploader/file-data.blade.php b/resources/views/components/uploader/file-data.blade.php
index 36293874..c52e413c 100644
--- a/resources/views/components/uploader/file-data.blade.php
+++ b/resources/views/components/uploader/file-data.blade.php
@@ -1,5 +1,5 @@
-
Titre
-
+
Titre
+
-
Type de photo
- @include('components.select',['name' => 'images[][type_image_id]' , 'list' => isset($type_images) ? $type_images : null])
+
Type de photo
+@include('components.select',['name' => 'images[][type_image_id]' , 'list' => isset($type_images) ? $type_images : null])
diff --git a/resources/views/components/uploader/mini-gallery-items.blade.php b/resources/views/components/uploader/mini-gallery-items.blade.php
new file mode 100644
index 00000000..889c1f1c
--- /dev/null
+++ b/resources/views/components/uploader/mini-gallery-items.blade.php
@@ -0,0 +1,18 @@
+@foreach($images as $key => $image)
+
+
+
+
+
+
+
+
+
+
+
+@endforeach
+
+
\ No newline at end of file
diff --git a/resources/views/components/uploader/mini-gallery.blade.php b/resources/views/components/uploader/mini-gallery.blade.php
index 4739731c..b4713295 100644
--- a/resources/views/components/uploader/mini-gallery.blade.php
+++ b/resources/views/components/uploader/mini-gallery.blade.php
@@ -1,34 +1,48 @@
-@if ($images)
-
- @foreach($images as $image)
-
-
-
-
-
-
-
-
-
-
-
- @endforeach
+
+
+
+
+
+
+
+
+
+
-@endif
+
@push('js')
@endpush
\ No newline at end of file
diff --git a/resources/views/components/uploader/widget.blade.php b/resources/views/components/uploader/widget.blade.php
index 0eb69243..41d8dfb3 100644
--- a/resources/views/components/uploader/widget.blade.php
+++ b/resources/views/components/uploader/widget.blade.php
@@ -2,15 +2,20 @@
-
- @include('components.uploader.mini-gallery', ['images' => $images])
+
+ @if (isset($id))
+ @include('components.uploader.mini-gallery')
+ @endif
@include('components.uploader.block_image_new', ['name' => 'images[]', 'required' => true])
+
@push('js')
@@ -30,5 +35,15 @@
callback: append_image,
hideSection: true
});
+
+ function loadImages()
+ {
+ $gallery = $("#uploader-mini-gallery");
+ if ($gallery) {
+ $gallery.load("{{ route('Botanic.Admin.Varieties.getImages', ['id' => (isset($id)) ? $id : false]) }}");
+ }
+ }
+
+ loadImages();
@endpush
diff --git a/routes/Botanic/Admin/Varieties.php b/routes/Botanic/Admin/Varieties.php
index 7d3bc3cc..633e7426 100644
--- a/routes/Botanic/Admin/Varieties.php
+++ b/routes/Botanic/Admin/Varieties.php
@@ -9,6 +9,7 @@ Route::prefix('Varieties')->name('Varieties.')->group(function () {
Route::post('store', 'VarietyController@store')->name('store');
Route::get('edit/{id}', 'VarietyController@edit')->name('edit');
Route::post('getSelect', 'VarietyController@getOptionsWithSpecie')->name('getSelect');
- Route::delete('deleteImage', 'VarietyController@deleteImage')->name('deleteImage');
+ Route::post('deleteImage', 'VarietyController@deleteImage')->name('deleteImage');
+ Route::any('getImages/{id?}', 'VarietyController@getImages')->name('getImages');
});
diff --git a/routes/Shop/Admin/Articles.php b/routes/Shop/Admin/Articles.php
index eb47b215..fd305e6c 100644
--- a/routes/Shop/Admin/Articles.php
+++ b/routes/Shop/Admin/Articles.php
@@ -7,6 +7,8 @@ Route::prefix('Articles')->name('Articles.')->group(function () {
Route::post('update', 'ArticleController@update')->name('update');
Route::post('store', 'ArticleController@store')->name('store');
Route::get('edit/{id}', 'ArticleController@edit')->name('edit');
-
+
+ Route::any('getImages/{id?}', 'ArticleController@getImages')->name('getImages');
+ Route::post('deleteImage', 'ArticleController@deleteImage')->name('deleteImage');
});