Fix new recipe creation when reloading the /recipes/new page (fixes #536)

This commit is contained in:
Bernd Bestel 2020-02-01 18:16:44 +01:00
parent 23efe0c87a
commit ad9f336035
No known key found for this signature in database
GPG Key ID: 71BD34C0D4891300
2 changed files with 9 additions and 1 deletions

View File

@ -6,5 +6,6 @@
- Optimized the new compact view (there was a little too much white space at the sides of the page)
### Recipe improvements/fixes
- Fixed that when editing a recipe ingredient which had "Only check if a single unit is in stock" set, not any quantity unit could be picked and the amount stayed empty
- Optimized the ordering of the inputs on the recipe ingredient edit page (moved "Only check if a single unit is in stock" before the amount)
- Fixed that when editing a recipe ingredient which had "Only check if a single unit is in stock" set, not any quantity unit could be picked and the amount stayed empty
- Fixed that when reloading the "new recipe"-page (or when it gets auto-reloaded due to "Auto reload on external changes" is enabled), for each reload a new recipe was created

View File

@ -381,3 +381,10 @@ Grocy.Components.ProductPicker.GetPicker().on('change', function(e)
// Just save the current recipe on every change of the product picker as a workflow could be started which leaves the page...
Grocy.Api.Put('objects/recipes/' + Grocy.EditObjectId, $('#recipe-form').serializeJSON(), function () { }, function () { });
});
// As the /recipe/new route immediately creates a new recipe on load,
// always replace the current location by the created recipes edit page location
if (window.location.pathname.toLowerCase() === "/recipe/new")
{
window.history.replaceState(null, null, U("/recipe/" + Grocy.EditObjectId));
}