From c9b7dbe5ab4d1bd82b70e918a88bfabcf8143c4a Mon Sep 17 00:00:00 2001 From: Valentin Date: Tue, 19 Oct 2021 11:58:20 +0300 Subject: [PATCH] updated logic to automatically assign the current user as approver if he is included in the approvers list when move a file to under approval --- .../dossier/shared/services/file-action.service.ts | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/apps/red-ui/src/app/modules/dossier/shared/services/file-action.service.ts b/apps/red-ui/src/app/modules/dossier/shared/services/file-action.service.ts index 623ced42f..55870d0e6 100644 --- a/apps/red-ui/src/app/modules/dossier/shared/services/file-action.service.ts +++ b/apps/red-ui/src/app/modules/dossier/shared/services/file-action.service.ts @@ -93,10 +93,10 @@ export class FileActionService { callback?: Function, ignoreChanged = false, ) { - const userIds = - mode === 'approver' ? this._dossiersService.activeDossier.approverIds : this._dossiersService.activeDossier.memberIds; - if (userIds.length === 1) { - this._assignFile(userIds[0], mode, [file]).then(async () => { + const userIds = this._getUserIds(mode); + if (userIds.length === 1 || (userIds.includes(this._userService.currentUser.id) && mode === 'approver')) { + const userId = userIds.length === 1 ? userIds[0] : this._userService.currentUser.id; + this._assignFile(userId, mode, [file]).then(async () => { if (callback) { await callback(); } @@ -135,6 +135,10 @@ export class FileActionService { } } + private _getUserIds(mode: 'reviewer' | 'approver') { + return mode === 'approver' ? this._dossiersService.activeDossier.approverIds : this._dossiersService.activeDossier.memberIds; + } + private async _assignReviewerToCurrentUser(files: File[], callback?: Function) { await this._fileService .setReviewerFor(