Also show the stock QU (as on all other places) after a product is selected on the chore edit page (references #279)

This commit is contained in:
Bernd Bestel 2019-09-18 10:08:59 +02:00
parent 3df44697bf
commit ba089a3d79
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300

View File

@ -106,6 +106,8 @@ setTimeout(function()
// Click twice to trigger on-click but not change the actual checked state
$("#consume_product_on_execution").click();
$("#consume_product_on_execution").click();
Grocy.Components.ProductPicker.GetPicker().trigger('change');
}, 100);
$('.input-group-chore-period-type').on('change', function(e)
@ -200,3 +202,22 @@ $("#consume_product_on_execution").on("click", function()
Grocy.FrontendHelpers.ValidateForm("chore-form");
});
Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
{
var productId = $(e.target).val();
if (productId)
{
Grocy.Api.Get('stock/products/' + productId,
function(productDetails)
{
$('#amount_qu_unit').text(productDetails.quantity_unit_stock.name);
},
function(xhr)
{
console.error(xhr);
}
);
}
});