From cd214158335e172c5357d0f3cf8440d78a49c5dd Mon Sep 17 00:00:00 2001
From: "florian.azizian" <florian.azizian@maarch.org>
Date: Tue, 3 Mar 2020 15:29:22 +0100
Subject: [PATCH] FIX #13152 TIME 0:30 does not lock document with viewDoc
 component

---
 src/frontend/app/actions/actions.service.ts | 43 +++++++++++----------
 1 file changed, 22 insertions(+), 21 deletions(-)

diff --git a/src/frontend/app/actions/actions.service.ts b/src/frontend/app/actions/actions.service.ts
index 64c750870dd..2719994ba1e 100644
--- a/src/frontend/app/actions/actions.service.ts
+++ b/src/frontend/app/actions/actions.service.ts
@@ -132,32 +132,35 @@ export class ActionsService {
         }
     }
 
-
     launchAction(action: any, userId: number, groupId: number, basketId: number, resIds: number[], datas: any, lockRes: boolean = true) {
         if (this.setActionInformations(action, userId, groupId, basketId, resIds)) {
             this.loading = true;
             this.lockMode = lockRes;
             this.setResourceInformations(datas);
             if (this.lockMode) {
-                this.http.put(`../../rest/resourcesList/users/${userId}/groups/${groupId}/baskets/${basketId}/lock`, { resources: resIds }).pipe(
-                    tap((data: any) => {
-                        if (this.canExecuteAction(data.lockedResources, data.lockers, resIds)) {
-                            try {
-                                this.lockResource();
-                                this[action.component](action.data);
-                            }
-                            catch (error) {
-                                console.log(error);
-                                console.log(action);
-                                alert(this.lang.actionNotExist);
+                if (action.component == 'viewDoc') {
+                    this[action.component](action.data);
+                } else {
+                    this.http.put(`../../rest/resourcesList/users/${userId}/groups/${groupId}/baskets/${basketId}/lock`, { resources: resIds }).pipe(
+                        tap((data: any) => {
+                            if (this.canExecuteAction(data.lockedResources, data.lockers, resIds)) {
+                                try {
+                                    this.lockResource();
+                                    this[action.component](action.data);
+                                }
+                                catch (error) {
+                                    console.log(error);
+                                    console.log(action);
+                                    alert(this.lang.actionNotExist);
+                                }
                             }
-                        }
-                    }),
-                    catchError((err: any) => {
-                        this.notify.handleErrors(err);
-                        return of(false);
-                    })
-                ).subscribe();
+                        }),
+                        catchError((err: any) => {
+                            this.notify.handleErrors(err);
+                            return of(false);
+                        })
+                    ).subscribe();
+                }
             } else {
                 try {
                     this[action.component]();
@@ -168,7 +171,6 @@ export class ActionsService {
                     alert(this.lang.actionNotExist);
                 }
             }
-
         }
     }
 
@@ -190,7 +192,6 @@ export class ActionsService {
         }
     }
 
-
     lockResource() {
         this.currentResourceLock = setInterval(() => {
             this.http.put(`../../rest/resourcesList/users/${this.currentUserId}/groups/${this.currentGroupId}/baskets/${this.currentBasketId}/lock`, { resources: this.currentResIds }).pipe(
-- 
GitLab