diff --git a/src/frontend/app/actions/actions.service.ts b/src/frontend/app/actions/actions.service.ts index 6d569c55fee4c2c477245510e3430f60749048d4..89c74562c1dca2cad08c43a8b8d97fe13bf155ed 100644 --- a/src/frontend/app/actions/actions.service.ts +++ b/src/frontend/app/actions/actions.service.ts @@ -46,6 +46,7 @@ export class ActionsService { currentResourceLock: any = null; lockMode: boolean = true; + actionEnded: boolean = false; currentAction: any = null; currentUserId: number = null; @@ -140,6 +141,7 @@ export class ActionsService { 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); @@ -207,10 +209,8 @@ export class ActionsService { } lockResource(userId: number = this.currentUserId, groupId: number = this.currentGroupId, basketId: number = this.currentBasketId, resIds: number[] = this.currentResIds) { - console.log(`Verouillage des documents ${resIds}`); this.http.put(`../../rest/resourcesList/users/${userId}/groups/${groupId}/baskets/${basketId}/lock`, { resources: resIds }).pipe( - tap(() => console.debug(`Cycle lock : `, this.currentResourceLock)), catchError((err: any) => { this.notify.handleErrors(err); return of(false); @@ -219,7 +219,6 @@ export class ActionsService { this.currentResourceLock = setInterval(() => { this.http.put(`../../rest/resourcesList/users/${userId}/groups/${groupId}/baskets/${basketId}/lock`, { resources: resIds }).pipe( - tap(() => console.debug(`Cycle lock : `, this.currentResourceLock)), catchError((err: any) => { if (err.status === 403) { clearInterval(this.currentResourceLock); @@ -233,7 +232,6 @@ export class ActionsService { unlockResource(userId: number = this.currentUserId, groupId: number = this.currentGroupId, basketId: number = this.currentBasketId, resIds: number[] = this.currentResIds) { if (resIds.length > 0) { - console.debug(`Unlock ressource : ${resIds}`); this.http.put(`../../rest/resourcesList/users/${userId}/groups/${groupId}/baskets/${basketId}/unlock`, { resources: resIds }).pipe( catchError((err: any) => { this.notify.handleErrors(err); @@ -245,7 +243,6 @@ export class ActionsService { stopRefreshResourceLock() { if (this.currentResourceLock !== null) { - console.debug('Cycle lock cancel'); clearInterval(this.currentResourceLock); } } @@ -277,6 +274,7 @@ export class ActionsService { 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 137e0070ea14288c726b7afb27c3d34e7daf3623..2dc71fe5f3e521aa67256148d11cbf646fba8916 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 180318639e0243c7babce121a24382ffa54449a0..14fdd52c0d1881509ae2274c74747ae478243125 100755 --- a/src/frontend/app/signature-book.component.ts +++ b/src/frontend/app/signature-book.component.ts @@ -469,15 +469,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(); + } } } @@ -563,7 +565,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();