diff --git a/apps/red-ui/src/app/modules/projects/components/file-workload/file-workload.component.html b/apps/red-ui/src/app/modules/projects/components/file-workload/file-workload.component.html index 59307364c..5c88ae2bd 100644 --- a/apps/red-ui/src/app/modules/projects/components/file-workload/file-workload.component.html +++ b/apps/red-ui/src/app/modules/projects/components/file-workload/file-workload.component.html @@ -12,6 +12,7 @@ [filterTemplate]="annotationFilterTemplate" [actionsTemplate]="annotationFilterActionTemplate" [filters]="annotationFilters" + [enableFilterOptions]="true" > diff --git a/apps/red-ui/src/app/modules/projects/components/file-workload/file-workload.component.ts b/apps/red-ui/src/app/modules/projects/components/file-workload/file-workload.component.ts index d09b08029..2ab4eb6b4 100644 --- a/apps/red-ui/src/app/modules/projects/components/file-workload/file-workload.component.ts +++ b/apps/red-ui/src/app/modules/projects/components/file-workload/file-workload.component.ts @@ -45,6 +45,7 @@ export class FileWorkloadComponent { public quickScrollLastEnabled = false; public displayedPages: number[] = []; public pagesPanelActive = true; + public filterOnlyWithComments = false; @ViewChild('annotationsElement') private _annotationsElement: ElementRef; @ViewChild('quickNavigation') private _quickNavigationElement: ElementRef; @@ -109,8 +110,8 @@ export class FileWorkloadComponent { } @debounce(0) - public filtersChanged(filters: FilterModel[]) { - this.displayedAnnotations = this._annotationProcessingService.filterAndGroupAnnotations(this._annotations, filters); + public filtersChanged($event: { filters: FilterModel[]; extraFilterBy?: (annotation: AnnotationWrapper) => boolean }) { + this.displayedAnnotations = this._annotationProcessingService.filterAndGroupAnnotations(this._annotations, $event.filters, $event.extraFilterBy); this.displayedPages = Object.keys(this.displayedAnnotations).map((key) => Number(key)); this.computeQuickNavButtonsState(); this._changeDetectorRef.markForCheck(); diff --git a/apps/red-ui/src/app/modules/projects/screens/file-preview-screen/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/projects/screens/file-preview-screen/file-preview-screen.component.ts index e09b48f8c..f5cc77839 100644 --- a/apps/red-ui/src/app/modules/projects/screens/file-preview-screen/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/projects/screens/file-preview-screen/file-preview-screen.component.ts @@ -218,7 +218,7 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach, ); const annotationFilters = this._annotationProcessingService.getAnnotationFilter(this.annotations); this.annotationFilters = processFilters(this.annotationFilters, annotationFilters); - this._workloadComponent.filtersChanged(this.annotationFilters); + this._workloadComponent.filtersChanged({ filters: this.annotationFilters }); console.log('[REDACTION] Process time: ' + (new Date().getTime() - processStartTime) + 'ms'); console.log( '[REDACTION] Annotation Redraw and filter rebuild time: ' + @@ -527,7 +527,7 @@ export class FilePreviewScreenComponent implements OnInit, OnDestroy, OnAttach, const oldPageSpecificFilters = this._annotationProcessingService.getAnnotationFilter(currentPageAnnotations); const newPageSpecificFilters = this._annotationProcessingService.getAnnotationFilter(newPageAnnotations); handleFilterDelta(oldPageSpecificFilters, newPageSpecificFilters, this.annotationFilters); - this._workloadComponent.filtersChanged(this.annotationFilters); + this._workloadComponent.filtersChanged({ filters: this.annotationFilters }); } } diff --git a/apps/red-ui/src/app/modules/projects/services/annotation-processing.service.ts b/apps/red-ui/src/app/modules/projects/services/annotation-processing.service.ts index b55219238..5fe3b3592 100644 --- a/apps/red-ui/src/app/modules/projects/services/annotation-processing.service.ts +++ b/apps/red-ui/src/app/modules/projects/services/annotation-processing.service.ts @@ -62,7 +62,11 @@ export class AnnotationProcessingService { return filter; } - filterAndGroupAnnotations(annotations: AnnotationWrapper[], filters: FilterModel[]): { [key: number]: { annotations: AnnotationWrapper[] } } { + filterAndGroupAnnotations( + annotations: AnnotationWrapper[], + filters: FilterModel[], + extraFilterBy?: (annotation: AnnotationWrapper) => boolean + ): { [key: number]: { annotations: AnnotationWrapper[] } } { const obj = {}; const hasActiveFilters = this._hasActiveFilters(filters); @@ -73,6 +77,10 @@ export class AnnotationProcessingService { flatFilters.push(...filter.filters); }); for (const annotation of annotations) { + if (typeof extraFilterBy === 'function' && !extraFilterBy(annotation)) { + continue; + } + const pageNumber = annotation.pageNumber; const type = annotation.superType; @@ -103,6 +111,7 @@ export class AnnotationProcessingService { skipped: 0 }; } + obj[pageNumber].annotations.push(annotation); obj[pageNumber][type]++; } diff --git a/apps/red-ui/src/app/modules/shared/components/filter/filter.component.html b/apps/red-ui/src/app/modules/shared/components/filter/filter.component.html index 032f6e59d..471b7196a 100644 --- a/apps/red-ui/src/app/modules/shared/components/filter/filter.component.html +++ b/apps/red-ui/src/app/modules/shared/components/filter/filter.component.html @@ -1,58 +1,63 @@ -