show manual redactions and their pages when excluded

This commit is contained in:
Dan Percic 2021-11-06 02:49:57 +02:00
parent a3e2f1d498
commit 0504086fef
4 changed files with 21 additions and 12 deletions

View File

@ -24,7 +24,7 @@ export class FileDataModel {
const entries: RedactionLogEntryWrapper[] = this._convertData();
let allAnnotations = entries
.map(entry => AnnotationWrapper.fromData(entry))
.filter(ann => !this.file.excludedPages.includes(ann.pageNumber));
.filter(ann => ann.manual || !this.file.excludedPages.includes(ann.pageNumber));
if (!areDevFeaturesEnabled) {
allAnnotations = allAnnotations.filter(annotation => !annotation.isFalsePositive);

View File

@ -88,6 +88,7 @@
[activeSelection]="pageHasSelection(pageNumber)"
[active]="pageNumber === activeViewerPage"
[number]="pageNumber"
[showDottedIcon]="hasOnlyManualRedactionsAndNotExcluded(pageNumber)"
[viewedPages]="fileData?.viewedPages"
></redaction-page-indicator>
</div>

View File

@ -118,6 +118,11 @@ export class FileWorkloadComponent {
}
}
hasOnlyManualRedactionsAndNotExcluded(pageNumber: number): boolean {
const hasOnlyManualRedactions = this.displayedAnnotations.get(pageNumber).every(annotation => annotation.manual);
return hasOnlyManualRedactions && this.fileData.file.excludedPages.includes(pageNumber);
}
pageHasSelection(page: number) {
return this.multiSelectActive && !!this.selectedAnnotations?.find(a => a.pageNumber === page);
}

View File

@ -323,7 +323,7 @@ export class PdfViewerComponent implements OnInit, OnChanges {
textTool.SELECTION_MODE = this._configService.values.SELECTION_MODE;
}
private _toggleRectangleAnnotationAction(readonly: boolean) {
private _toggleRectangleAnnotationAction(readonly = false) {
if (!readonly) {
this.instance.UI.enableElements([dataElements.ADD_RECTANGLE]);
} else {
@ -529,14 +529,14 @@ export class PdfViewerComponent implements OnInit, OnChanges {
this.instance.UI.textPopup.add([
{
type: 'actionButton',
dataElement: 'add-redaction',
dataElement: dataElements.ADD_REDACTION,
img: this._convertPath('/assets/icons/general/pdftron-action-add-redaction.svg'),
title: this._translateService.instant(this._manualAnnotationService.getTitle(ManualRedactionEntryTypes.REDACTION)),
onClick: () => this._addManualRedactionOfType(ManualRedactionEntryTypes.REDACTION),
},
{
type: 'actionButton',
dataElement: 'add-dictionary',
dataElement: dataElements.ADD_DICTIONARY,
img: this._convertPath('/assets/icons/general/pdftron-action-add-dict.svg'),
title: this._translateService.instant(this._manualAnnotationService.getTitle(ManualRedactionEntryTypes.DICTIONARY)),
onClick: () => this._addManualRedactionOfType(ManualRedactionEntryTypes.DICTIONARY),
@ -555,13 +555,14 @@ export class PdfViewerComponent implements OnInit, OnChanges {
private _handleCustomActions() {
this.instance.UI.setToolMode('AnnotationEdit');
const { ANNOTATION_POPUP, ADD_RECTANGLE, ADD_REDACTION, SHAPE_TOOL_GROUP_BUTTON } = dataElements;
const elements = [
'add-redaction',
'add-rectangle',
ADD_REDACTION,
ADD_RECTANGLE,
'add-false-positive',
'shapeToolGroupButton',
SHAPE_TOOL_GROUP_BUTTON,
'rectangleToolDivider',
'annotationPopup',
ANNOTATION_POPUP,
];
if (this.canPerformActions && !this.utils.isCurrentPageExcluded) {
@ -575,13 +576,15 @@ export class PdfViewerComponent implements OnInit, OnChanges {
return;
}
const elementsToDisable = [...elements, dataElements.ADD_RECTANGLE];
let elementsToDisable = [...elements, ADD_RECTANGLE];
if (this.utils.isCurrentPageExcluded) {
elementsToDisable.splice(elementsToDisable.indexOf(dataElements.ADD_REDACTION), 1);
elementsToDisable.splice(elementsToDisable.indexOf(dataElements.SHAPE_TOOL_GROUP_BUTTON), 1);
const allowedActionsWhenPageExcluded: string[] = [ANNOTATION_POPUP, ADD_RECTANGLE, ADD_REDACTION, SHAPE_TOOL_GROUP_BUTTON];
elementsToDisable = elementsToDisable.filter(element => !allowedActionsWhenPageExcluded.includes(element));
} else {
this.instance.UI.disableTools(['AnnotationCreateRectangle']);
}
this.instance.UI.disableTools(['AnnotationCreateRectangle']);
this.instance.UI.disableElements(elementsToDisable);
}