new: add quick edit links for article, package and tariff on offer form
This commit is contained in:
@@ -14,43 +14,64 @@
|
|||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="col-12">
|
<div class="col-12">
|
||||||
@include('components.form.select', [
|
<div class="d-flex align-items-end">
|
||||||
'name' => 'article_id',
|
<div class="flex-grow-1">
|
||||||
'id_name' => 'article_id',
|
@include('components.form.select', [
|
||||||
'list' => $articles ?? null,
|
'name' => 'article_id',
|
||||||
'value' => $offer['article_id'] ?? null,
|
'id_name' => 'article_id',
|
||||||
'with_empty' => '',
|
'list' => $articles ?? null,
|
||||||
'class' => 'select2 select_article',
|
'value' => $offer['article_id'] ?? null,
|
||||||
'label' => 'Article',
|
'with_empty' => '',
|
||||||
'required' => true,
|
'class' => 'select2 select_article',
|
||||||
])
|
'label' => 'Article',
|
||||||
|
'required' => true,
|
||||||
|
])
|
||||||
|
</div>
|
||||||
|
<a id="edit-article-link" href="#" class="btn btn-sm btn-outline-secondary ml-2 mb-1" title="Modifier l'article" style="display:none;">
|
||||||
|
<i class="fa fa-external-link"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row mb-3">
|
<div class="row mb-3">
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
@include('components.form.select', [
|
<div class="d-flex align-items-end">
|
||||||
'name' => 'variation_id',
|
<div class="flex-grow-1">
|
||||||
'id_name' => 'variation_id',
|
@include('components.form.select', [
|
||||||
'list' => $variations ?? null,
|
'name' => 'variation_id',
|
||||||
'value' => $offer['variation_id'] ?? null,
|
'id_name' => 'variation_id',
|
||||||
'with_empty' => '',
|
'list' => $variations ?? null,
|
||||||
'class' => 'select2 select_variation',
|
'value' => $offer['variation_id'] ?? null,
|
||||||
'label' => __('shop.packages.name'),
|
'with_empty' => '',
|
||||||
'required' => true,
|
'class' => 'select2 select_variation',
|
||||||
])
|
'label' => __('shop.packages.name'),
|
||||||
|
'required' => true,
|
||||||
|
])
|
||||||
|
</div>
|
||||||
|
<a id="edit-variation-link" href="#" class="btn btn-sm btn-outline-secondary ml-2 mb-1" title="Modifier la déclinaison" style="display:none;">
|
||||||
|
<i class="fa fa-external-link"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
@include('components.form.select', [
|
<div class="d-flex align-items-end">
|
||||||
'name' => 'tariff_id',
|
<div class="flex-grow-1">
|
||||||
'id_name' => 'tariff_id',
|
@include('components.form.select', [
|
||||||
'list' => $tariffs ?? null,
|
'name' => 'tariff_id',
|
||||||
'value' => $offer['tariff_id'] ?? null,
|
'id_name' => 'tariff_id',
|
||||||
'with_empty' => '',
|
'list' => $tariffs ?? null,
|
||||||
'class' => 'select2 select_tariffs',
|
'value' => $offer['tariff_id'] ?? null,
|
||||||
'label' => 'Tarif',
|
'with_empty' => '',
|
||||||
'required' => true,
|
'class' => 'select2 select_tariffs',
|
||||||
])
|
'label' => 'Tarif',
|
||||||
|
'required' => true,
|
||||||
|
])
|
||||||
|
</div>
|
||||||
|
<a id="edit-tariff-link" href="#" class="btn btn-sm btn-outline-secondary ml-2 mb-1" title="Modifier le tarif" style="display:none;">
|
||||||
|
<i class="fa fa-external-link"></i>
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
@include('components.form.input', [
|
@include('components.form.input', [
|
||||||
@@ -122,5 +143,34 @@
|
|||||||
initChevron();
|
initChevron();
|
||||||
initSaveForm('#offer-form');
|
initSaveForm('#offer-form');
|
||||||
initSelect2();
|
initSelect2();
|
||||||
|
function updateEditLink(selectId, linkId, routeTemplate) {
|
||||||
|
var val = $('#' + selectId).val();
|
||||||
|
var $link = $('#' + linkId);
|
||||||
|
if (val) {
|
||||||
|
$link.attr('href', routeTemplate.replace('__ID__', val)).show();
|
||||||
|
} else {
|
||||||
|
$link.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
var articleRoute = '{{ route('Admin.Shop.Articles.edit', ['id' => '__ID__']) }}';
|
||||||
|
var variationRoute = '{{ route('Admin.Shop.Variations.edit', ['id' => '__ID__']) }}';
|
||||||
|
var tariffRoute = '{{ route('Admin.Shop.Tariffs.edit', ['id' => '__ID__']) }}';
|
||||||
|
|
||||||
|
// Init on page load
|
||||||
|
updateEditLink('article_id', 'edit-article-link', articleRoute);
|
||||||
|
updateEditLink('variation_id', 'edit-variation-link', variationRoute);
|
||||||
|
updateEditLink('tariff_id', 'edit-tariff-link', tariffRoute);
|
||||||
|
|
||||||
|
// Update on change
|
||||||
|
$('#article_id').on('change', function() {
|
||||||
|
updateEditLink('article_id', 'edit-article-link', articleRoute);
|
||||||
|
});
|
||||||
|
$('#variation_id').on('change', function() {
|
||||||
|
updateEditLink('variation_id', 'edit-variation-link', variationRoute);
|
||||||
|
});
|
||||||
|
$('#tariff_id').on('change', function() {
|
||||||
|
updateEditLink('tariff_id', 'edit-tariff-link', tariffRoute);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
@endpush
|
@endpush
|
||||||
|
|||||||
Reference in New Issue
Block a user