From 7d6b76effb02a21d18453d513a6806c642c184b2 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Sun, 12 Jan 2025 17:40:39 +0100 Subject: [PATCH] Fixed Userfield initialization on /purchase and /inventory (fixes #2581) --- changelog/77_UNRELEASED_xxxx-xx-xx.md | 2 +- public/viewjs/inventory.js | 2 ++ public/viewjs/purchase.js | 2 ++ public/viewjs/userfieldform.js | 11 ++++++++--- 4 files changed, 13 insertions(+), 4 deletions(-) diff --git a/changelog/77_UNRELEASED_xxxx-xx-xx.md b/changelog/77_UNRELEASED_xxxx-xx-xx.md index 5152aa25..d63fcec1 100644 --- a/changelog/77_UNRELEASED_xxxx-xx-xx.md +++ b/changelog/77_UNRELEASED_xxxx-xx-xx.md @@ -53,7 +53,7 @@ ### Userfields -- xxx +- Fixed that Userfield default values were not initialized for the `stock` entity (so affecting the purchase and inventory page) ### General diff --git a/public/viewjs/inventory.js b/public/viewjs/inventory.js index 89ca19f8..9d876b0d 100644 --- a/public/viewjs/inventory.js +++ b/public/viewjs/inventory.js @@ -548,3 +548,5 @@ if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_LABEL_PRINTER) } }); } + +Grocy.Components.UserfieldsForm.Load(); diff --git a/public/viewjs/purchase.js b/public/viewjs/purchase.js index e53e4159..072d6c33 100644 --- a/public/viewjs/purchase.js +++ b/public/viewjs/purchase.js @@ -738,3 +738,5 @@ if (Grocy.FeatureFlags.GROCY_FEATURE_FLAG_LABEL_PRINTER) } }); } + +Grocy.Components.UserfieldsForm.Load(); diff --git a/public/viewjs/userfieldform.js b/public/viewjs/userfieldform.js index 1823500a..1c5ac0fb 100644 --- a/public/viewjs/userfieldform.js +++ b/public/viewjs/userfieldform.js @@ -111,13 +111,18 @@ $("#type").on("change", function(e) $("#default-value-group.userfield-type-" + value).removeClass("d-none"); }); -$('#entity').focus(); - if (GetUriParam("entity")) { $("#entity").val(GetUriParam("entity")); $("#entity").trigger("change"); - $('#name').focus(); + setTimeout(function() + { + $('#name').focus(); + }, 500); +} +else +{ + $('#entity').focus(); } $("#type").trigger("change");