From 1b8bcaa1e426ff1eb7a8f5bdbe5304f60d7c2d5e Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Wed, 23 Feb 2022 13:54:04 +0200 Subject: [PATCH] RED-3459: only pages without annotations filters --- .../file-workload.component.html | 14 +++++-- .../file-workload/file-workload.component.ts | 40 ++++++++++++++----- .../file-preview-screen.component.ts | 11 +++-- .../services/annotation-processing.service.ts | 11 ++++- apps/red-ui/src/assets/i18n/en.json | 6 ++- libs/common-ui | 2 +- 6 files changed, 64 insertions(+), 20 deletions(-) diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.html b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.html index a39979f30..cc48bfa09 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.html +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.html @@ -16,8 +16,8 @@ (click)="multiSelectService.activate()" *ngIf="(multiSelectService.enabled$ | async) && (multiSelectInactive$ | async)" class="all-caps-label primary pointer" - translate="file-preview.tabs.annotations.select" iqserHelpMode="bulk_select_annotations" + translate="file-preview.tabs.annotations.select" > - + {{ 'file-preview.tabs.annotations.page-is' | translate }} . + + + {{ 'file-preview.tabs.annotations.wrong-filters' | translate }} + + {{ 'file-preview.tabs.annotations.the-filters' | translate }} +
diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.ts index c3fd3396e..49e0d9989 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/file-workload/file-workload.component.ts @@ -34,6 +34,7 @@ import { MultiSelectService } from '../../services/multi-select.service'; import { DocumentInfoService } from '../../services/document-info.service'; import { SkippedService } from '../../services/skipped.service'; import { FilePreviewStateService } from '../../services/file-preview-state.service'; +import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; const COMMAND_KEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Escape']; const ALL_HOTKEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown']; @@ -47,6 +48,8 @@ const ALL_HOTKEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown']; export class FileWorkloadComponent { readonly iconButtonTypes = IconButtonTypes; readonly circleButtonTypes = CircleButtonTypes; + readonly noDataI18NKey = _('file-preview.no-data.title'); + readonly resetFiltersI18NKey = _('file-preview.reset-filters'); displayedAnnotations = new Map(); @Input() selectedAnnotations: AnnotationWrapper[]; @@ -72,14 +75,14 @@ export class FileWorkloadComponent { @ViewChild('quickNavigation') private readonly _quickNavigationElement: ElementRef; constructor( - readonly excludedPagesService: ExcludedPagesService, - readonly multiSelectService: MultiSelectService, - readonly documentInfoService: DocumentInfoService, + readonly filterService: FilterService, readonly skippedService: SkippedService, readonly state: FilePreviewStateService, - private readonly _permissionsService: PermissionsService, + readonly multiSelectService: MultiSelectService, + readonly documentInfoService: DocumentInfoService, + readonly excludedPagesService: ExcludedPagesService, private readonly _changeDetectorRef: ChangeDetectorRef, - private readonly _filterService: FilterService, + private readonly _permissionsService: PermissionsService, private readonly _annotationProcessingService: AnnotationProcessingService, ) { this.displayedAnnotations$ = this._displayedAnnotations$; @@ -138,14 +141,18 @@ export class FileWorkloadComponent { } private get _displayedAnnotations$(): Observable> { - const primary$ = this._filterService.getFilterModels$('primaryFilters'); - const secondary$ = this._filterService.getFilterModels$('secondaryFilters'); + const primary$ = this.filterService.getFilterModels$('primaryFilters'); + const secondary$ = this.filterService.getFilterModels$('secondaryFilters'); return combineLatest([this._annotations$.asObservable(), primary$, secondary$]).pipe( map(([annotations, primary, secondary]) => this._filterAnnotations(annotations, primary, secondary)), ); } + get #allPages() { + return Array.from({ length: this.file?.numberOfPages }, (x, i) => i + 1); + } + private static _scrollToFirstElement(elements: HTMLElement[], mode: 'always' | 'if-needed' = 'if-needed') { if (elements.length > 0) { scrollIntoView(elements[0], { @@ -335,11 +342,26 @@ export class FileWorkloadComponent { secondary: INestedFilter[] = [], ): Map { if (!primary || primary.length === 0) { - this.displayedPages = Array.from({ length: this.file?.numberOfPages }, (x, i) => i + 1); + this.displayedPages = this.#allPages; return; } + this.displayedAnnotations = this._annotationProcessingService.filterAndGroupAnnotations(annotations, primary, secondary); - this.displayedPages = [...this.displayedAnnotations.keys()]; + const pagesThatDisplayAnnotations = [...this.displayedAnnotations.keys()]; + const enabledFilters = this.filterService.enabledFlatFilters; + if (enabledFilters.some(f => f.id === 'pages-without-annotations')) { + if (enabledFilters.length === 1) { + this.displayedPages = this.#allPages.filter(page => !pagesThatDisplayAnnotations.includes(page)); + } else { + this.displayedPages = []; + } + this.displayedAnnotations.clear(); + } else if (enabledFilters.length) { + this.displayedPages = pagesThatDisplayAnnotations; + } else { + this.displayedPages = this.#allPages; + } + return this.displayedAnnotations; } diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts index fc17cf93a..785b034ce 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/file-preview-screen.component.ts @@ -435,10 +435,13 @@ export class FilePreviewScreenComponent extends AutoUnsubscribe implements OnIni } async downloadOriginalFile(file: File) { - const data = await this._fileManagementService - .downloadOriginalFile(this.dossierId, this.fileId, 'response', file.cacheIdentifier) - .toPromise(); - download(data, file.filename); + const originalFile = this._fileManagementService.downloadOriginalFile( + this.dossierId, + this.fileId, + 'response', + file.cacheIdentifier, + ); + download(await firstValueFrom(originalFile), file.filename); } #deactivateMultiSelect(): void { diff --git a/apps/red-ui/src/app/modules/dossier/services/annotation-processing.service.ts b/apps/red-ui/src/app/modules/dossier/services/annotation-processing.service.ts index 5c1ea0c65..06bbf924f 100644 --- a/apps/red-ui/src/app/modules/dossier/services/annotation-processing.service.ts +++ b/apps/red-ui/src/app/modules/dossier/services/annotation-processing.service.ts @@ -9,6 +9,7 @@ import { IViewedPage } from '@red/domain'; @Injectable() export class AnnotationProcessingService { static secondaryAnnotationFilters(viewedPages: IViewedPage[]): INestedFilter[] { + const _viewedPages = viewedPages.map(page => page.page); return [ { id: 'with-comments', @@ -32,7 +33,15 @@ export class AnnotationProcessingService { label: _('filter-menu.unseen-pages'), checked: false, topLevelFilter: true, - checker: (annotation: AnnotationWrapper) => !viewedPages.map(page => page.page).includes(annotation.pageNumber), + checker: (annotation: AnnotationWrapper) => !_viewedPages.includes(annotation.pageNumber), + }, + { + id: 'pages-without-annotations', + icon: 'iqser:pages', + label: _('filter-menu.pages-without-annotations'), + checked: false, + topLevelFilter: true, + checker: () => true, }, ].map(item => new NestedFilter(item)); } diff --git a/apps/red-ui/src/assets/i18n/en.json b/apps/red-ui/src/assets/i18n/en.json index 086f554f0..ed148fdc3 100644 --- a/apps/red-ui/src/assets/i18n/en.json +++ b/apps/red-ui/src/assets/i18n/en.json @@ -1226,9 +1226,12 @@ "jump-to-previous": "Jump to Previous", "label": "Workload", "page-is": "This page is", + "reset": "reset", "select": "Select", "select-all": "All", - "select-none": "None" + "select-none": "None", + "the-filters": "the filters", + "wrong-filters": "The selected filter combination is not possible. Please adjust or" }, "document-info": { "close": "Close Document Info", @@ -1284,6 +1287,7 @@ "filter-options": "Filter options", "filter-types": "Filter", "label": "Filter", + "pages-without-annotations": "Only pages without annotations", "redaction-changes": "Only annotations with redaction changes", "unseen-pages": "Only annotations on unseen pages", "with-comments": "Only annotations with comments" diff --git a/libs/common-ui b/libs/common-ui index e2f853655..174b239f2 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit e2f85365512c68b927465ee5fe4c0d8e3d5dfe1a +Subproject commit 174b239f26e9b877648f5c63432abf8c9bb97654