RED-4723: can set approved file to under review in workflow
This commit is contained in:
parent
ff6763704a
commit
8b991d2012
@ -9,6 +9,7 @@ import {
|
|||||||
ListingModes,
|
ListingModes,
|
||||||
NestedFilter,
|
NestedFilter,
|
||||||
TableColumnConfig,
|
TableColumnConfig,
|
||||||
|
WorkflowColumn,
|
||||||
WorkflowConfig,
|
WorkflowConfig,
|
||||||
} from '@iqser/common-ui';
|
} from '@iqser/common-ui';
|
||||||
import {
|
import {
|
||||||
@ -65,56 +66,60 @@ export class ConfigService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
workflowConfig(dossier: Dossier): WorkflowConfig<File, WorkflowFileStatus> {
|
workflowConfig(dossier: Dossier): WorkflowConfig<File, WorkflowFileStatus> {
|
||||||
|
const { NEW, UNDER_REVIEW, UNDER_APPROVAL, APPROVED } = WorkflowFileStatuses;
|
||||||
|
|
||||||
|
const newColumn: WorkflowColumn<File, typeof NEW> = {
|
||||||
|
label: workflowFileStatusTranslations[NEW],
|
||||||
|
key: NEW,
|
||||||
|
enterFn: files => this._bulkActionsService.setToNew(files),
|
||||||
|
enterPredicate: files => this._permissionsService.canSetToNew(files, dossier),
|
||||||
|
color: '#D3D5DA',
|
||||||
|
entities: new BehaviorSubject([]),
|
||||||
|
};
|
||||||
|
|
||||||
|
const underReviewColumn: WorkflowColumn<File, typeof UNDER_REVIEW> = {
|
||||||
|
label: workflowFileStatusTranslations[UNDER_REVIEW],
|
||||||
|
enterFn: async files => {
|
||||||
|
const statuses: WorkflowFileStatus[] = [UNDER_APPROVAL, APPROVED];
|
||||||
|
if (statuses.includes(files[0].workflowStatus)) {
|
||||||
|
await this._bulkActionsService.backToUnderReview(files);
|
||||||
|
} else {
|
||||||
|
await this._bulkActionsService.assignToMe(files);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
enterPredicate: files =>
|
||||||
|
this._permissionsService.canSetUnderReviewInWorkflow(files, dossier) ||
|
||||||
|
this._permissionsService.canAssignToSelf(files, dossier) ||
|
||||||
|
this._permissionsService.canAssignUser(files, dossier),
|
||||||
|
key: UNDER_REVIEW,
|
||||||
|
color: '#FDBD00',
|
||||||
|
entities: new BehaviorSubject([]),
|
||||||
|
};
|
||||||
|
|
||||||
|
const underApprovalColumn: WorkflowColumn<File, typeof UNDER_APPROVAL> = {
|
||||||
|
label: workflowFileStatusTranslations[UNDER_APPROVAL],
|
||||||
|
enterFn: files => this._bulkActionsService.setToUnderApproval(files),
|
||||||
|
enterPredicate: files =>
|
||||||
|
this._permissionsService.canSetUnderApproval(files, dossier) || this._permissionsService.canUndoApproval(files, dossier),
|
||||||
|
key: UNDER_APPROVAL,
|
||||||
|
color: '#374C81',
|
||||||
|
entities: new BehaviorSubject([]),
|
||||||
|
};
|
||||||
|
|
||||||
|
const approvedColumn: WorkflowColumn<File, typeof APPROVED> = {
|
||||||
|
label: workflowFileStatusTranslations[APPROVED],
|
||||||
|
enterFn: files => this._bulkActionsService.approve(files),
|
||||||
|
enterPredicate: files =>
|
||||||
|
this._permissionsService.isReadyForApproval(files, dossier) && this._permissionsService.canBeApproved(files, dossier),
|
||||||
|
key: APPROVED,
|
||||||
|
color: '#48C9F7',
|
||||||
|
entities: new BehaviorSubject([]),
|
||||||
|
};
|
||||||
|
|
||||||
return {
|
return {
|
||||||
columnIdentifierFn: entity => entity.workflowStatus,
|
columnIdentifierFn: entity => entity.workflowStatus,
|
||||||
itemVersionFn: (entity: File) => `${entity.lastUpdated}-${entity.numberOfAnalyses}`,
|
itemVersionFn: (entity: File) => `${entity.lastUpdated}-${entity.numberOfAnalyses}`,
|
||||||
columns: [
|
columns: [newColumn, underReviewColumn, underApprovalColumn, approvedColumn],
|
||||||
{
|
|
||||||
label: workflowFileStatusTranslations[WorkflowFileStatuses.NEW],
|
|
||||||
key: WorkflowFileStatuses.NEW,
|
|
||||||
enterFn: (files: File[]) => this._bulkActionsService.setToNew(files),
|
|
||||||
enterPredicate: (files: File[]) => this._permissionsService.canSetToNew(files, dossier),
|
|
||||||
color: '#D3D5DA',
|
|
||||||
entities: new BehaviorSubject([]),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: workflowFileStatusTranslations[WorkflowFileStatuses.UNDER_REVIEW],
|
|
||||||
enterFn: async (files: File[]) => {
|
|
||||||
if (files[0].workflowStatus === WorkflowFileStatuses.UNDER_APPROVAL) {
|
|
||||||
await this._bulkActionsService.backToUnderReview(files);
|
|
||||||
} else {
|
|
||||||
await this._bulkActionsService.assignToMe(files);
|
|
||||||
}
|
|
||||||
},
|
|
||||||
enterPredicate: (files: File[]) =>
|
|
||||||
this._permissionsService.canSetUnderReview(files, dossier) ||
|
|
||||||
this._permissionsService.canAssignToSelf(files, dossier) ||
|
|
||||||
this._permissionsService.canAssignUser(files, dossier),
|
|
||||||
key: WorkflowFileStatuses.UNDER_REVIEW,
|
|
||||||
color: '#FDBD00',
|
|
||||||
entities: new BehaviorSubject([]),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: workflowFileStatusTranslations[WorkflowFileStatuses.UNDER_APPROVAL],
|
|
||||||
enterFn: (files: File[]) => this._bulkActionsService.setToUnderApproval(files),
|
|
||||||
enterPredicate: (files: File[]) =>
|
|
||||||
this._permissionsService.canSetUnderApproval(files, dossier) ||
|
|
||||||
this._permissionsService.canUndoApproval(files, dossier),
|
|
||||||
key: WorkflowFileStatuses.UNDER_APPROVAL,
|
|
||||||
color: '#374C81',
|
|
||||||
entities: new BehaviorSubject([]),
|
|
||||||
},
|
|
||||||
{
|
|
||||||
label: workflowFileStatusTranslations[WorkflowFileStatuses.APPROVED],
|
|
||||||
enterFn: (files: File[]) => this._bulkActionsService.approve(files),
|
|
||||||
enterPredicate: (files: File[]) =>
|
|
||||||
this._permissionsService.isReadyForApproval(files, dossier) &&
|
|
||||||
this._permissionsService.canBeApproved(files, dossier),
|
|
||||||
key: WorkflowFileStatuses.APPROVED,
|
|
||||||
color: '#48C9F7',
|
|
||||||
entities: new BehaviorSubject([]),
|
|
||||||
},
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -137,6 +137,11 @@ export class PermissionsService {
|
|||||||
return files.reduce((acc, _file) => this._canSetUnderReview(_file, dossier) && acc, true);
|
return files.reduce((acc, _file) => this._canSetUnderReview(_file, dossier) && acc, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
canSetUnderReviewInWorkflow(file: File | File[], dossier: Dossier): boolean {
|
||||||
|
const files = file instanceof File ? [file] : file;
|
||||||
|
return files.reduce((acc, _file) => this._canSetUnderReviewInWorkflow(_file, dossier) && acc, true);
|
||||||
|
}
|
||||||
|
|
||||||
canBeApproved(file: File | File[], dossier: Dossier): boolean {
|
canBeApproved(file: File | File[], dossier: Dossier): boolean {
|
||||||
const files = file instanceof File ? [file] : file;
|
const files = file instanceof File ? [file] : file;
|
||||||
return files.reduce((acc, _file) => this._canBeApproved(_file, dossier) && acc, true);
|
return files.reduce((acc, _file) => this._canBeApproved(_file, dossier) && acc, true);
|
||||||
@ -303,12 +308,24 @@ export class PermissionsService {
|
|||||||
return dossier.isActive && file.isUnderReview && this.isAssigneeOrApprover(file, dossier);
|
return dossier.isActive && file.isUnderReview && this.isAssigneeOrApprover(file, dossier);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** UNDER_APPROVAL => UNDER_REVIEW OR NEW => UNDER_REVIEW */
|
/** UNDER_APPROVAL => UNDER_REVIEW OR NEW => UNDER_REVIEW */
|
||||||
private _canSetUnderReview(file: File, dossier: Dossier): boolean {
|
private _canSetUnderReview(file: File, dossier: Dossier): boolean {
|
||||||
return (
|
if (!dossier.isActive) {
|
||||||
dossier.isActive &&
|
return false;
|
||||||
((file.isUnderApproval && this.isAssigneeOrApprover(file, dossier)) || (file.isNew && this.isDossierMember(dossier)))
|
}
|
||||||
);
|
|
||||||
|
return (file.isUnderApproval && this.isAssigneeOrApprover(file, dossier)) || (file.isNew && this.isDossierMember(dossier));
|
||||||
|
}
|
||||||
|
|
||||||
|
/** UNDER_APPROVAL => UNDER_REVIEW OR NEW => UNDER_REVIEW OR APPROVED => UNDER_REVIEW*/
|
||||||
|
private _canSetUnderReviewInWorkflow(file: File, dossier: Dossier): boolean {
|
||||||
|
if (!dossier.isActive) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const isApprovedOrUnderApproval = file.isApproved || file.isUnderApproval;
|
||||||
|
|
||||||
|
return (isApprovedOrUnderApproval && this.isAssigneeOrApprover(file, dossier)) || (file.isNew && this.isDossierMember(dossier));
|
||||||
}
|
}
|
||||||
|
|
||||||
/** UNDER_APPROVAL => APPROVED */
|
/** UNDER_APPROVAL => APPROVED */
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user