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