From 89c221a1c738148426316f5debcd7283e5cc2ee2 Mon Sep 17 00:00:00 2001 From: Alex ORLUC <alex.orluc@maarch.org> Date: Tue, 7 Jul 2020 19:09:41 +0200 Subject: [PATCH] FIX #14199 TIME 0:10 fix unlock resource --- src/frontend/app/actions/actions.service.ts | 3 +++ src/frontend/app/process/process.component.ts | 4 ++- src/frontend/app/signature-book.component.ts | 25 +++++++++++-------- 3 files changed, 21 insertions(+), 11 deletions(-) diff --git a/src/frontend/app/actions/actions.service.ts b/src/frontend/app/actions/actions.service.ts index 340e465f82d..fad5de2283f 100644 --- a/src/frontend/app/actions/actions.service.ts +++ b/src/frontend/app/actions/actions.service.ts @@ -46,6 +46,7 @@ export class ActionsService implements OnDestroy { currentResourceLock: any = null; lockMode: boolean = true; + actionEnded: boolean = false; currentAction: any = null; currentUserId: number = null; @@ -146,6 +147,7 @@ export class ActionsService implements OnDestroy { async 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.actionEnded = false; this.loading = true; this.lockMode = lockRes; this.setResourceInformations(datas); @@ -283,6 +285,7 @@ export class ActionsService implements OnDestroy { this.notify.success(this.lang.action + ' : "' + this.currentAction.label + '" ' + this.lang.done); + this.actionEnded = true; this.eventAction.next(resIds); } diff --git a/src/frontend/app/process/process.component.ts b/src/frontend/app/process/process.component.ts index 1e049e40ffb..9aed353ccfd 100755 --- a/src/frontend/app/process/process.component.ts +++ b/src/frontend/app/process/process.component.ts @@ -657,7 +657,9 @@ export class ProcessComponent implements OnInit, OnDestroy { ngOnDestroy() { if (!this.detailMode) { this.actionService.stopRefreshResourceLock(); - this.actionService.unlockResource(this.currentUserId, this.currentGroupId, this.currentBasketId, [this.currentResourceInformations.resId]); + if (!this.actionService.actionEnded) { + this.actionService.unlockResource(this.currentUserId, this.currentGroupId, this.currentBasketId, [this.currentResourceInformations.resId]); + } } // unsubscribe to ensure no memory leaks this.subscription.unsubscribe(); diff --git a/src/frontend/app/signature-book.component.ts b/src/frontend/app/signature-book.component.ts index 302f412104d..73a2ca57ba3 100755 --- a/src/frontend/app/signature-book.component.ts +++ b/src/frontend/app/signature-book.component.ts @@ -455,15 +455,17 @@ export class SignatureBookComponent implements OnInit, OnDestroy { } async changeLocation(resId: number, origin: string) { - const data: any = await this.actionService.canExecuteAction([resId], this.userId, this.groupId, this.basketId); - - if (data === true) { - this.actionService.stopRefreshResourceLock(); - this.actionService.unlockResource(this.userId, this.groupId, this.basketId, [this.resId]); - const path = 'signatureBook/users/' + this.userId + '/groups/' + this.groupId + '/baskets/' + this.basketId + '/resources/' + resId; - this.router.navigate([path]); - } else { - this.backToBasket(); + if (resId !== this.resId) { + const data: any = await this.actionService.canExecuteAction([resId], this.userId, this.groupId, this.basketId); + + if (data === true) { + this.actionService.stopRefreshResourceLock(); + this.actionService.unlockResource(this.userId, this.groupId, this.basketId, [this.resId]); + const path = 'signatureBook/users/' + this.userId + '/groups/' + this.groupId + '/baskets/' + this.basketId + '/resources/' + resId; + this.router.navigate([path]); + } else { + this.backToBasket(); + } } } @@ -565,7 +567,10 @@ export class SignatureBookComponent implements OnInit, OnDestroy { ngOnDestroy() { this.actionService.stopRefreshResourceLock(); - this.actionService.unlockResource(this.userId, this.groupId, this.basketId, [this.resId]); + + if (!this.actionService.actionEnded) { + this.actionService.unlockResource(this.userId, this.groupId, this.basketId, [this.resId]); + } // unsubscribe to ensure no memory leaks this.subscription.unsubscribe(); -- GitLab