Edit annotation reason WIP
This commit is contained in:
parent
f223338d03
commit
975bed7380
@ -1,4 +1,13 @@
|
||||
<div *ngIf="canPerformAnnotationActions" class="annotation-actions">
|
||||
<redaction-circle-button
|
||||
(action)="annotationActionsService.changeLegalBasis($event, annotation, annotationsChanged)"
|
||||
*ngIf="annotationPermissions.canChangeLegalBasis"
|
||||
icon="red:edit"
|
||||
tooltip="annotation-actions.edit-reason.label"
|
||||
type="dark-bg"
|
||||
>
|
||||
</redaction-circle-button>
|
||||
|
||||
<redaction-circle-button
|
||||
(action)="
|
||||
annotationActionsService.convertRecommendationToAnnotation(
|
||||
@ -10,7 +19,6 @@
|
||||
*ngIf="annotationPermissions.canAcceptRecommendation"
|
||||
icon="red:check"
|
||||
tooltip="annotation-actions.accept-recommendation.label"
|
||||
tooltipPosition="before"
|
||||
type="dark-bg"
|
||||
>
|
||||
</redaction-circle-button>
|
||||
@ -22,7 +30,6 @@
|
||||
*ngIf="annotationPermissions.canAcceptSuggestion"
|
||||
icon="red:check"
|
||||
tooltip="annotation-actions.accept-suggestion.label"
|
||||
tooltipPosition="before"
|
||||
type="dark-bg"
|
||||
>
|
||||
</redaction-circle-button>
|
||||
@ -34,7 +41,6 @@
|
||||
*ngIf="annotationPermissions.canUndo"
|
||||
icon="red:undo"
|
||||
tooltip="annotation-actions.undo"
|
||||
tooltipPosition="before"
|
||||
type="dark-bg"
|
||||
>
|
||||
</redaction-circle-button>
|
||||
@ -46,7 +52,6 @@
|
||||
*ngIf="annotationPermissions.canRejectSuggestion"
|
||||
icon="red:trash"
|
||||
tooltip="annotation-actions.reject-suggestion"
|
||||
tooltipPosition="before"
|
||||
type="dark-bg"
|
||||
>
|
||||
</redaction-circle-button>
|
||||
@ -61,7 +66,6 @@
|
||||
"
|
||||
icon="red:thumb-down"
|
||||
tooltip="annotation-actions.remove-annotation.false-positive"
|
||||
tooltipPosition="before"
|
||||
type="dark-bg"
|
||||
>
|
||||
</redaction-circle-button>
|
||||
@ -71,7 +75,6 @@
|
||||
*ngIf="annotationPermissions.canForceRedaction"
|
||||
icon="red:thumb-up"
|
||||
tooltip="annotation-actions.force-redaction.label"
|
||||
tooltipPosition="before"
|
||||
type="dark-bg"
|
||||
>
|
||||
</redaction-circle-button>
|
||||
@ -81,7 +84,6 @@
|
||||
*ngIf="annotation.isImage && viewerAnnotation?.isVisible()"
|
||||
icon="red:visibility-off"
|
||||
tooltip="annotation-actions.hide"
|
||||
tooltipPosition="before"
|
||||
type="dark-bg"
|
||||
>
|
||||
</redaction-circle-button>
|
||||
@ -91,7 +93,6 @@
|
||||
*ngIf="annotation.isImage && !viewerAnnotation?.isVisible()"
|
||||
icon="red:visibility"
|
||||
tooltip="annotation-actions.show"
|
||||
tooltipPosition="before"
|
||||
type="dark-bg"
|
||||
>
|
||||
</redaction-circle-button>
|
||||
|
||||
@ -0,0 +1,68 @@
|
||||
<section class="dialog">
|
||||
<form (submit)="save()" [formGroup]="legalBasisForm">
|
||||
<div class="dialog-header heading-l" translate="change-legal-basis-dialog.header"></div>
|
||||
|
||||
<div class="dialog-content">
|
||||
<div class="red-input-group required w-400">
|
||||
<label translate="change-legal-basis-dialog.content.reason"></label>
|
||||
<mat-select
|
||||
[placeholder]="
|
||||
'change-legal-basis-dialog.content.reason-placeholder' | translate
|
||||
"
|
||||
class="full-width"
|
||||
formControlName="reason"
|
||||
>
|
||||
<mat-option
|
||||
*ngFor="let option of legalOptions"
|
||||
[matTooltip]="option.description"
|
||||
[value]="option"
|
||||
>
|
||||
{{ option.label }}
|
||||
</mat-option>
|
||||
</mat-select>
|
||||
</div>
|
||||
|
||||
<div class="red-input-group w-400">
|
||||
<label translate="change-legal-basis-dialog.content.legalBasis"></label>
|
||||
<input
|
||||
[value]="legalBasisForm.get('reason').value?.legalBasis"
|
||||
disabled
|
||||
type="text"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div [class.required]="!isDocumentAdmin" class="red-input-group w-300">
|
||||
<label translate="change-legal-basis-dialog.content.comment"></label>
|
||||
<textarea
|
||||
formControlName="comment"
|
||||
name="comment"
|
||||
redactionHasScrollbar
|
||||
rows="4"
|
||||
type="text"
|
||||
></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="dialog-actions">
|
||||
<button
|
||||
[disabled]="!legalBasisForm.valid || !changed"
|
||||
color="primary"
|
||||
mat-flat-button
|
||||
type="submit"
|
||||
>
|
||||
{{ 'change-legal-basis-dialog.actions.save' | translate }}
|
||||
</button>
|
||||
<div
|
||||
class="all-caps-label cancel"
|
||||
mat-dialog-close
|
||||
translate="change-legal-basis-dialog.actions.cancel"
|
||||
></div>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
<redaction-circle-button
|
||||
class="dialog-close"
|
||||
icon="red:close"
|
||||
mat-dialog-close
|
||||
></redaction-circle-button>
|
||||
</section>
|
||||
@ -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<ChangeLegalBasisDialogComponent>,
|
||||
@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
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -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 = [
|
||||
|
||||
@ -74,6 +74,28 @@ export class AnnotationActionsService {
|
||||
});
|
||||
}
|
||||
|
||||
changeLegalBasis(
|
||||
$event: MouseEvent,
|
||||
annotation: AnnotationWrapper,
|
||||
annotationsChanged: EventEmitter<AnnotationWrapper>
|
||||
) {
|
||||
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[],
|
||||
|
||||
@ -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<ChangeLegalBasisDialogComponent> {
|
||||
$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[],
|
||||
|
||||
@ -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
|
||||
) {
|
||||
|
||||
@ -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",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user