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