RED-7421 - Unassigned file cannot be moved back from "under approval" to "under review."
This commit is contained in:
parent
d853c781a7
commit
2b56f71023
@ -1,18 +1,21 @@
|
|||||||
import { Injectable } from '@angular/core';
|
import { Injectable } from '@angular/core';
|
||||||
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker';
|
||||||
import { IConfirmationDialogData, IqserDialog, LoadingService } from '@iqser/common-ui';
|
import { IConfirmationDialogData, IqserDialog, LoadingService } from '@iqser/common-ui';
|
||||||
import { Dossier, File, WorkflowFileStatus, WorkflowFileStatuses } from '@red/domain';
|
import { Dossier, File, User, WorkflowFileStatus, WorkflowFileStatuses } from '@red/domain';
|
||||||
import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service';
|
import { ActiveDossiersService } from '@services/dossiers/active-dossiers.service';
|
||||||
import { FileManagementService } from '@services/files/file-management.service';
|
import { FileManagementService } from '@services/files/file-management.service';
|
||||||
import { FilesService } from '@services/files/files.service';
|
import { FilesService } from '@services/files/files.service';
|
||||||
import { ReanalysisService } from '@services/reanalysis.service';
|
import { ReanalysisService } from '@services/reanalysis.service';
|
||||||
import { firstValueFrom } from 'rxjs';
|
import { firstValueFrom, forkJoin } from 'rxjs';
|
||||||
import { AssignReviewerApproverDialogComponent } from '../../shared-dossiers/dialogs/assign-reviewer-approver-dialog/assign-reviewer-approver-dialog.component';
|
import { AssignReviewerApproverDialogComponent } from '../../shared-dossiers/dialogs/assign-reviewer-approver-dialog/assign-reviewer-approver-dialog.component';
|
||||||
import { DossiersDialogService } from '../../shared-dossiers/services/dossiers-dialog.service';
|
import { DossiersDialogService } from '../../shared-dossiers/services/dossiers-dialog.service';
|
||||||
import { FileAssignService } from '../../shared-dossiers/services/file-assign.service';
|
import { FileAssignService } from '../../shared-dossiers/services/file-assign.service';
|
||||||
|
import { getCurrentUser } from '@common-ui/users';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class BulkActionsService {
|
export class BulkActionsService {
|
||||||
|
readonly currentUser = getCurrentUser<User>();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private readonly _dialogService: DossiersDialogService,
|
private readonly _dialogService: DossiersDialogService,
|
||||||
private readonly _iqserDialog: IqserDialog,
|
private readonly _iqserDialog: IqserDialog,
|
||||||
@ -81,7 +84,22 @@ export class BulkActionsService {
|
|||||||
|
|
||||||
async backToUnderReview(files: File[]): Promise<void> {
|
async backToUnderReview(files: File[]): Promise<void> {
|
||||||
this._loadingService.start();
|
this._loadingService.start();
|
||||||
await this._filesService.setUnderReview(files);
|
const [unassignedFiles, assignedFiles] = files.reduce(
|
||||||
|
(result, element) => {
|
||||||
|
result[!element.assignee ? 0 : 1].push(element);
|
||||||
|
return result;
|
||||||
|
},
|
||||||
|
[[], []],
|
||||||
|
);
|
||||||
|
|
||||||
|
const requests$ = [];
|
||||||
|
if (unassignedFiles.length) {
|
||||||
|
requests$.push(this._filesService.setReviewer(unassignedFiles, this.currentUser.id));
|
||||||
|
}
|
||||||
|
if (assignedFiles.length) {
|
||||||
|
requests$.push(this._filesService.setUnderReview(assignedFiles));
|
||||||
|
}
|
||||||
|
await firstValueFrom(forkJoin(requests$));
|
||||||
this._loadingService.stop();
|
this._loadingService.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -68,7 +68,12 @@ export class FileAssignService {
|
|||||||
userId = currentUserId;
|
userId = currentUserId;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (file.assignee === currentUserId) {
|
if (
|
||||||
|
file.assignee === currentUserId ||
|
||||||
|
(!file.assignee &&
|
||||||
|
targetStatus === WorkflowFileStatuses.UNDER_REVIEW &&
|
||||||
|
file.workflowStatus === WorkflowFileStatuses.UNDER_APPROVAL)
|
||||||
|
) {
|
||||||
if (eligibleUsersIds.includes(currentUserId)) {
|
if (eligibleUsersIds.includes(currentUserId)) {
|
||||||
userId = currentUserId;
|
userId = currentUserId;
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user