From b38b28dc148d746c512b12f0a3c5eb713008ca0a Mon Sep 17 00:00:00 2001
From: enured <enis.nuredini@uzh.ch>
Date: Mon, 21 Mar 2022 17:34:16 +0100
Subject: [PATCH] =?UTF-8?q?F9052=20CodeMirror=20feature=20f=C3=BCr=20im=20?=
 =?UTF-8?q?Report=20angepasst:=20Fensterr=C3=BCckmeldung=20ersetzt=20durch?=
 =?UTF-8?q?=20kurzzeitig=20erscheinenden=20Badge=20unter=20dem=20Button.?=
 =?UTF-8?q?=20Externes=20Fenster=20wird=20von=20Anfang=20an=20mit=20passen?=
 =?UTF-8?q?der=20URL=20geladen.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 javascript/src/Helper/codemirror.js | 24 +++++++++++++++++-------
 1 file changed, 17 insertions(+), 7 deletions(-)

diff --git a/javascript/src/Helper/codemirror.js b/javascript/src/Helper/codemirror.js
index 74902794c..46a2c8fc2 100644
--- a/javascript/src/Helper/codemirror.js
+++ b/javascript/src/Helper/codemirror.js
@@ -108,6 +108,11 @@ $(document).ready(function(){
     var urlParams = new URLSearchParams(window.location.search);
     var ttContentParam = urlParams.get('tt-content');
     var pageId = urlParams.get('id');
+    if(pageId === null){
+        pageId = '';
+    }else{
+        pageId = 'id='+pageId+'&';
+    }
 
     if(ttContentParam !== null && $(targetEditReportButton).next("#"+ttContentParam)[0] !== undefined){
         var formContent = $($(targetEditReportButton).next("#"+ttContentParam)[0].outerHTML);
@@ -117,18 +122,23 @@ $(document).ready(function(){
     // execute changes(post) and reload page with id of tt-content as get parameter. Staying in same window with new content.
     $(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')){
+        $('<div style="text-align: right; margin-top: 10px;"><span style="background-color: green;" class="badge badge-success">Saved</span></div>')
+            .insertAfter('.btn-default')
+            .delay(3000)
+            .fadeOut(function() {
+                $(this).remove();
+            });
+        if(window.location.search !== '?'+pageId+"tt-content="+$('form').attr('id')){
             window.location.href = '//' + location.host + location.pathname + "?" +pageId+ "tt-content=" + $('form').attr('id');
         }
         return false;
     });
 
+    // Refresh new window with correct url
+    if($(externWindow).length !== 0 && window.location.search !== '?'+pageId+"tt-content="+$('form').attr('id')){
+        window.location.href = '//' + location.host + location.pathname + "?" +pageId+ "tt-content=" + $('form').attr('id');
+    }
+
     // enable CodeMirror for extern window
     $(externWindow).children("[class=qfq-codemirror]").each(
         function () {
-- 
GitLab