From a0fc06f6ed582b427191b70c1324fa20e0696df8 Mon Sep 17 00:00:00 2001 From: Marc Ole Bulling Date: Sat, 19 Oct 2019 10:26:18 +0200 Subject: [PATCH] Add GET parameter to close window after product creation (#420) * Add GET parameter to close window after product creation PR for issue #419 This only works when the window was opened by Javascript (eg. from a third party plugin like Barcode Buddy) * Added flow if window closing fails If the window could not be closed, the normal flow continues Added comments * Made GET parameter case insensitive --- public/viewjs/productform.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/public/viewjs/productform.js b/public/viewjs/productform.js index ee803124..d025290f 100644 --- a/public/viewjs/productform.js +++ b/public/viewjs/productform.js @@ -67,7 +67,14 @@ } else { - if (redirectDestination == "reload") + /* 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") { window.location.reload(); }