Skip to content
Snippets Groups Projects
Commit 89c221a1 authored by Alex ORLUC's avatar Alex ORLUC
Browse files

FIX #14199 TIME 0:10 fix unlock resource

parent 062540ed
No related branches found
No related tags found
No related merge requests found
......@@ -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);
}
......
......@@ -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();
......
......@@ -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();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment