Refactor dossiers dialog service: assign file to user
This commit is contained in:
parent
f2694e8853
commit
d18359aa6c
@ -154,16 +154,7 @@ export class DossierOverviewBulkActionsComponent {
|
|||||||
setToUnderApproval() {
|
setToUnderApproval() {
|
||||||
// If more than 1 approver - show dialog and ask who to assign
|
// If more than 1 approver - show dialog and ask who to assign
|
||||||
if (this._appStateService.activeDossier.approverIds.length > 1) {
|
if (this._appStateService.activeDossier.approverIds.length > 1) {
|
||||||
this._dialogService.openAssignFileToUserDialog(
|
this._assignFiles('approver', true);
|
||||||
this.selectedFiles,
|
|
||||||
'approver',
|
|
||||||
() => {
|
|
||||||
this._loadingService.start();
|
|
||||||
this.reload.emit();
|
|
||||||
this._loadingService.stop();
|
|
||||||
},
|
|
||||||
true
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
this._performBulkAction(
|
this._performBulkAction(
|
||||||
this._fileActionService.setFileUnderApproval(this.selectedFiles, this._appStateService.activeDossier.approverIds[0])
|
this._fileActionService.setFileUnderApproval(this.selectedFiles, this._appStateService.activeDossier.approverIds[0])
|
||||||
@ -196,8 +187,12 @@ export class DossierOverviewBulkActionsComponent {
|
|||||||
|
|
||||||
assign() {
|
assign() {
|
||||||
const mode = this.selectedFiles[0].isUnderApproval ? 'approver' : 'reviewer';
|
const mode = this.selectedFiles[0].isUnderApproval ? 'approver' : 'reviewer';
|
||||||
|
this._assignFiles(mode);
|
||||||
|
}
|
||||||
|
|
||||||
this._dialogService.openAssignFileToUserDialog(this.selectedFiles, mode, () => {
|
private _assignFiles(mode: 'reviewer' | 'approver', ignoreChanged = false) {
|
||||||
|
const data = { mode, files: this.selectedFiles, ignoreChanged };
|
||||||
|
this._dialogService.openDialog('assignFile', null, data, () => {
|
||||||
this._loadingService.start();
|
this._loadingService.start();
|
||||||
this.reload.emit();
|
this.reload.emit();
|
||||||
this._loadingService.stop();
|
this._loadingService.stop();
|
||||||
|
|||||||
@ -139,11 +139,9 @@ export class FileActionsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
assign($event: MouseEvent) {
|
assign($event: MouseEvent) {
|
||||||
$event.stopPropagation();
|
|
||||||
|
|
||||||
const mode = this.fileStatus.isUnderApproval ? 'approver' : 'reviewer';
|
const mode = this.fileStatus.isUnderApproval ? 'approver' : 'reviewer';
|
||||||
|
const files = [this.fileStatus];
|
||||||
this._dialogService.openAssignFileToUserDialog([this.fileStatus], mode, () => {
|
this._dialogService.openDialog('assignFile', $event, { mode, files }, () => {
|
||||||
this.actionPerformed.emit('assign-reviewer');
|
this.actionPerformed.emit('assign-reviewer');
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -164,9 +162,14 @@ export class FileActionsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setFileUnderApproval($event: MouseEvent) {
|
setFileUnderApproval($event: MouseEvent) {
|
||||||
$event.stopPropagation();
|
|
||||||
if (this.appStateService.activeDossier.approverIds.length > 1) {
|
if (this.appStateService.activeDossier.approverIds.length > 1) {
|
||||||
this._fileActionService.assignDossierApprover(this.fileStatus, () => this.actionPerformed.emit('assign-reviewer'), true);
|
this._fileActionService.assignFile(
|
||||||
|
'approver',
|
||||||
|
$event,
|
||||||
|
this.fileStatus,
|
||||||
|
() => this.actionPerformed.emit('assign-reviewer'),
|
||||||
|
true
|
||||||
|
);
|
||||||
} else {
|
} else {
|
||||||
this._fileActionService.setFileUnderApproval(this.fileStatus).subscribe(() => {
|
this._fileActionService.setFileUnderApproval(this.fileStatus).subscribe(() => {
|
||||||
this.reloadDossiers('set-under-approval');
|
this.reloadDossiers('set-under-approval');
|
||||||
@ -189,8 +192,9 @@ export class FileActionsComponent implements OnInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setFileUnderReview($event: MouseEvent, ignoreDialogChanges = false) {
|
setFileUnderReview($event: MouseEvent, ignoreDialogChanges = false) {
|
||||||
$event.stopPropagation();
|
this._fileActionService.assignFile(
|
||||||
this._fileActionService.assignDossierReviewer(
|
'reviewer',
|
||||||
|
$event,
|
||||||
this.fileStatus,
|
this.fileStatus,
|
||||||
() => this.actionPerformed.emit('assign-reviewer'),
|
() => this.actionPerformed.emit('assign-reviewer'),
|
||||||
ignoreDialogChanges
|
ignoreDialogChanges
|
||||||
|
|||||||
@ -93,7 +93,7 @@ export class AssignReviewerApproverDialogComponent {
|
|||||||
this._toaster.error('Failed: ' + error.error ? error.error.message : error);
|
this._toaster.error('Failed: ' + error.error ? error.error.message : error);
|
||||||
}
|
}
|
||||||
|
|
||||||
this._dialogRef.close();
|
this._dialogRef.close(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _loadData() {
|
private _loadData() {
|
||||||
|
|||||||
@ -13,7 +13,6 @@ import { ManualAnnotationService } from './manual-annotation.service';
|
|||||||
import { ManualAnnotationDialogComponent } from '../dialogs/manual-redaction-dialog/manual-annotation-dialog.component';
|
import { ManualAnnotationDialogComponent } from '../dialogs/manual-redaction-dialog/manual-annotation-dialog.component';
|
||||||
import { DossierDictionaryDialogComponent } from '../dialogs/dossier-dictionary-dialog/dossier-dictionary-dialog.component';
|
import { DossierDictionaryDialogComponent } from '../dialogs/dossier-dictionary-dialog/dossier-dictionary-dialog.component';
|
||||||
import { EditDossierDialogComponent } from '../dialogs/edit-dossier-dialog/edit-dossier-dialog.component';
|
import { EditDossierDialogComponent } from '../dialogs/edit-dossier-dialog/edit-dossier-dialog.component';
|
||||||
import { FileStatusWrapper } from '@models/file/file-status.wrapper';
|
|
||||||
import { AssignReviewerApproverDialogComponent } from '../dialogs/assign-reviewer-approver-dialog/assign-reviewer-approver-dialog.component';
|
import { AssignReviewerApproverDialogComponent } from '../dialogs/assign-reviewer-approver-dialog/assign-reviewer-approver-dialog.component';
|
||||||
import { AppConfigService } from '@app-config/app-config.service';
|
import { AppConfigService } from '@app-config/app-config.service';
|
||||||
import { ChangeLegalBasisDialogComponent } from '../dialogs/change-legal-basis-dialog/change-legal-basis-dialog.component';
|
import { ChangeLegalBasisDialogComponent } from '../dialogs/change-legal-basis-dialog/change-legal-basis-dialog.component';
|
||||||
@ -29,7 +28,7 @@ const dialogConfig = {
|
|||||||
|
|
||||||
// TODO: Continue refactor
|
// TODO: Continue refactor
|
||||||
|
|
||||||
type DialogType = 'confirm' | 'documentInfo' | 'editDossier' | 'addDossier';
|
type DialogType = 'confirm' | 'documentInfo' | 'editDossier' | 'addDossier' | 'assignFile';
|
||||||
|
|
||||||
type DossiersDialogConfig = {
|
type DossiersDialogConfig = {
|
||||||
[key in DialogType]: {
|
[key in DialogType]: {
|
||||||
@ -59,6 +58,9 @@ export class DossiersDialogService extends DialogService<DialogType> {
|
|||||||
width: '900px',
|
width: '900px',
|
||||||
autoFocus: true
|
autoFocus: true
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
assignFile: {
|
||||||
|
component: AssignReviewerApproverDialogComponent
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -175,22 +177,4 @@ export class DossiersDialogService extends DialogService<DialogType> {
|
|||||||
});
|
});
|
||||||
return ref;
|
return ref;
|
||||||
}
|
}
|
||||||
|
|
||||||
openAssignFileToUserDialog(
|
|
||||||
files: FileStatusWrapper[],
|
|
||||||
mode: 'reviewer' | 'approver',
|
|
||||||
cb?: Function,
|
|
||||||
ignoreDialogChanges = false
|
|
||||||
): MatDialogRef<AssignReviewerApproverDialogComponent> {
|
|
||||||
const ref = this._dialog.open(AssignReviewerApproverDialogComponent, {
|
|
||||||
...dialogConfig,
|
|
||||||
data: { mode: mode, files: files, ignoreChanged: ignoreDialogChanges }
|
|
||||||
});
|
|
||||||
|
|
||||||
ref.afterClosed().subscribe(() => {
|
|
||||||
if (cb) cb();
|
|
||||||
});
|
|
||||||
|
|
||||||
return ref;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -42,42 +42,6 @@ export class FileActionService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
async assignDossierReviewerFromOverview(file?: FileStatusWrapper, callback?: Function) {
|
|
||||||
if (this._permissionsService.isOwner()) {
|
|
||||||
this._openAssignReviewerDialog(file, callback);
|
|
||||||
} else {
|
|
||||||
await this.assignToMe(file, callback);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
assignDossierApprover(file?: FileStatusWrapper, callback?: Function, ignoreDialogChanges = false) {
|
|
||||||
this._dialogService.openAssignFileToUserDialog(
|
|
||||||
file ? [file] : [this._appStateService.activeFile],
|
|
||||||
'approver',
|
|
||||||
async () => {
|
|
||||||
await this._appStateService.reloadActiveDossierFiles();
|
|
||||||
if (callback) {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
ignoreDialogChanges
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
assignDossierReviewer(file?: FileStatusWrapper, callback?: Function, ignoreDialogChanges = false) {
|
|
||||||
this._dialogService.openAssignFileToUserDialog(
|
|
||||||
file ? [file] : [this._appStateService.activeFile],
|
|
||||||
'reviewer',
|
|
||||||
async () => {
|
|
||||||
await this._appStateService.reloadActiveDossierFiles();
|
|
||||||
if (callback) {
|
|
||||||
callback();
|
|
||||||
}
|
|
||||||
},
|
|
||||||
ignoreDialogChanges
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
async assignToMe(fileStatus?: FileStatusWrapper | FileStatusWrapper[], callback?: Function) {
|
async assignToMe(fileStatus?: FileStatusWrapper | FileStatusWrapper[], callback?: Function) {
|
||||||
if (!isArray(fileStatus)) {
|
if (!isArray(fileStatus)) {
|
||||||
fileStatus = [fileStatus];
|
fileStatus = [fileStatus];
|
||||||
@ -143,8 +107,10 @@ export class FileActionService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private _openAssignReviewerDialog(file?: FileStatusWrapper, callback?: Function) {
|
assignFile(mode: 'reviewer' | 'approver', $event: MouseEvent, file?: FileStatusWrapper, callback?: Function, ignoreChanged = false) {
|
||||||
this._dialogService.openAssignFileToUserDialog(file ? [file] : [this._appStateService.activeFile], 'reviewer', async () => {
|
const files = file ? [file] : [this._appStateService.activeFile];
|
||||||
|
const data = { mode, files, ignoreChanged };
|
||||||
|
this._dialogService.openDialog('assignFile', $event, data, async () => {
|
||||||
await this._appStateService.reloadActiveDossierFiles();
|
await this._appStateService.reloadActiveDossierFiles();
|
||||||
if (callback) {
|
if (callback) {
|
||||||
callback();
|
callback();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user