From da2c8d48ac741b53c63f210032d5c115aae52866 Mon Sep 17 00:00:00 2001 From: Bernd Bestel Date: Sat, 19 Oct 2019 10:33:46 +0200 Subject: [PATCH] Changelog and code optimizations for pull request #420 --- changelog/55_UNRELEASED_2019-xx-xx.md | 3 ++- public/viewjs/productform.js | 31 +++++++++++++++++---------- 2 files changed, 22 insertions(+), 12 deletions(-) diff --git a/changelog/55_UNRELEASED_2019-xx-xx.md b/changelog/55_UNRELEASED_2019-xx-xx.md index 14a5735b..2d30b5dd 100644 --- a/changelog/55_UNRELEASED_2019-xx-xx.md +++ b/changelog/55_UNRELEASED_2019-xx-xx.md @@ -1,6 +1,7 @@ ### Calendar improvements - Improved that meal plan events in the iCal calendar export now contain a link to the appropriate meal plan week in the body of the event (thanks @kriddles) -### General & other fixes +### General & other improvements/fixes - Fixed that the meal plan menu entry (sidebar) was not visible when the calendar was disabled (`FEATURE_FLAG_CALENDAR`) (thanks @lwis) - Slightly optimized table loading & search performance (thanks @lwis) +- For integration: If a `GET` parameter `closeAfterCreation` is passed to the product edit page, the window will be closed on save (due to Browser restrictions, this only works when the window was opened from JavaScript) (thanks @Forceu) diff --git a/public/viewjs/productform.js b/public/viewjs/productform.js index d025290f..4be401d7 100644 --- a/public/viewjs/productform.js +++ b/public/viewjs/productform.js @@ -49,7 +49,11 @@ Grocy.Api.UploadFile($("#product-picture")[0].files[0], 'productpictures', jsonData.picture_file_name, function(result) { - if (redirectDestination == "reload") + if (GetUriParam("closeAfterCreation") !== undefined) + { + window.close(); + } + else if (redirectDestination == "reload") { window.location.reload(); } @@ -67,14 +71,11 @@ } else { - /* If the GET parameter "closeAfterCreation" was passed to the form, it will - automatically close after creating the product. This only works if the window - was opened with javascript */ - if (window.location.href.toLowerCase().includes("closeaftercreation")) - { - window.close(); - } - if (redirectDestination == "reload") + if (GetUriParam("closeAfterCreation") !== undefined) + { + window.close(); + } + else if (redirectDestination == "reload") { window.location.reload(); } @@ -119,7 +120,11 @@ Grocy.Api.UploadFile($("#product-picture")[0].files[0], 'productpictures', jsonData.picture_file_name, function(result) { - if (redirectDestination == "reload") + if (GetUriParam("closeAfterCreation") !== undefined) + { + window.close(); + } + else if (redirectDestination == "reload") { window.location.reload(); } @@ -137,7 +142,11 @@ } else { - if (redirectDestination == "reload") + if (GetUriParam("closeAfterCreation") !== undefined) + { + window.close(); + } + else if (redirectDestination == "reload") { window.location.reload(); }