From 4b289b86bb5853ac2b59c370d3352a56fe8afc69 Mon Sep 17 00:00:00 2001
From: "florian.azizian" <florian.azizian@maarch.org>
Date: Fri, 21 Feb 2020 15:05:12 +0100
Subject: [PATCH] FIX #12091 TIME 0:20 redirect after close + ts error

---
 src/frontend/app/actions/actions.service.ts     | 7 +++++--
 src/frontend/app/notes/note-editor.component.ts | 4 ++--
 2 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/src/frontend/app/actions/actions.service.ts b/src/frontend/app/actions/actions.service.ts
index e5b623b1bf2..b5383b3dc6b 100644
--- a/src/frontend/app/actions/actions.service.ts
+++ b/src/frontend/app/actions/actions.service.ts
@@ -304,15 +304,18 @@ export class ActionsService {
             tap((result: any) => {
                 this.endAction(result);
                 let firstGroup: number = 0;
+                let redirectAfterClose = '';
                 this.headerService.user.groups.filter((group: any) => group.can_index === true).forEach((group: any) => {
                     if (firstGroup == 0) {
                         firstGroup = group.id;
                     }
                     if (group.id == this.currentGroupId) {
-                        this.router.navigate(['/indexing/' + this.currentGroupId]);
+                        redirectAfterClose = '/indexing/' + this.currentGroupId;
                     }
                 });
-                if (firstGroup == 0) {
+                if (redirectAfterClose != '') {
+                    this.router.navigate([redirectAfterClose]);
+                } else if (firstGroup == 0) {
                     this.router.navigate(['/home']);
                 } else {
                     this.router.navigate(['/indexing/' + firstGroup]);
diff --git a/src/frontend/app/notes/note-editor.component.ts b/src/frontend/app/notes/note-editor.component.ts
index 532ea4dd494..a36d5781854 100644
--- a/src/frontend/app/notes/note-editor.component.ts
+++ b/src/frontend/app/notes/note-editor.component.ts
@@ -134,7 +134,7 @@ export class NoteEditorComponent implements OnInit {
     getTemplatesNote() {
         if (this.templatesNote.length == 0) {
             let params = {};
-            if (this.resIds.length == 1) {
+            if (!this.functions.empty(this.resIds) && this.resIds.length == 1) {
                 params['resId'] = this.resIds[0];
             }
             this.http.get("../../rest/notesTemplates", { params: params })
@@ -149,7 +149,7 @@ export class NoteEditorComponent implements OnInit {
         return new Promise((resolve, reject) => {
             if (this.entities.length == 0) {
                 let params = {};
-                if (this.resIds.length == 1) {
+                if (!this.functions.empty(this.resIds) && this.resIds.length == 1) {
                     params['resId'] = this.resIds[0];
                 }
                 this.http.get("../../rest/entities").pipe(
-- 
GitLab