diff --git a/public/viewjs/choreform.js b/public/viewjs/choreform.js index 6753785a..2a25e171 100644 --- a/public/viewjs/choreform.js +++ b/public/viewjs/choreform.js @@ -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); + } + ); + } +});