remove annotations/redactions UI WIP

This commit is contained in:
Timo Bejan 2020-11-03 23:58:06 +02:00
parent 9c3aa3fb0e
commit 1bea2aecc9
6 changed files with 101 additions and 17 deletions

View File

@ -217,4 +217,29 @@ export class DialogService {
return ref;
}
openRemoveAnnotationModal(
$event: MouseEvent,
annotation: AnnotationWrapper,
callback: () => void
) {
$event.stopPropagation();
const ref = this._dialog.open(ConfirmationDialogComponent, {
width: '400px',
maxWidth: '90vw'
});
ref.afterClosed().subscribe((result) => {
if (result) {
this._manualAnnotationService.removeAnnotation(annotation).subscribe(() => {
if (callback) {
callback();
}
});
}
});
return ref;
}
}

View File

@ -32,7 +32,7 @@ export class ManualAnnotationDialogComponent implements OnInit {
) {}
async ngOnInit() {
this.isDocumentAdmin = this._appStateService.isActiveProjectOwner;
this.isDocumentAdmin = this._appStateService.isActiveProjectOwnerAndManager;
const commentField = this.isDocumentAdmin ? [null] : [null, Validators.required];
this.redactionForm = this._formBuilder.group({
reason:

View File

@ -171,13 +171,15 @@
<redaction-comments [annotation]="annotation"></redaction-comments>
<div
*ngIf="annotation.superType === 'request'"
[class.visible]="isAnnotationMenuOpen(annotation)"
class="annotation-actions"
>
<button
(click)="openAcceptSuggestionMenu($event, annotation)"
*ngIf="appStateService.isActiveProjectOwnerAndManager"
*ngIf="
appStateService.isActiveProjectOwnerAndManager &&
annotation.superType === 'request'
"
[class.active]="isAnnotationMenuOpen(annotation)"
[matMenuTriggerFor]="menu"
class="confirm"
@ -217,6 +219,14 @@
</mat-menu>
<button
(click)="rejectSuggestion($event, annotation)"
*ngIf="annotation.superType === 'request'"
mat-icon-button
>
<mat-icon svgIcon="red:trash"></mat-icon>
</button>
<button
(click)="suggestRemoveAnnotation($event, annotation)"
*ngIf="annotation.superType !== 'request'"
mat-icon-button
>
<mat-icon svgIcon="red:trash"></mat-icon>

View File

@ -291,14 +291,14 @@ export class FilePreviewScreenComponent implements OnInit {
}
public rejectSuggestion($event: MouseEvent, annotation: AnnotationWrapper) {
this.ngZone.run(() => {
this._dialogRef = this._dialogService.openRejectSuggestionModal(
$event,
annotation,
() => {
this._cleanupAndRedrawManualAnnotations();
}
);
this._dialogRef = this._dialogService.openRejectSuggestionModal($event, annotation, () => {
this._cleanupAndRedrawManualAnnotations();
});
}
suggestRemoveAnnotation($event: MouseEvent, annotation: AnnotationWrapper) {
this._dialogRef = this._dialogService.openRemoveAnnotationModal($event, annotation, () => {
this._cleanupAndRedrawManualAnnotations();
});
}

View File

@ -3,13 +3,12 @@ import { AppStateService } from '../../../state/app-state.service';
import {
DictionaryControllerService,
ManualRedactionControllerService,
ManualRedactionEntry,
ManualRedactions
ManualRedactionEntry
} from '@redaction/red-ui-http';
import { AnnotationWrapper } from '../model/annotation.wrapper';
import { NotificationService, NotificationType } from '../../../notification/notification.service';
import { TranslateService } from '@ngx-translate/core';
import { map, mergeMap, tap } from 'rxjs/operators';
import { mergeMap, tap } from 'rxjs/operators';
import { UserService } from '../../../user/user.service';
@Injectable({
@ -111,7 +110,56 @@ export class ManualAnnotationService {
);
}
public removeRedaction(annotationWrapper: AnnotationWrapper) {}
public removeAnnotation(
annotationWrapper: AnnotationWrapper,
removeFromDictionary: boolean = false
) {
if (this._appStateService.isActiveProjectOwnerAndManager) {
return this._manualRedactionControllerService
.removeRedaction(
{
annotationId: annotationWrapper.id,
removeFromDictionary: removeFromDictionary,
comment: { text: 'Auto' }
},
this._appStateService.activeProjectId,
this._appStateService.activeFileId
)
.pipe(
tap(
() => this._notify('manual-annotation.remove-redaction-request.success'),
() => {
this._notify(
'manual-annotation.remove-redaction-request.error',
NotificationType.ERROR
);
}
)
);
} else {
return this._manualRedactionControllerService
.requestRemoveRedaction(
{
annotationId: annotationWrapper.id,
removeFromDictionary: removeFromDictionary,
comment: { text: 'Auto' }
},
this._appStateService.activeProjectId,
this._appStateService.activeFileId
)
.pipe(
tap(
() => this._notify('manual-annotation.remove-redaction-request.success'),
() => {
this._notify(
'manual-annotation.remove-redaction-request.error',
NotificationType.ERROR
);
}
)
);
}
}
private _makeRedactionRequest(manualRedactionEntry: ManualRedactionEntry) {
return this._manualRedactionControllerService
@ -162,7 +210,7 @@ export class ManualAnnotationService {
}
getTitle(type: 'DICTIONARY' | 'REDACTION') {
if (this._appStateService.isActiveProjectOwner) {
if (this._appStateService.isActiveProjectOwnerAndManager) {
if (type === 'DICTIONARY') {
return 'manual-redaction.dialog.header.dictionary';
} else {

View File

@ -246,7 +246,8 @@
<button
(click)="openDeleteFileDialog($event, fileStatus)"
*ngIf="
userService.isManager(user) || appStateService.isActiveProjectOwner
userService.isManager(user) ||
appStateService.isActiveProjectOwnerAndManager
"
[matTooltip]="'project-overview.delete.action' | translate"
[matTooltipPosition]="'above'"