From d9a3c5169e1e288279fe31f206111bcca16b98ef Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Wed, 16 Dec 2020 17:51:05 +0100 Subject: [PATCH] Fixed product copy source / default value prefilling handling (fixes #1179) --- public/viewjs/productform.js | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/public/viewjs/productform.js b/public/viewjs/productform.js index 3d402fb4..dac03001 100644 --- a/public/viewjs/productform.js +++ b/public/viewjs/productform.js @@ -266,24 +266,6 @@ $("#delete-current-product-picture-button").on("click", function(e) $("#product-picture-label-none").removeClass("d-none"); }); -if (Grocy.EditMode === 'create') -{ - if (Grocy.UserSettings.product_presets_location_id.toString() !== '-1') - { - $("#location_id").val(Grocy.UserSettings.product_presets_location_id); - } - - if (Grocy.UserSettings.product_presets_product_group_id.toString() !== '-1') - { - $("#product_group_id").val(Grocy.UserSettings.product_presets_product_group_id); - } - - if (Grocy.UserSettings.product_presets_qu_id.toString() !== '-1') - { - $("select.input-group-qu").val(Grocy.UserSettings.product_presets_qu_id); - } -} - var quConversionsTable = $('#qu-conversions-table-products').DataTable({ 'order': [[1, 'asc']], "orderFixed": [[4, 'asc']], @@ -470,3 +452,20 @@ if (Grocy.EditMode == "create" && GetUriParam("copy-of") != undefined) } ); } +else if (Grocy.EditMode === 'create') +{ + if (Grocy.UserSettings.product_presets_location_id.toString() !== '-1') + { + $("#location_id").val(Grocy.UserSettings.product_presets_location_id); + } + + if (Grocy.UserSettings.product_presets_product_group_id.toString() !== '-1') + { + $("#product_group_id").val(Grocy.UserSettings.product_presets_product_group_id); + } + + if (Grocy.UserSettings.product_presets_qu_id.toString() !== '-1') + { + $("select.input-group-qu").val(Grocy.UserSettings.product_presets_qu_id); + } +}