fixed RED-1541
This commit is contained in:
parent
62153b72a5
commit
f6e9e17011
@ -8,7 +8,7 @@ import {
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { FileStatusWrapper } from '@models/file/file-status.wrapper';
|
||||
import { FileActionService } from '../../services/file-action.service';
|
||||
import { Observable } from 'rxjs';
|
||||
import { from, Observable } from 'rxjs';
|
||||
import { StatusOverlayService } from '@upload-download/services/status-overlay.service';
|
||||
import { ProjectsDialogService } from '../../services/projects-dialog.service';
|
||||
|
||||
@ -236,6 +236,10 @@ export class ProjectOverviewBulkActionsComponent {
|
||||
this._performBulkAction(this._fileActionService.setFileApproved(this.selectedFiles));
|
||||
}
|
||||
|
||||
assignToMe() {
|
||||
this._performBulkAction(from(this._fileActionService.assignToMe(this.selectedFiles)));
|
||||
}
|
||||
|
||||
private _performBulkAction(obs: Observable<any>) {
|
||||
this.loading = true;
|
||||
obs.subscribe().add(() => {
|
||||
@ -257,6 +261,4 @@ export class ProjectOverviewBulkActionsComponent {
|
||||
this.loading = false;
|
||||
});
|
||||
}
|
||||
|
||||
assignToMe() {}
|
||||
}
|
||||
|
||||
@ -1,11 +1,7 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { AppStateService } from '@state/app-state.service';
|
||||
import { UserService } from '@services/user.service';
|
||||
import {
|
||||
FileStatus,
|
||||
ReanalysisControllerService,
|
||||
StatusControllerService
|
||||
} from '@redaction/red-ui-http';
|
||||
import { ReanalysisControllerService, StatusControllerService } from '@redaction/red-ui-http';
|
||||
import { FileStatusWrapper } from '@models/file/file-status.wrapper';
|
||||
import { PermissionsService } from '@services/permissions.service';
|
||||
import { isArray } from 'rxjs/internal-compatibility';
|
||||
@ -88,16 +84,21 @@ export class FileActionService {
|
||||
);
|
||||
}
|
||||
|
||||
async assignToMe(file?: FileStatusWrapper, callback?: Function) {
|
||||
if (!file.currentReviewer) {
|
||||
await this._assignReviewerToCurrentUser(file, callback);
|
||||
async assignToMe(fileStatus?: FileStatusWrapper | FileStatusWrapper[], callback?: Function) {
|
||||
if (!isArray(fileStatus)) {
|
||||
fileStatus = [fileStatus];
|
||||
}
|
||||
|
||||
const atLeastOneFileHasReviewer = fileStatus.reduce(
|
||||
(acc, fs) => acc || !!fs.currentReviewer,
|
||||
false
|
||||
);
|
||||
if (atLeastOneFileHasReviewer) {
|
||||
this._dialogService.openAssignFileToMeDialog(async () => {
|
||||
await this._assignReviewerToCurrentUser(fileStatus, callback);
|
||||
});
|
||||
} else {
|
||||
this._dialogService.openAssignFileToMeDialog(
|
||||
file ? file : this._appStateService.activeFile,
|
||||
async () => {
|
||||
await this._assignReviewerToCurrentUser(file, callback);
|
||||
}
|
||||
);
|
||||
await this._assignReviewerToCurrentUser(fileStatus, callback);
|
||||
}
|
||||
}
|
||||
|
||||
@ -160,12 +161,17 @@ export class FileActionService {
|
||||
);
|
||||
}
|
||||
|
||||
private async _assignReviewerToCurrentUser(file?: FileStatus, callback?: Function) {
|
||||
console.log('assign here');
|
||||
private async _assignReviewerToCurrentUser(
|
||||
fileStatus: FileStatusWrapper | FileStatusWrapper[],
|
||||
callback?: Function
|
||||
) {
|
||||
if (!isArray(fileStatus)) {
|
||||
fileStatus = [fileStatus];
|
||||
}
|
||||
await this._statusControllerService
|
||||
.setFileReviewer(
|
||||
.setFileReviewerForList(
|
||||
fileStatus.map((f) => f.fileId),
|
||||
this._appStateService.activeProjectId,
|
||||
file.fileId,
|
||||
this._userService.userId
|
||||
)
|
||||
.toPromise();
|
||||
|
||||
@ -248,7 +248,7 @@ export class ProjectsDialogService {
|
||||
return ref;
|
||||
}
|
||||
|
||||
openAssignFileToMeDialog(file: FileStatus, cb?: Function) {
|
||||
openAssignFileToMeDialog(cb?: Function) {
|
||||
const ref = this._dialog.open(ConfirmationDialogComponent, {
|
||||
...dialogConfig,
|
||||
data: new ConfirmationDialogInput({
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user