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="row mb-3">
|
||||
<div class="col-12">
|
||||
@include('components.form.select', [
|
||||
'name' => 'article_id',
|
||||
'id_name' => 'article_id',
|
||||
'list' => $articles ?? null,
|
||||
'value' => $offer['article_id'] ?? null,
|
||||
'with_empty' => '',
|
||||
'class' => 'select2 select_article',
|
||||
'label' => 'Article',
|
||||
'required' => true,
|
||||
])
|
||||
<div class="d-flex align-items-end">
|
||||
<div class="flex-grow-1">
|
||||
@include('components.form.select', [
|
||||
'name' => 'article_id',
|
||||
'id_name' => 'article_id',
|
||||
'list' => $articles ?? null,
|
||||
'value' => $offer['article_id'] ?? null,
|
||||
'with_empty' => '',
|
||||
'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 class="row mb-3">
|
||||
<div class="col-4">
|
||||
@include('components.form.select', [
|
||||
'name' => 'variation_id',
|
||||
'id_name' => 'variation_id',
|
||||
'list' => $variations ?? null,
|
||||
'value' => $offer['variation_id'] ?? null,
|
||||
'with_empty' => '',
|
||||
'class' => 'select2 select_variation',
|
||||
'label' => __('shop.packages.name'),
|
||||
'required' => true,
|
||||
])
|
||||
<div class="d-flex align-items-end">
|
||||
<div class="flex-grow-1">
|
||||
@include('components.form.select', [
|
||||
'name' => 'variation_id',
|
||||
'id_name' => 'variation_id',
|
||||
'list' => $variations ?? null,
|
||||
'value' => $offer['variation_id'] ?? null,
|
||||
'with_empty' => '',
|
||||
'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 class="col-4">
|
||||
@include('components.form.select', [
|
||||
'name' => 'tariff_id',
|
||||
'id_name' => 'tariff_id',
|
||||
'list' => $tariffs ?? null,
|
||||
'value' => $offer['tariff_id'] ?? null,
|
||||
'with_empty' => '',
|
||||
'class' => 'select2 select_tariffs',
|
||||
'label' => 'Tarif',
|
||||
'required' => true,
|
||||
])
|
||||
<div class="d-flex align-items-end">
|
||||
<div class="flex-grow-1">
|
||||
@include('components.form.select', [
|
||||
'name' => 'tariff_id',
|
||||
'id_name' => 'tariff_id',
|
||||
'list' => $tariffs ?? null,
|
||||
'value' => $offer['tariff_id'] ?? null,
|
||||
'with_empty' => '',
|
||||
'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 class="col-4">
|
||||
@include('components.form.input', [
|
||||
@@ -122,5 +143,34 @@
|
||||
initChevron();
|
||||
initSaveForm('#offer-form');
|
||||
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>
|
||||
@endpush
|
||||
|
||||
Reference in New Issue
Block a user