fixed ignore color

This commit is contained in:
Timo Bejan 2020-11-11 12:27:57 +02:00
parent 0303b9e2c9
commit 86de4f2040
5 changed files with 65 additions and 77 deletions

View File

@ -15,6 +15,10 @@ export class PermissionsService {
return this._userService.user;
}
get currentUserId() {
return this._userService.userId;
}
public isManager(user?: User) {
return this._userService.isManager();
}

View File

@ -23,7 +23,9 @@ export class TypeAnnotationIconComponent implements OnChanges {
? this._appStateService.getDictionaryColor('suggestion-dictionary')
: this._appStateService.getDictionaryColor('suggestion');
} else {
this.color = this._appStateService.getDictionaryColor(this.annotation.dictionary);
this.color = this.annotation.isIgnored
? this._appStateService.getDictionaryColor('ignore')
: this._appStateService.getDictionaryColor(this.annotation.dictionary);
}
this.type = this.annotation.isSuggestion ? 'rhombus' : this.annotation.isRedactedOrIgnored ? 'square' : 'circle';
this.label = this.annotation.isSuggestion ? 'S' : this.annotation.isIgnored ? 'I' : this.annotation.dictionary[0].toUpperCase();

View File

@ -1,73 +1,45 @@
<div [class.visible]="menuType" *ngIf="canPerformAnnotationActions" class="annotation-actions">
<!-- <button-->
<!-- (click)="openMenu($event, 'APPROVE')"-->
<!-- *ngIf="canAcceptSuggestion"-->
<!-- [class.active]="menuType"-->
<!-- [matMenuTriggerFor]="menu"-->
<!-- class="confirm"-->
<!-- mat-icon-button-->
<!-- >-->
<!-- <mat-icon svgIcon="red:check-alt"></mat-icon>-->
<!-- </button>-->
<div [class.visible]="menuOpen" *ngIf="canPerformAnnotationActions" class="annotation-actions">
<!-- Only owner can accept or reject suggestions-->
<ng-container *ngIf="permissionsService.isManagerAndOwner()">
<button (click)="acceptSuggestion($event, annotation, annotation.modifyDictionary)" *ngIf="annotation.isSuggestion" mat-icon-button>
<mat-icon svgIcon="red:check-alt"></mat-icon>
</button>
<button (click)="rejectSuggestion($event, annotation)" *ngIf="annotation.isSuggestion" mat-icon-button>
<mat-icon svgIcon="red:close"></mat-icon>
</button>
</ng-container>
<button
(click)="acceptSuggestion($event, annotation, annotation.modifyDictionary)"
*ngIf="!annotation.canUndo && (annotation.superType === 'suggestion' || annotation.superType === 'suggestion-remove')"
mat-icon-button
>
<mat-icon svgIcon="red:check-alt"></mat-icon>
</button>
<mat-menu #menu="matMenu" (closed)="onMenuClosed()" xPosition="before">
<!-- <ng-container *ngIf="menuType === 'APPROVE'">-->
<!-- <div (click)="acceptSuggestion($event, annotation, true)" mat-menu-item>-->
<!-- <redaction-annotation-icon [typeValue]="suggestionType" [color]="'#5B97DB'"></redaction-annotation-icon>-->
<!-- <div-->
<!-- [translate]="-->
<!-- annotation.superType === 'suggestion'-->
<!-- ? 'file-preview.tabs.annotations.accept-suggestion.add-to-dict'-->
<!-- : 'file-preview.tabs.annotations.accept-suggestion.remove-from-dict'-->
<!-- "-->
<!-- ></div>-->
<!-- </div>-->
<!-- <div (click)="acceptSuggestion($event, annotation, false)" mat-menu-item>-->
<!-- <redaction-annotation-icon [typeValue]="suggestionType"></redaction-annotation-icon>-->
<!-- <div translate="file-preview.tabs.annotations.accept-suggestion.only-here"></div>-->
<!-- </div>-->
<!-- </ng-container>-->
<ng-container *ngIf="menuType === 'SUGGEST-REMOVE'">
<div (click)="suggestRemoveAnnotation($event, annotation, true)" mat-menu-item>
<redaction-type-annotation-icon [annotation]="annotation"></redaction-type-annotation-icon>
<div [translate]="'file-preview.tabs.annotations.remove-annotation.remove-from-dict'"></div>
</div>
<div (click)="suggestRemoveAnnotation($event, annotation, false)" mat-menu-item>
<redaction-type-annotation-icon [annotation]="annotation"></redaction-type-annotation-icon>
<div translate="file-preview.tabs.annotations.remove-annotation.only-here"></div>
</div>
</ng-container>
</mat-menu>
<button (click)="undoDirectAction($event, annotation)" *ngIf="annotation.canUndo" mat-icon-button>
<!-- If we can undo the annotation - allow it-->
<button (click)="undoDirectAction($event, annotation)" *ngIf="canUndoAnnotation()" mat-icon-button>
<mat-icon svgIcon="red:undo"></mat-icon>
</button>
<button
(click)="rejectSuggestion($event, annotation)"
*ngIf="!annotation.canUndo && (annotation.superType === 'suggestion' || annotation.superType === 'suggestion-remove')"
mat-icon-button
>
<mat-icon svgIcon="red:close"></mat-icon>
</button>
<button (click)="suggestRemoveAnnotation($event, annotation, true)" *ngIf="!annotation.canUndo && annotation.superType === 'hint'" mat-icon-button>
<!-- Everyone can suggest to remove annotations, manager will remove directly while user will make a suggestion-->
<!-- For Suggesting Removal, in case of hints, the user can suggest removal from dictionary -->
<button (click)="suggestRemoveAnnotation($event, annotation, true)" *ngIf="annotation.superType === 'hint'" mat-icon-button>
<mat-icon svgIcon="red:trash"></mat-icon>
</button>
<!-- For Suggesting Removal, in case of redactions, the user can suggest only-here or everywhere-->
<button
(click)="openMenu($event, 'SUGGEST-REMOVE')"
*ngIf="!annotation.canUndo && annotation.superType === 'redaction'"
[class.active]="menuType"
(click)="openMenu($event)"
*ngIf="annotation.superType === 'redaction'"
[class.active]="menuOpen"
[matMenuTriggerFor]="menu"
class="confirm"
mat-icon-button
>
<mat-icon svgIcon="red:trash"></mat-icon>
</button>
<mat-menu #menu="matMenu" (closed)="onMenuClosed()" xPosition="before">
<div (click)="suggestRemoveAnnotation($event, annotation, true)" mat-menu-item>
<redaction-type-annotation-icon [annotation]="annotation"></redaction-type-annotation-icon>
<div [translate]="'file-preview.tabs.annotations.remove-annotation.remove-from-dict'"></div>
</div>
<div (click)="suggestRemoveAnnotation($event, annotation, false)" mat-menu-item>
<redaction-type-annotation-icon [annotation]="annotation"></redaction-type-annotation-icon>
<div translate="file-preview.tabs.annotations.remove-annotation.only-here"></div>
</div>
</mat-menu>
</div>

