mirror of
https://github.com/grocy/grocy.git
synced 2025-08-20 04:12:59 +00:00
Always save the recipe before leaving/reloading the page (this now closes #520)
This commit is contained in:
@@ -133,11 +133,10 @@ $(document).on('click', '.recipe-pos-delete-button', function(e)
|
|||||||
{
|
{
|
||||||
if (result === true)
|
if (result === true)
|
||||||
{
|
{
|
||||||
Grocy.Api.Put('objects/recipes/' + Grocy.EditObjectId, $('#recipe-form').serializeJSON(), function() { }, function() { });
|
|
||||||
Grocy.Api.Delete('objects/recipes_pos/' + objectId, {},
|
Grocy.Api.Delete('objects/recipes_pos/' + objectId, {},
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
window.location.href = U('/recipe/' + Grocy.EditObjectId);
|
window.postMessage(WindowMessageBag("IngredientsChanged"), Grocy.BaseUrl);
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
@@ -171,11 +170,10 @@ $(document).on('click', '.recipe-include-delete-button', function(e)
|
|||||||
{
|
{
|
||||||
if (result === true)
|
if (result === true)
|
||||||
{
|
{
|
||||||
Grocy.Api.Put('objects/recipes/' + Grocy.EditObjectId, $('#recipe-form').serializeJSON(), function() { }, function() { });
|
|
||||||
Grocy.Api.Delete('objects/recipes_nestings/' + objectId, {},
|
Grocy.Api.Delete('objects/recipes_nestings/' + objectId, {},
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
window.location.href = U('/recipe/' + Grocy.EditObjectId);
|
window.postMessage(WindowMessageBag("IngredientsChanged"), Grocy.BaseUrl);
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
@@ -305,7 +303,7 @@ $('#save-recipe-include-button').on('click', function(e)
|
|||||||
Grocy.Api.Post('objects/recipes_nestings', jsonData,
|
Grocy.Api.Post('objects/recipes_nestings', jsonData,
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
window.location.href = U('/recipe/' + Grocy.EditObjectId);
|
window.postMessage(WindowMessageBag("IngredientsChanged"), Grocy.BaseUrl);
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
@@ -318,7 +316,7 @@ $('#save-recipe-include-button').on('click', function(e)
|
|||||||
Grocy.Api.Put('objects/recipes_nestings/' + nestingId, jsonData,
|
Grocy.Api.Put('objects/recipes_nestings/' + nestingId, jsonData,
|
||||||
function(result)
|
function(result)
|
||||||
{
|
{
|
||||||
window.location.href = U('/recipe/' + Grocy.EditObjectId);
|
window.postMessage(WindowMessageBag("IngredientsChanged"), Grocy.BaseUrl);
|
||||||
},
|
},
|
||||||
function(xhr)
|
function(xhr)
|
||||||
{
|
{
|
||||||
@@ -345,7 +343,16 @@ $(window).on("message", function(e)
|
|||||||
|
|
||||||
if (data.Message === "IngredientsChanged")
|
if (data.Message === "IngredientsChanged")
|
||||||
{
|
{
|
||||||
window.location.href = U('/recipe/' + Grocy.EditObjectId);
|
Grocy.Api.Put('objects/recipes/' + Grocy.EditObjectId, $('#recipe-form').serializeJSON(),
|
||||||
|
function(result)
|
||||||
|
{
|
||||||
|
window.location.href = U('/recipe/' + Grocy.EditObjectId);
|
||||||
|
},
|
||||||
|
function(xhr)
|
||||||
|
{
|
||||||
|
console.error(xhr);
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user