manual redaction fixes

This commit is contained in:
Timo Bejan 2020-11-03 09:45:57 +02:00
parent 5a3f6852ea
commit e4c3b6bcdb
5 changed files with 78 additions and 24 deletions

View File

@ -27,7 +27,24 @@ export class FilterComponent implements OnChanges {
constructor(public readonly appStateService: AppStateService) {}
ngOnChanges(changes: SimpleChanges): void {
// this.filtersChanged.emit(this.filters);
if (changes.filters) {
const oldFilters = changes.filters.previousValue;
this._copySettings(oldFilters, this.filters);
}
}
private _copySettings(oldFilters: FilterModel[], newFilters: FilterModel[]) {
if (oldFilters && newFilters) {
for (let oldFilter of oldFilters) {
const newFilter = newFilters.find((f) => f.key === oldFilter.key);
if (newFilter) {
newFilter.checked = oldFilter.checked;
newFilter.indeterminate = oldFilter.indeterminate;
this._copySettings(oldFilter.filters, newFilter.filters);
handleCheckedValue(newFilter);
}
}
}
}
filterCheckboxClicked($event: any, filter: FilterModel, parent?: FilterModel) {

View File

@ -92,7 +92,6 @@ export class FilePreviewScreenComponent implements OnInit {
@ViewChild(PdfViewerComponent) private _viewerComponent: PdfViewerComponent;
@ViewChild('annotationsElement') private _annotationsElement: ElementRef;
@ViewChild('quickNavigation') private _quickNavigationElement: ElementRef;
@ViewChild('menu') private _matMenuTrigger: MatMenuTrigger;
public fileData: FileDataModel;
public fileId: string;
@ -118,23 +117,30 @@ export class FilePreviewScreenComponent implements OnInit {
private _loadFileData() {
this._fileDownloadService.loadActiveFileData().subscribe((fileDataModel) => {
this.fileData = fileDataModel;
const manualRedactionAnnotations = fileDataModel.entriesToAdd.map((mr) =>
AnnotationWrapper.fromManualRedaction(mr, fileDataModel.manualRedactions.comments)
);
const redactionLogAnnotations = fileDataModel.redactionLog.redactionLogEntry.map(
(rde) =>
AnnotationWrapper.fromRedactionLog(rde, fileDataModel.manualRedactions.comments)
);
this.annotations.push(...manualRedactionAnnotations);
this.annotations.push(...redactionLogAnnotations);
this.filters = this._annotationProcessingService.getAnnotationFilter(this.annotations);
this.filtersChanged(this.filters);
this._changeDetectorRef.detectChanges();
this._rebuildFilters();
});
}
private _rebuildFilters() {
const manualRedactionAnnotations = this.fileData.entriesToAdd.map((mr) =>
AnnotationWrapper.fromManualRedaction(
mr,
this.fileData.manualRedactions.comments,
this.appStateService.dictionaryData
)
);
const redactionLogAnnotations = this.fileData.redactionLog.redactionLogEntry.map((rde) =>
AnnotationWrapper.fromRedactionLog(rde, this.fileData.manualRedactions.comments)
);
this.annotations.splice(0, this.annotations.length);
this.annotations.push(...manualRedactionAnnotations);
this.annotations.push(...redactionLogAnnotations);
this.filters = this._annotationProcessingService.getAnnotationFilter(this.annotations);
this.filtersChanged(this.filters);
this._changeDetectorRef.detectChanges();
}
public openFileDetailsDialog($event: MouseEvent) {
this._dialogRef = this._dialogService.openFileDetailsDialog(
$event,
@ -257,7 +263,6 @@ export class FilePreviewScreenComponent implements OnInit {
public openAcceptSuggestionMenu($event: MouseEvent, annotation: AnnotationWrapper) {
$event.preventDefault();
this._activeSuggestion = annotation;
this._matMenuTrigger.openMenu();
}
public onSuggestionMenuClose() {
@ -459,6 +464,7 @@ export class FilePreviewScreenComponent implements OnInit {
this.instance,
this.fileData.entriesToAdd
);
this._rebuildFilters();
});
}
}

View File

@ -1,4 +1,10 @@
import { Comment, ManualRedactionEntry, Point, RedactionLogEntry } from '@redaction/red-ui-http';
import {
Comment,
ManualRedactionEntry,
Point,
RedactionLogEntry,
TypeValue
} from '@redaction/red-ui-http';
export class AnnotationWrapper {
superType: 'request' | 'redaction' | 'hint' | 'ignore';
@ -39,11 +45,16 @@ export class AnnotationWrapper {
static fromManualRedaction(
manualRedactionEntry: ManualRedactionEntry,
comments: { [key: string]: Array<Comment> }
comments: { [p: string]: Array<Comment> },
dictionaryData: { [p: string]: TypeValue }
) {
console.log(manualRedactionEntry);
const annotationWrapper = new AnnotationWrapper();
annotationWrapper.superType = !manualRedactionEntry.addToDictionary ? 'request' : 'request';
annotationWrapper.superType = AnnotationWrapper.getManualRedactionSuperType(
manualRedactionEntry,
dictionaryData
);
annotationWrapper.dictionary = manualRedactionEntry.type;
annotationWrapper.firstTopLeftPoint = manualRedactionEntry.positions[0]?.topLeft;
annotationWrapper.pageNumber = manualRedactionEntry.positions[0]?.page;
@ -58,6 +69,18 @@ export class AnnotationWrapper {
return annotationWrapper;
}
static getManualRedactionSuperType(
manualRedactionEntry: ManualRedactionEntry,
dictionaryData: { [p: string]: TypeValue }
) {
const dictionary = dictionaryData[manualRedactionEntry.type];
return manualRedactionEntry.status === 'REQUESTED'
? 'request'
: dictionary.hint
? 'hint'
: 'redaction';
}
constructor() {}
get manualRedactionOwner() {

View File

@ -10,7 +10,9 @@ export class FileDataModel {
get entriesToAdd(): ManualRedactionEntry[] {
return this.manualRedactions.entriesToAdd.filter(
(e) => !this.redactionLog.redactionLogEntry.find((r) => r.id === e.id)
(e) =>
e.status !== 'DECLINED' &&
!this.redactionLog.redactionLogEntry.find((r) => r.id === e.id)
);
}
}

View File

@ -3,6 +3,7 @@ import { WebViewerInstance } from '@pdftron/webviewer';
import { ManualRedactionEntry, Rectangle } from '@redaction/red-ui-http';
import { hexToRgb } from '../../../utils/functions';
import { AppStateService } from '../../../state/app-state.service';
import { AnnotationWrapper } from '../model/annotation.wrapper';
@Injectable({
providedIn: 'root'
@ -32,9 +33,14 @@ export class AnnotationDrawService {
private _getColor(activeViewer: WebViewerInstance, manualRedactionEntry: ManualRedactionEntry) {
// if you're the owner, use the request color, otherwise use the actual dict color
const color = this._appStateService.isActiveProjectOwner
? this._appStateService.getDictionaryColor(manualRedactionEntry.type)
: this._appStateService.getDictionaryColor('request');
const superType = AnnotationWrapper.getManualRedactionSuperType(
manualRedactionEntry,
this._appStateService.dictionaryData
);
const color =
superType === 'request'
? this._appStateService.getDictionaryColor('request')
: this._appStateService.getDictionaryColor(manualRedactionEntry.type);
const rgbColor = hexToRgb(color);
return new activeViewer.Annotations.Color(rgbColor.r, rgbColor.g, rgbColor.b);