diff --git a/apps/red-ui/src/app/modules/dossier/components/annotation-actions/annotation-actions.component.html b/apps/red-ui/src/app/modules/dossier/components/annotation-actions/annotation-actions.component.html index 108794308..30af3e697 100644 --- a/apps/red-ui/src/app/modules/dossier/components/annotation-actions/annotation-actions.component.html +++ b/apps/red-ui/src/app/modules/dossier/components/annotation-actions/annotation-actions.component.html @@ -1,4 +1,13 @@
+ + + @@ -22,7 +30,6 @@ *ngIf="annotationPermissions.canAcceptSuggestion" icon="red:check" tooltip="annotation-actions.accept-suggestion.label" - tooltipPosition="before" type="dark-bg" > @@ -34,7 +41,6 @@ *ngIf="annotationPermissions.canUndo" icon="red:undo" tooltip="annotation-actions.undo" - tooltipPosition="before" type="dark-bg" > @@ -46,7 +52,6 @@ *ngIf="annotationPermissions.canRejectSuggestion" icon="red:trash" tooltip="annotation-actions.reject-suggestion" - tooltipPosition="before" type="dark-bg" > @@ -61,7 +66,6 @@ " icon="red:thumb-down" tooltip="annotation-actions.remove-annotation.false-positive" - tooltipPosition="before" type="dark-bg" > @@ -71,7 +75,6 @@ *ngIf="annotationPermissions.canForceRedaction" icon="red:thumb-up" tooltip="annotation-actions.force-redaction.label" - tooltipPosition="before" type="dark-bg" > @@ -81,7 +84,6 @@ *ngIf="annotation.isImage && viewerAnnotation?.isVisible()" icon="red:visibility-off" tooltip="annotation-actions.hide" - tooltipPosition="before" type="dark-bg" > @@ -91,7 +93,6 @@ *ngIf="annotation.isImage && !viewerAnnotation?.isVisible()" icon="red:visibility" tooltip="annotation-actions.show" - tooltipPosition="before" type="dark-bg" > diff --git a/apps/red-ui/src/app/modules/dossier/dialogs/change-legal-basis-dialog/change-legal-basis-dialog.component.html b/apps/red-ui/src/app/modules/dossier/dialogs/change-legal-basis-dialog/change-legal-basis-dialog.component.html new file mode 100644 index 000000000..5570febef --- /dev/null +++ b/apps/red-ui/src/app/modules/dossier/dialogs/change-legal-basis-dialog/change-legal-basis-dialog.component.html @@ -0,0 +1,68 @@ +
+
+
+ +
+
+ + + + {{ option.label }} + + +
+ +
+ + +
+ +
+ + +
+
+ +
+ +
+
+
+ + +
diff --git a/apps/red-ui/src/app/modules/dossier/dialogs/change-legal-basis-dialog/change-legal-basis-dialog.component.scss b/apps/red-ui/src/app/modules/dossier/dialogs/change-legal-basis-dialog/change-legal-basis-dialog.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/apps/red-ui/src/app/modules/dossier/dialogs/change-legal-basis-dialog/change-legal-basis-dialog.component.ts b/apps/red-ui/src/app/modules/dossier/dialogs/change-legal-basis-dialog/change-legal-basis-dialog.component.ts new file mode 100644 index 000000000..947e79bfe --- /dev/null +++ b/apps/red-ui/src/app/modules/dossier/dialogs/change-legal-basis-dialog/change-legal-basis-dialog.component.ts @@ -0,0 +1,73 @@ +import { Component, Inject, OnInit } from '@angular/core'; +import { TranslateService } from '@ngx-translate/core'; +import { MAT_DIALOG_DATA, MatDialogRef } from '@angular/material/dialog'; +import { AnnotationWrapper } from '@models/file/annotation.wrapper'; +import { FormBuilder, FormGroup, Validators } from '@angular/forms'; +import { LegalBasisMappingControllerService } from '@redaction/red-ui-http'; +import { AppStateService } from '../../../../state/app-state.service'; +import { PermissionsService } from '../../../../services/permissions.service'; + +export interface LegalBasisOption { + label?: string; + legalBasis?: string; + description?: string; +} + +@Component({ + selector: 'redaction-change-legal-basis-dialog', + templateUrl: './change-legal-basis-dialog.component.html', + styleUrls: ['./change-legal-basis-dialog.component.scss'] +}) +export class ChangeLegalBasisDialogComponent implements OnInit { + legalBasisForm: FormGroup; + isDocumentAdmin: boolean; + legalOptions: LegalBasisOption[] = []; + + constructor( + private readonly _translateService: TranslateService, + private readonly _legalBasisMappingControllerService: LegalBasisMappingControllerService, + private readonly _appStateService: AppStateService, + private readonly _permissionsService: PermissionsService, + private readonly _formBuilder: FormBuilder, + public dialogRef: MatDialogRef, + @Inject(MAT_DIALOG_DATA) public annotation: AnnotationWrapper + ) {} + + get changed(): boolean { + return this.legalBasisForm.get('reason').value.legalBasis !== this.annotation.legalBasis; + } + + async ngOnInit() { + this.isDocumentAdmin = this._permissionsService.isApprover(); + + this.legalBasisForm = this._formBuilder.group({ + reason: [null, Validators.required], + comment: this.isDocumentAdmin ? [null] : [null, Validators.required] + }); + const data = await this._legalBasisMappingControllerService + .getLegalBasisMapping(this._appStateService.activeDossier.dossierTemplateId) + .toPromise(); + + this.legalOptions = data + .map(lbm => ({ + legalBasis: lbm.reason, + description: lbm.description, + label: lbm.name + })) + .sort((a, b) => a.label.localeCompare(b.label)); + + // this.annotation. + this.legalBasisForm.patchValue({ + reason: this.legalOptions.find( + option => option.legalBasis === this.annotation.legalBasis + ) + }); + } + + save() { + this.dialogRef.close({ + legalBasis: this.legalBasisForm.get('reason').value.legalBasis, + comment: this.legalBasisForm.get('comment').value + }); + } +} diff --git a/apps/red-ui/src/app/modules/dossier/dossiers.module.ts b/apps/red-ui/src/app/modules/dossier/dossiers.module.ts index bd319a76c..40f754d51 100644 --- a/apps/red-ui/src/app/modules/dossier/dossiers.module.ts +++ b/apps/red-ui/src/app/modules/dossier/dossiers.module.ts @@ -45,6 +45,7 @@ import { EditDossierTeamMembersComponent } from './dialogs/edit-dossier-dialog/t import { TeamMembersManagerComponent } from './components/team-members-manager/team-members-manager.component'; import { TeamMembersDialogComponent } from './dialogs/team-members-dialog/team-members-dialog.component'; import { ScrollButtonComponent } from './components/scroll-button/scroll-button.component'; +import { ChangeLegalBasisDialogComponent } from './dialogs/change-legal-basis-dialog/change-legal-basis-dialog.component'; import { PageExclusionComponent } from './components/page-exclusion/page-exclusion.component'; const screens = [ @@ -62,7 +63,8 @@ const dialogs = [ RemoveAnnotationsDialogComponent, DocumentInfoDialogComponent, AssignReviewerApproverDialogComponent, - DossierDictionaryDialogComponent + DossierDictionaryDialogComponent, + ChangeLegalBasisDialogComponent ]; const components = [ diff --git a/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts b/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts index 2e0491a13..fee998b6c 100644 --- a/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/annotation-actions.service.ts @@ -74,6 +74,28 @@ export class AnnotationActionsService { }); } + changeLegalBasis( + $event: MouseEvent, + annotation: AnnotationWrapper, + annotationsChanged: EventEmitter + ) { + this._dialogService.openChangeLegalBasisDialog( + $event, + annotation, + (data: { comment: string; legalBasis: string }) => { + this._processObsAndEmit( + this._manualAnnotationService.changeLegalBasis( + annotation.annotationId, + data.legalBasis, + data.comment + ), + annotation, + annotationsChanged + ); + } + ); + } + suggestRemoveAnnotation( $event: MouseEvent, annotations: AnnotationWrapper[], diff --git a/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts b/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts index 620255fb8..c01244769 100644 --- a/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/dossiers-dialog.service.ts @@ -30,6 +30,7 @@ import { FileStatusWrapper } from '../../../models/file/file-status.wrapper'; import { AssignReviewerApproverDialogComponent } from '../dialogs/assign-reviewer-approver-dialog/assign-reviewer-approver-dialog.component'; import { TeamMembersDialogComponent } from '../dialogs/team-members-dialog/team-members-dialog.component'; import { AppConfigService } from '../../app-config/app-config.service'; +import { ChangeLegalBasisDialogComponent } from '../dialogs/change-legal-basis-dialog/change-legal-basis-dialog.component'; const dialogConfig = { width: '662px', @@ -170,6 +171,24 @@ export class DossiersDialogService { return ref; } + openChangeLegalBasisDialog( + $event: MouseEvent, + annotation: AnnotationWrapper, + cb?: Function + ): MatDialogRef { + $event?.stopPropagation(); + const ref = this._dialog.open(ChangeLegalBasisDialogComponent, { + ...dialogConfig, + data: annotation + }); + ref.afterClosed().subscribe(async result => { + if (result && cb) { + cb(result); + } + }); + return ref; + } + openRemoveFromDictionaryDialog( $event: MouseEvent, annotations: AnnotationWrapper[], diff --git a/apps/red-ui/src/app/modules/dossier/services/manual-annotation.service.ts b/apps/red-ui/src/app/modules/dossier/services/manual-annotation.service.ts index ac87e06b2..bf10da472 100644 --- a/apps/red-ui/src/app/modules/dossier/services/manual-annotation.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/manual-annotation.service.ts @@ -58,6 +58,17 @@ export class ManualAnnotationService { return this.addAnnotation(manualRedactionEntry); } + // this wraps + // /manualRedaction/redaction/legalBasisChange + // /manualRedaction/request/legalBasis + changeLegalBasis(annotationId: string, legalBasis: string, comment?: string) { + if (this._permissionsService.isApprover()) { + return this._makeLegalBasisChange(annotationId, legalBasis, comment); + } else { + return this._makeLegalBasisChangeRequest(annotationId, legalBasis, comment); + } + } + // this wraps // /manualRedaction/redaction/add // /manualRedaction/request/add @@ -345,6 +356,50 @@ export class ManualAnnotationService { ); } + private _makeLegalBasisChange(annotationId: string, legalBasis: string, comment?: string) { + return this._manualRedactionControllerService + .legalBasisChange( + { annotationId, legalBasis, comment }, + this._appStateService.activeDossierId, + this._appStateService.activeFileId + ) + .pipe( + tap( + () => this._notify(this._getMessage('change-legal-basis')), + error => + this._notify( + this._getMessage('change-legal-basis', false, true), + NotificationType.ERROR, + error + ) + ) + ); + } + + private _makeLegalBasisChangeRequest( + annotationId: string, + legalBasis: string, + comment?: string + ) { + return this._manualRedactionControllerService + .requestLegalBasisChange( + { annotationId, legalBasis, comment }, + this._appStateService.activeDossierId, + this._appStateService.activeFileId + ) + .pipe( + tap( + () => this._notify(this._getMessage('request-change-legal-basis')), + error => + this._notify( + this._getMessage('request-change-legal-basis', false, true), + NotificationType.ERROR, + error + ) + ) + ); + } + private _makeRedaction(manualRedactionEntry: AddRedactionRequest) { return this._manualRedactionControllerService .addRedaction( @@ -379,7 +434,16 @@ export class ManualAnnotationService { } private _getMessage( - mode: 'add' | 'remove' | 'request-remove' | 'suggest' | 'approve' | 'decline' | 'undo', + mode: + | 'add' + | 'remove' + | 'request-remove' + | 'suggest' + | 'approve' + | 'decline' + | 'undo' + | 'change-legal-basis' + | 'request-change-legal-basis', modifyDictionary?: boolean, error: boolean = false ) { diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index 62132e841..b6bb13c3d 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -414,6 +414,19 @@ "jump-last": "Jump to last page" } }, + "change-legal-basis-dialog": { + "header": "Edit Redaction Reason", + "actions": { + "save": "Save Changes", + "cancel": "Cancel" + }, + "content": { + "reason": "Select redaction reason", + "reason-placeholder": "Select a reason...", + "legalBasis": "Legal Basis", + "comment": "Comment" + } + }, "assign-user": { "cancel": "Cancel", "save": "Save" @@ -478,6 +491,9 @@ "accept-recommendation": { "label": "Accept Recommendation" }, + "edit-reason": { + "label": "Edit Reason" + }, "suggest-remove-annotation": "Remove or Suggest to remove this entry", "suggest-remove-annotations": "Remove or Suggest to remove selected entries", "reject-suggestion": "Reject Suggestion",