This commit is contained in:
Ludovic CANDELLIER
2021-03-27 01:16:37 +01:00
parent 22fa3d3246
commit 4855254a7f
21 changed files with 219 additions and 137 deletions

View File

@@ -4,8 +4,6 @@
'breadcrumb' => [__('Shop.articles.title'), __('Shop.articles.add')]
])
@include('boilerplate::load.fileinput')
@section('content')
{{ Form::open(['route' => 'Shop.Admin.Articles.store', 'id' => 'article-form', 'autocomplete' => 'off', 'files' => true]) }}

View File

@@ -4,8 +4,6 @@
'breadcrumb' => ['Articles']
])
@include('boilerplate::load.fileinput')
@section('content')
{{ Form::open(['route' => 'Shop.Admin.Articles.store', 'id' => 'article-form', 'autocomplete' => 'off', 'files' => true]) }}

View File

@@ -1,5 +1,6 @@
@include('boilerplate::load.fileinput')
@include('boilerplate::load.select2')
@include('load.set_options')
@include('boilerplate::load.tinymce')
<div class="row mt-3">

View File

@@ -12,7 +12,7 @@
</div>
<div class="col-6">
{{ Form::label('model_id', 'Produit') }}<br>
@include('components.select2', ['name' => 'product_id', 'id_name' => 'product_id', 'value' => isset($product_id) ? $product_id : null, 'class' => 'select2 form-control'])
@include('components.select', ['name' => 'product_id', 'id_name' => 'product_id', 'list' => $products ?? [], 'value' => isset($product_id) ? $product_id : null, 'class' => 'select2 form-control'])
</div>
</div>
@@ -64,7 +64,16 @@
});
$('#product_type').change( function() {
loadVarieties();
var product_type = $(this).val();
switch (product_type) {
case 'App\\Models\\Botanic\\Specie':
loadSpecies();
break;
case 'App\\Models\\Botanic\\Variety':
default:
loadVarieties();
break;
}
});
function loadVarieties() {
@@ -73,12 +82,28 @@
method : 'POST',
data: {model: $('#product_type').val()},
success : function(data) {
$("#product_id").select2({data: data});
$("#product_id").trigger('change');
setOptions('#product_id', data);
// $("#product_id").select2({data: data});
// $("#product_id").trigger('change');
}
});
}
loadVarieties();
function loadSpecies() {
console.log('loadSpecies');
console.log($('#product_type').val());
$.ajax({
url : '{{ route('Botanic.Admin.Species.getSelect') }}',
method : 'POST',
data: {model: $('#product_type').val()},
success : function(data) {
setOptions('#product_id', data);
// $("#product_id").select2({data: data});
// $("#product_id").trigger('change');
}
});
}
// loadVarieties();
</script>
@endpush

View File

@@ -0,0 +1,52 @@
@include('Shop.Admin.Articles.partials.generic_prices.block_generic_price_new')
<div id="append_generic_price" class="row">
@include('Shop.Admin.Articles.partials.generic_prices.list-generic_prices')
</div>
<button type="button" class="btn btn-sm btn-primary add-new-generic_price">Associer un tarif générique<i class="fa fa-plus"></i></button>
@include('components.select-tree', ['name' => "article_price_generic_id", 'value' => $price['article_price_generic_id'] ?? null, 'list' => $price_generics ?? null, 'required' => false, 'class' => 'form-control-sm w-100'])
@push('js')
<script>
function append_generic_price() {
// handle_append_attribute();
$('.select2').select2();
// handle_change_attribute();
// load_attribute_values($('.attributes-value'), $('.attributes-family').val());
}
$("#append_generic_price").appender({
rowSection: '.row-new-generic_price',
type: '.row-generic_price',
addBtn: '.add-new-generic_price',
appendEffect: 'slide',
addClass: 'animated bounceInLeft',
rowNumber: '.row-generic_price-number',
deleteBtn: '.delete-new-generic_price-btn',
callback: append_generic_price,
rowNumberStart: 2,
hideSection: true
});
function handle_delete_generic_price() {
$('.delete-generic_price-btn').click(function() {
var $selector = $(this).parents('.row-generic_price');
var id = $selector.find('.generic_price_id').val();
/*
confirm_delete(id, "{## route('Shop.Admin.ArticlePrices.destroy') }}", function() {
$selector.remove();
});
*/
});
}
</script>
@endpush

View File

@@ -8,8 +8,8 @@
<script>
$(function () {
handle_delete_price();
init_attribute_values();
handle_change_attribute();
init_unities();
handle_change_package();
handle_prices();
handle_prices_taxed();
});

View File

@@ -12,8 +12,8 @@
function append_price() {
// handle_append_attribute();
$('.select2').select2();
handle_change_attribute();
load_attribute_values($('.unities'), $('.price-family').val());
handle_change_package();
load_unities($('.unities'), $('.package').val());
}
$("#append_price").appender({
@@ -29,35 +29,36 @@
hideSection: true
});
function handle_change_attribute() {
$('.price-family').change( function() {
var family_id = $(this).val();
var $family = $(this);
var $parent = $family.parent().parent();
function handle_change_package() {
$('.package').change( function() {
var package_id = $(this).val();
var $package = $(this);
var $parent = $package.parent().parent();
var $selector = $parent.find('.unities');
load_attribute_values($selector, family_id);
load_unities($selector, package_id);
});
}
function init_attribute_values() {
$('.price-family').each( function() {
var family_id = $(this).val();
var $family = $(this);
var $parent = $family.parent().parent();
function init_unities() {
$('.package').each( function() {
var package_id = $(this).val();
var $package = $(this);
var $parent = $package.parent().parent();
var $selector = $parent.find('.unities');
load_attribute_values($selector, family_id);
load_unities($selector, package_id);
value_id = $selector.data('id');
$selector.val(value_id).trigger('change');
});
}
function load_attribute_values($selector, family_id) {
function load_unities($selector, package_id) {
$.ajax({
url : "{{ route('Shop.Admin.Unities.getOptionsByFamily') }}",
url : "{{ route('Shop.Admin.Unities.getOptionsByPackage') }}",
method : 'POST',
data: { family_id: family_id },
data: { package_id: package_id },
success : function(data) {
$selector.empty().select2({data: data});
setOptions($selector, data);
// $selector.empty().select2({data: data});
}
});
}

View File

@@ -61,7 +61,16 @@
})
}
function handle_packages() {
$('.delete-price-btn').click(function() {
var $selector = $(this).parents('.row-price');
var id = $selector.find('.price_id').val();
confirm_delete(id, laroute.route('Shop.Admin.PriceGenericValues.destroy', {id : id}), function() {
$selector.remove();
});
});
}
</script>
@endpush

View File

@@ -5,5 +5,5 @@
])
@section('content')
@include('components.datatable', ['route' => route('Shop.Admin.TagGroups.index'), 'model' => 'TagGroups'])
@include('components.datatable', ['route' => route('Shop.Admin.TagGroups.index'), 'model' => 'tag_groups'])
@endsection