Recettes : BO, rajout de l'ajax
This commit is contained in:
@@ -11,7 +11,7 @@
|
||||
<td>{$UNITY}</td>
|
||||
<td>{$QUANTITY_PROPOSED}</td>
|
||||
<td class="text-center">
|
||||
<a href="{url path='/admin/module/Recettes/remove-product/%recipeId/%pseId' recipeId=$recipe_id pseId=$PSE_ID}" class="delete-product"><i class="glyphicon glyphicon-trash"></i></a>
|
||||
<a href="{url path='/admin/module/Recettes/remove-product/%recipeId/%pseId/%contentId' recipeId=$recipe_id pseId=$PSE_ID contentId=$content_id}" class="delete-product"><i class="glyphicon glyphicon-trash"></i></a>
|
||||
</td>
|
||||
</tr>
|
||||
{/loop}
|
||||
@@ -26,9 +26,19 @@
|
||||
</tr>
|
||||
{/elseloop}
|
||||
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<input class="form-control" type="text" id="product_ref" autocomplete="off" data-content-id="{$recipe_id}" placeholder="Indiquez une référence de produit">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="3">
|
||||
<input class="form-control" type="text" id="pse_id" autocomplete="off" data-content-id="{$pse_id}" placeholder="Choisissez une déclinaison">
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2">
|
||||
<input class="form-control" type="text" id="product_ref" autocomplete="off" data-content-id="{$content_id}" placeholder="Indiquez une référence de produit">
|
||||
<input class="form-control" type="text" id="quantity" autocomplete="off" placeholder="Saisir une quantité">
|
||||
</td>
|
||||
<td class="text-center">
|
||||
<a href="{url path='/admin/module/Recettes/add-product/%recipeId' recipeId=$recipe_id}" class="btn btn-sm btn-primary add-product"><i class="glyphicon glyphicon-plus-sign"></i></a>
|
||||
|
||||
1
local/modules/Recettes/templates/backOffice/default/js/bootstrap-typeahead.min.js
vendored
Normal file
1
local/modules/Recettes/templates/backOffice/default/js/bootstrap-typeahead.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -0,0 +1,81 @@
|
||||
<script src="{javascript file="js/bootstrap-typeahead.min.js" source="Recettes"}"></script>
|
||||
|
||||
<script>
|
||||
{$langcode = {lang attr="code"}|substr:0:2}
|
||||
|
||||
$(function() {
|
||||
|
||||
function setupTypeAhead() {
|
||||
|
||||
$('#product_ref').typeahead({
|
||||
source: function (query, process) {
|
||||
return $.getJSON(
|
||||
'{url path="/admin/module/Recettes/search-product"}',
|
||||
{
|
||||
query: query
|
||||
},
|
||||
function (data) {
|
||||
process(data)
|
||||
}
|
||||
);
|
||||
},
|
||||
displayText: function (item) {
|
||||
return item.title
|
||||
},
|
||||
afterSelect: function (item) {
|
||||
this.$element[0].value = item.title
|
||||
$('#product_ref').data('product-id', item.id);
|
||||
$("#pse_id").attr('disabled', null);
|
||||
}
|
||||
});
|
||||
|
||||
$('#pse_id').typeahead({
|
||||
source: function (query, process) {
|
||||
return $.getJSON(
|
||||
'{url path="/admin/module/Recettes/search-combination"}',
|
||||
{
|
||||
query: query
|
||||
},
|
||||
function (data) {
|
||||
process(data)
|
||||
}
|
||||
);
|
||||
},
|
||||
displayText: function (item) {
|
||||
return item.title
|
||||
},
|
||||
afterSelect: function (item) {
|
||||
this.$element[0].value = item.title
|
||||
$('#product_ref').data('product-id', item.id);
|
||||
$("#pse_id").attr('disabled', null);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
$(document).on('click', '.add-product', function(event) {
|
||||
event.preventDefault();
|
||||
|
||||
$('#related-products-block').load(
|
||||
$(this).attr('href'),
|
||||
{
|
||||
product_id: $('#product_ref').data('product-id')
|
||||
},
|
||||
function() {
|
||||
setupTypeAhead();
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
setupTypeAhead();
|
||||
$("#pse_id").attr('disabled', 'disabled');
|
||||
$("#quantity").attr('disabled', 'disabled');
|
||||
$(".add-product").attr('disabled', 'disabled');
|
||||
|
||||
});
|
||||
</script>
|
||||
@@ -115,12 +115,12 @@
|
||||
<div class="col-md-4 form-group">
|
||||
<label class="control-label">Produits attachés</label>
|
||||
<div id="related-products-block">
|
||||
{include file='ajax/related-products.html'}
|
||||
{include file="ajax/related-products.html" content_id=$content_id}
|
||||
</div>
|
||||
<br>
|
||||
<label class="control-label">Etapes de la recette</label>
|
||||
<div id="steps-block">
|
||||
{include file='ajax/steps.html'}
|
||||
{include file="ajax/steps.html"}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -110,12 +110,9 @@ div.entete span b {
|
||||
}
|
||||
.table-liste-recettes th {
|
||||
text-align: center !important;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.table-liste-recettes > tbody > tr > td:nth-child(1),
|
||||
.table-liste-recettes > tbody > tr > td:nth-child(2),
|
||||
.table-liste-recettes > tbody > tr > td:nth-child(4),
|
||||
.table-liste-recettes th:nth-child(1),
|
||||
.table-liste-recettes th:nth-child(3) {
|
||||
.table-liste-recettes th {
|
||||
background-color: rgba(128,189,138,0.12);
|
||||
}
|
||||
.table-liste-recettes > tbody > tr > td,
|
||||
|
||||
Reference in New Issue
Block a user