diff --git a/apps/red-ui/src/app/common/filter/filter.component.ts b/apps/red-ui/src/app/common/filter/filter.component.ts index f1ea84a5b..02acb5487 100644 --- a/apps/red-ui/src/app/common/filter/filter.component.ts +++ b/apps/red-ui/src/app/common/filter/filter.component.ts @@ -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) { diff --git a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts index 7423a3ec3..068724a06 100644 --- a/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/screens/file/file-preview-screen/file-preview-screen.component.ts @@ -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(); }); } } diff --git a/apps/red-ui/src/app/screens/file/model/annotation.wrapper.ts b/apps/red-ui/src/app/screens/file/model/annotation.wrapper.ts index 79998c81c..e520219c9 100644 --- a/apps/red-ui/src/app/screens/file/model/annotation.wrapper.ts +++ b/apps/red-ui/src/app/screens/file/model/annotation.wrapper.ts @@ -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 } + comments: { [p: string]: Array }, + 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() { diff --git a/apps/red-ui/src/app/screens/file/model/file-data.model.ts b/apps/red-ui/src/app/screens/file/model/file-data.model.ts index cc92e42cd..f3e623d1c 100644 --- a/apps/red-ui/src/app/screens/file/model/file-data.model.ts +++ b/apps/red-ui/src/app/screens/file/model/file-data.model.ts @@ -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) ); } } diff --git a/apps/red-ui/src/app/screens/file/service/annotation-draw.service.ts b/apps/red-ui/src/app/screens/file/service/annotation-draw.service.ts index 024450d09..596d292ab 100644 --- a/apps/red-ui/src/app/screens/file/service/annotation-draw.service.ts +++ b/apps/red-ui/src/app/screens/file/service/annotation-draw.service.ts @@ -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);