View File

@ -18,7 +18,7 @@ export class AnnotationActionsComponent implements OnInit {
@Output() annotationsChanged = new EventEmitter();
suggestionType: TypeValue;
menuType: 'APPROVE' | 'SUGGEST-REMOVE';
menuOpen: boolean;
constructor(
public appStateService: AppStateService,
@ -65,12 +65,19 @@ export class AnnotationActionsComponent implements OnInit {
);
}
public openMenu($event: MouseEvent, menuType: 'APPROVE' | 'SUGGEST-REMOVE') {
public openMenu($event: MouseEvent) {
$event.preventDefault();
this.menuType = menuType;
this.menuOpen = true;
}
public onMenuClosed() {
this.menuType = null;
this.menuOpen = false;
}
canUndoAnnotation() {
const isSuggestionOfCurrentUser = this.annotation.isSuggestion && this.annotation.userId === this.permissionsService.currentUserId;
const isManualAnnotationOfCurrentUser =
this.annotation.manual && this.annotation.userId === this.permissionsService.currentUserId && this.permissionsService.isManagerAndOwner();
return isSuggestionOfCurrentUser || isManualAnnotationOfCurrentUser;
}
}

View File

@ -1,4 +1,4 @@
import { Comment, FileStatus, IdRemoval, ManualRedactionEntry, Point, Rectangle, RedactionLogEntry, TypeValue } from '@redaction/red-ui-http';
import { Comment, IdRemoval, ManualRedactionEntry, Point, Rectangle, RedactionLogEntry, TypeValue } from '@redaction/red-ui-http';
import { UserWrapper } from '../../../user/user.service';
import { FileStatusWrapper } from './file-status.wrapper';
@ -20,7 +20,6 @@ export class AnnotationWrapper {
content: string;
manual: boolean;
userId: string;
canUndo: boolean;
modifyDictionary: boolean;
typeLabel: string;
pageNumber: number;
@ -54,6 +53,8 @@ export class AnnotationWrapper {
annotationWrapper.comments = comments ? comments : [];
annotationWrapper.shouldDraw = true;
annotationWrapper.userId = manualRedactionEntry?.user || idRemoval?.user;
if (redactionLogEntry) {
if (redactionLogEntry.manual) {
if (!manualRedactionEntry && redactionLogEntry.manualRedactionType === 'ADD') {
@ -69,10 +70,9 @@ export class AnnotationWrapper {
annotationWrapper.firstTopLeftPoint = redactionLogEntry.positions[0]?.topLeft;
annotationWrapper.pageNumber = redactionLogEntry.positions[0]?.page;
annotationWrapper.positions = redactionLogEntry.positions;
annotationWrapper.content = AnnotationWrapper.createContentForRedactionLog(redactionLogEntry);
annotationWrapper.content = AnnotationWrapper.createContent(redactionLogEntry);
// either marked as manual or idRemove or manualRedactionEntry exists
annotationWrapper.manual = redactionLogEntry.manual;
annotationWrapper.canUndo = manualRedactionEntry?.user === user.id || idRemoval?.user === user.id;
annotationWrapper.modifyDictionary = !!manualRedactionEntry?.addToDictionary || !!idRemoval?.removeFromDictionary;
AnnotationWrapper._setSuperType(annotationWrapper, redactionLogEntry, manualRedactionEntry, idRemoval);
} else {
@ -84,11 +84,10 @@ export class AnnotationWrapper {
annotationWrapper.firstTopLeftPoint = manualRedactionEntry.positions[0]?.topLeft;
annotationWrapper.pageNumber = manualRedactionEntry.positions[0]?.page;
annotationWrapper.positions = manualRedactionEntry.positions;
annotationWrapper.content = manualRedactionEntry.addToDictionary ? null : AnnotationWrapper.createContentForManualRedaction(manualRedactionEntry);
annotationWrapper.content = manualRedactionEntry.addToDictionary ? null : AnnotationWrapper.createContent(manualRedactionEntry);
annotationWrapper.manual = true;
annotationWrapper.comments = comments[manualRedactionEntry.id] ? comments[manualRedactionEntry.id] : [];
annotationWrapper.userId = manualRedactionEntry.user;
annotationWrapper.canUndo = manualRedactionEntry?.user === user.id;
annotationWrapper.modifyDictionary = manualRedactionEntry.addToDictionary;
AnnotationWrapper._setSuperType(annotationWrapper, redactionLogEntry, manualRedactionEntry, idRemoval);
}
@ -154,13 +153,17 @@ export class AnnotationWrapper {
return this.firstTopLeftPoint.y;
}
private static createContentForRedactionLog(entry: RedactionLogEntry) {
if (entry.redacted) {
return entry.reason + '\n\nLegal basis:' + entry.legalBasis + '\n\nIn section: "' + entry.section + '"';
private static createContent(entry: any) {
let content = '';
if (entry.reason) {
content += entry.reason + '\n\n';
}
}
private static createContentForManualRedaction(entry: ManualRedactionEntry) {
return entry.reason + '\n\nLegal basis:' + entry.legalBasis;
if (entry.legalBasis) {
content += 'Legal basis:' + entry.legalBasis + '\n\n';
}
if (entry.section) {
content += 'In section: "' + entry.section + '"';
}
return content;
}
}