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

This commit is contained in:
Valentin 2021-10-19 11:58:20 +03:00
parent de93959f2c
commit c9b7dbe5ab

View File

@ -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(