From b2402f144888117828edc36bad3b6fae04701170 Mon Sep 17 00:00:00 2001
From: enured <enis.nuredini@uzh.ch>
Date: Mon, 14 Mar 2022 15:25:12 +0100
Subject: [PATCH] F9052: Fix -> Now editing in extern window works parallel
 while a form is open in main page.

---
 javascript/src/Helper/codemirror.js | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/javascript/src/Helper/codemirror.js b/javascript/src/Helper/codemirror.js
index ea4cee8b9..74902794c 100644
--- a/javascript/src/Helper/codemirror.js
+++ b/javascript/src/Helper/codemirror.js
@@ -107,6 +107,7 @@ $(document).ready(function(){
     // Show same content editor with refreshed data again after save. Control it with the given get parameter. First fetch only needed html content again (form) and open it in same window.
     var urlParams = new URLSearchParams(window.location.search);
     var ttContentParam = urlParams.get('tt-content');
+    var pageId = urlParams.get('id');
 
     if(ttContentParam !== null && $(targetEditReportButton).next("#"+ttContentParam)[0] !== undefined){
         var formContent = $($(targetEditReportButton).next("#"+ttContentParam)[0].outerHTML);
@@ -117,8 +118,13 @@ $(document).ready(function(){
     $(externWindow).submit(function() {
         $.post($(externWindow).attr('action'),$(externWindow).serializeArray());
         alert("Changes have been saved. Reload your primary window after that.");
+        if(pageId === null){
+            pageId = '';
+        }else{
+            pageId = 'id='+pageId+'&';
+        }
         if(window.location.search !== '?'+"tt-content="+$('form').attr('id')){
-            window.location.href += "?"+"tt-content="+$('form').attr('id');
+            window.location.href = '//' + location.host + location.pathname + "?" +pageId+ "tt-content=" + $('form').attr('id');
         }
         return false;
     });
-- 
GitLab