Fix on refreshing description & images from products
This commit is contained in:
@@ -22,7 +22,7 @@ class SpecieController extends Controller
|
||||
|
||||
public function getOptions()
|
||||
{
|
||||
return response()->json(Species::getOptions());
|
||||
return response()->json(['0' => ''] + Species::getOptions());
|
||||
}
|
||||
|
||||
public function create()
|
||||
|
||||
@@ -20,7 +20,7 @@ class VarietyController extends Controller
|
||||
|
||||
public function getOptionsWithSpecie()
|
||||
{
|
||||
return response()->json(Varieties::getOptionsWithSpecie());
|
||||
return response()->json(['0' => ''] + Varieties::getOptionsWithSpecie());
|
||||
}
|
||||
|
||||
public function create()
|
||||
|
||||
@@ -45,8 +45,6 @@ class ArticleController extends Controller
|
||||
public function edit($id)
|
||||
{
|
||||
$data = Articles::getFull($id);
|
||||
// dump($data);
|
||||
// exit;
|
||||
return view('Admin.Shop.Articles.edit', $data);
|
||||
}
|
||||
|
||||
@@ -69,7 +67,8 @@ class ArticleController extends Controller
|
||||
|
||||
public function getProductImages($product_id, $model)
|
||||
{
|
||||
$data = Articles::getInheritedByProduct($product_id, base64_decode($model));
|
||||
$data['article']['product_id'] = $product_id;
|
||||
$data['no_popup'] = false;
|
||||
return view('Admin.Shop.Articles.partials.product.images', $data);
|
||||
}
|
||||
|
||||
|
||||
@@ -101,6 +101,22 @@ class Articles
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getInheritedImagesByProduct($product_id, $product_type)
|
||||
{
|
||||
switch ($product_type) {
|
||||
case 'App\Models\Botanic\Variety':
|
||||
$data['images'] = Varieties::getImages($product_id);
|
||||
break;
|
||||
case 'App\Models\Botanic\Specie':
|
||||
$data['images'] = Species::getImages($product_id);
|
||||
break;
|
||||
case 'App\Models\Shop\Merchandise':
|
||||
$data['images'] = Merchandises::getImages($product_id);
|
||||
break;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
public static function getMeta(&$data = [])
|
||||
{
|
||||
$data['products'] = (($data['article']['product_type'] ?? false) == 'App\Models\Botanic\Variety') ? Varieties::getOptionsWithSpecie() : Species::getOptions();
|
||||
|
||||
@@ -56,7 +56,9 @@
|
||||
|
||||
</div>
|
||||
<div class="col-md-4">
|
||||
<div id="product_images_inherited">
|
||||
@include('Admin.Shop.Articles.partials.product.images')
|
||||
</div>
|
||||
@include('components.uploader.widget', ['load_url' => route('Admin.Shop.Articles.getImages', ['id' => $article['id'] ?? false]), 'delete_url' => route('Admin.Shop.Articles.deleteImage'), 'title' => 'Photos', 'name' => 'images' ])
|
||||
@include('Admin.Core.Comments.partials.comments', ['model' => 'Shop.Article', 'model_id' => $article['id'] ?? false, 'comments' => $article['comments'] ?? false])
|
||||
</div>
|
||||
@@ -69,16 +71,14 @@
|
||||
var product = $('#product_id').select2('data');
|
||||
var name = product[0]['text'];
|
||||
$('input[name="name"]').val(name);
|
||||
console.log(product);
|
||||
|
||||
var product_type = $('#product_type').select2('data');
|
||||
var name = product_type[0]['id'];
|
||||
console.log(product_type);
|
||||
console.log(name);
|
||||
|
||||
var url = "{{ route('Admin.Shop.Articles.getProductDescription') }}/" + product[0]['id'] + '/' + btoa(name);
|
||||
console.log(url);
|
||||
$('#product_description').load(url);
|
||||
|
||||
var url = "{{ route('Admin.Shop.Articles.getProductImages') }}/" + product[0]['id'] + '/' + btoa(name);
|
||||
$('#product_images_inherited').load(url);
|
||||
});
|
||||
|
||||
$('#product_type').change( function() {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
@if (count($article['inherited'] ?? []))
|
||||
@component('components.layout.box-collapse', ['id' => 'product_description_box', 'title' => 'Informations héritées'])
|
||||
@component('components.layout.box-collapse', ['id' => 'product_description_box', 'title' => 'Informations héritées', 'collapsed' => $collapsed ?? false])
|
||||
@foreach ($article['inherited'] as $inherited)
|
||||
@component('components.card', ['title' => $inherited['name'], 'class' => 'mb-3'])
|
||||
{!! $inherited['description'] !!}
|
||||
|
||||
@@ -1 +1,3 @@
|
||||
@include('components.uploader.widget', ['load_url' => route('Admin.Botanic.Varieties.getImages', ['id' => $article['product_id'] ?? false, 'can_edit' => 0]), 'name' => 'images', 'title' => 'Photos produits', 'prefix' => 'product_', 'can_edit' => false, 'collapsed' => true ])
|
||||
@if ($article['product_id'] ?? false)
|
||||
@include('components.uploader.widget', ['load_url' => route('Admin.Botanic.Varieties.getImages', ['id' => $article['product_id'] ?? false, 'can_edit' => 0]), 'name' => 'images', 'title' => 'Photos produits', 'prefix' => 'product_', 'can_edit' => false ])
|
||||
@endif
|
||||
@@ -1,5 +1,3 @@
|
||||
@include('boilerplate::load.fileinput')
|
||||
|
||||
@component('components.layout.box-collapse', ['id' => ($prefix ?? '') . ($name ?? 'images'), 'title' => $title ?? 'Photos', 'collapsed' => $collapsed ?? false])
|
||||
|
||||
@include('components.uploader.mini-gallery')
|
||||
@@ -17,7 +15,12 @@
|
||||
|
||||
@endcomponent
|
||||
|
||||
@include('boilerplate::load.fileinput')
|
||||
|
||||
@if ($no_popup ?? true)
|
||||
@push('js')
|
||||
@endif
|
||||
|
||||
<script>
|
||||
@if ($can_edit ?? true)
|
||||
function {{ $prefix ?? '' }}append_image() {
|
||||
@@ -53,4 +56,7 @@
|
||||
{{ $prefix ?? '' }}loadImages();
|
||||
});
|
||||
</script>
|
||||
|
||||
@if ($no_popup ?? true)
|
||||
@endpush
|
||||
@endif
|
||||
Reference in New Issue
Block a user