Implement that recipe ingredients can have arbitrary quantity units (references #32)

This commit is contained in:
Bernd Bestel
2018-08-09 17:24:04 +02:00
parent 3e73a44576
commit 71b9d11ff5
8 changed files with 119 additions and 18 deletions

View File

@@ -2,7 +2,7 @@
{
e.preventDefault();
var jsonData = $('#recipe-pos-form').serializeJSON();
var jsonData = $('#recipe-pos-form').serializeJSON({ checkboxUncheckedValue: "0" });
jsonData.recipe_id = Grocy.EditObjectParentId;
console.log(jsonData);
if (Grocy.EditMode === 'create')
@@ -44,7 +44,10 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
Grocy.Api.Get('stock/get-product-details/' + productId,
function (productDetails)
{
$('#amount_qu_unit').text(productDetails.quantity_unit_purchase.name);
if (!$("#only_check_single_unit_in_stock").is(":checked"))
{
$("#qu_id").val(productDetails.quantity_unit_stock.id);
}
$('#amount').focus();
Grocy.FrontendHelpers.ValidateForm('recipe-pos-form');
},
@@ -76,12 +79,12 @@ $('#amount').on('focus', function(e)
}
});
$('#recipe-pos-form input').keyup(function (event)
$('#recipe-pos-form input').keyup(function(event)
{
Grocy.FrontendHelpers.ValidateForm('recipe-pos-form');
});
$('#recipe-pos-form input').keydown(function (event)
$('#recipe-pos-form input').keydown(function(event)
{
if (event.keyCode === 13) //Enter
{
@@ -96,3 +99,16 @@ $('#recipe-pos-form input').keydown(function (event)
}
}
});
$("#only_check_single_unit_in_stock").on("click", function()
{
if (this.checked)
{
$("#qu_id").removeAttr("disabled");
}
else
{
$("#qu_id").attr("disabled", "");
Grocy.Components.ProductPicker.GetPicker().trigger("change");
}
});