RED-10504 - displayed all file annotations on documine when devMode is active and removed page filtering

This commit is contained in:
Valentin Mihai 2024-11-23 19:42:31 +02:00
parent 13e019b5e5
commit 67020213ed
6 changed files with 30 additions and 17 deletions

View File

@ -146,7 +146,7 @@
id="annotations-list" id="annotations-list"
tabindex="1" tabindex="1"
> >
<ng-container *ngIf="pdf.currentPage() && !displayedAnnotations().get(pdf.currentPage())?.length"> <ng-container *ngIf="pdf.currentPage() && !displayedAnnotations().get(currentAnnotationsPage)?.length">
<iqser-empty-state <iqser-empty-state
[horizontalPadding]="24" [horizontalPadding]="24"
[text]="'file-preview.no-data.title' | translate" [text]="'file-preview.no-data.title' | translate"

View File

@ -60,6 +60,7 @@ import { PagesComponent } from '../pages/pages.component';
import { ReadonlyBannerComponent } from '../readonly-banner/readonly-banner.component'; import { ReadonlyBannerComponent } from '../readonly-banner/readonly-banner.component';
import { DocumentInfoComponent } from '../document-info/document-info.component'; import { DocumentInfoComponent } from '../document-info/document-info.component';
import { getLast } from '@utils/functions'; import { getLast } from '@utils/functions';
import { ALL_ANNOTATIONS_PAGE } from '../../utils/constants';
const COMMAND_KEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Escape']; const COMMAND_KEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown', 'Escape'];
const ALL_HOTKEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown']; const ALL_HOTKEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown'];
@ -158,7 +159,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
this.filteredAnnotations$ = this._filteredAnnotations$; this.filteredAnnotations$ = this._filteredAnnotations$;
this.annotationsList$ = combineLatest([this.filteredAnnotations$, this.pdf.currentPage$]).pipe( this.annotationsList$ = combineLatest([this.filteredAnnotations$, this.pdf.currentPage$]).pipe(
map(([annotations, page]) => annotations.get(page)), map(([annotations]) => annotations.get(this.currentAnnotationsPage)),
); );
effect(() => { effect(() => {
@ -455,19 +456,24 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
this.displayedAnnotations.set(this._annotationProcessingService.filterAndGroupAnnotations(annotations, primary, secondary)); this.displayedAnnotations.set(this._annotationProcessingService.filterAndGroupAnnotations(annotations, primary, secondary));
const pagesThatDisplayAnnotations = [...this.displayedAnnotations().keys()]; const pagesThatDisplayAnnotations = [...this.displayedAnnotations().keys()];
this.enabledFilters = this.filterService.enabledFlatFilters; this.enabledFilters = this.filterService.enabledFlatFilters;
if (this.enabledFilters.some(f => f.id === 'pages-without-annotations')) { if (this.isDocumine && this.#isIqserDevMode) {
if (this.enabledFilters.length === 1 && !onlyPageWithAnnotations) {
const pages = allPages.filter(page => !pagesThatDisplayAnnotations.includes(page));
this.#setDisplayedPages(pages);
} else {
this.#setDisplayedPages([]);
}
this.displayedAnnotations().clear();
} else if (this.enabledFilters.length || onlyPageWithAnnotations || componentReferenceIds) {
this.#setDisplayedPages(pagesThatDisplayAnnotations);
} else {
this.#setDisplayedPages(allPages); this.#setDisplayedPages(allPages);
} else {
if (this.enabledFilters.some(f => f.id === 'pages-without-annotations')) {
if (this.enabledFilters.length === 1 && !onlyPageWithAnnotations) {
const pages = allPages.filter(page => !pagesThatDisplayAnnotations.includes(page));
this.#setDisplayedPages(pages);
} else {
this.#setDisplayedPages([]);
}
this.displayedAnnotations().clear();
} else if (this.enabledFilters.length || onlyPageWithAnnotations || componentReferenceIds) {
this.#setDisplayedPages(pagesThatDisplayAnnotations);
} else {
this.#setDisplayedPages(allPages);
}
} }
this.displayedPages.sort((a, b) => a - b); this.displayedPages.sort((a, b) => a - b);
return this.displayedAnnotations(); return this.displayedAnnotations();
@ -590,6 +596,10 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On
); );
} }
get currentAnnotationsPage() {
return this.isDocumine && this.#isIqserDevMode ? ALL_ANNOTATIONS_PAGE : this.pdf.currentPage();
}
@HostListener('click', ['$event']) @HostListener('click', ['$event'])
clickInsideWorkloadView($event: MouseEvent) { clickInsideWorkloadView($event: MouseEvent) {
$event?.stopPropagation(); $event?.stopPropagation();

View File

@ -1,7 +1,7 @@
<div *ngIf="viewedPages$ | async as viewedPages" class="pages" id="pages" [attr.help-mode-key]="'workload_page_list'"> <div *ngIf="viewedPages$ | async as viewedPages" class="pages" id="pages" [attr.help-mode-key]="'workload_page_list'">
<redaction-page-indicator <redaction-page-indicator
(pageSelected)="pageSelectedByClick($event)" (pageSelected)="pageSelectedByClick($event)"
*ngFor="let pageNumber of pages; trackBy: trackBy" *ngFor="let pageNumber of pages(); trackBy: trackBy"
[activeSelection]="pageHasSelection(pageNumber)" [activeSelection]="pageHasSelection(pageNumber)"
[number]="pageNumber" [number]="pageNumber"
[read]="!!getViewedPage(viewedPages, pageNumber)" [read]="!!getViewedPage(viewedPages, pageNumber)"

View File

@ -1,5 +1,5 @@
import { AsyncPipe, NgForOf, NgIf } from '@angular/common'; import { AsyncPipe, NgForOf, NgIf } from '@angular/common';
import { AfterViewInit, Component, inject, Input } from '@angular/core'; import { AfterViewInit, Component, inject, input, Input } from '@angular/core';
import { List } from '@iqser/common-ui/lib/utils'; import { List } from '@iqser/common-ui/lib/utils';
import { ViewedPage } from '@red/domain'; import { ViewedPage } from '@red/domain';
import { ViewedPagesMapService } from '@services/files/viewed-pages-map.service'; import { ViewedPagesMapService } from '@services/files/viewed-pages-map.service';
@ -22,7 +22,7 @@ export class PagesComponent implements AfterViewInit {
readonly #multiSelectService = inject(MultiSelectService); readonly #multiSelectService = inject(MultiSelectService);
readonly #listingService = inject(AnnotationsListingService); readonly #listingService = inject(AnnotationsListingService);
protected readonly _pdf = inject(PdfViewer); protected readonly _pdf = inject(PdfViewer);
@Input({ required: true }) pages: List<number>; readonly pages = input.required<List<number>>();
readonly viewedPages$ = inject(ViewedPagesMapService).get$(this.#state.fileId); readonly viewedPages$ = inject(ViewedPagesMapService).get$(this.#state.fileId);
ngAfterViewInit() { ngAfterViewInit() {

View File

@ -19,6 +19,7 @@ import {
} from '../utils/sort-by-page-rotation.utils'; } from '../utils/sort-by-page-rotation.utils';
import { FileDataService } from './file-data.service'; import { FileDataService } from './file-data.service';
import { FilePreviewStateService } from './file-preview-state.service'; import { FilePreviewStateService } from './file-preview-state.service';
import { ALL_ANNOTATIONS_PAGE } from '../utils/constants';
@Injectable() @Injectable()
export class AnnotationProcessingService { export class AnnotationProcessingService {
@ -167,7 +168,7 @@ export class AnnotationProcessingService {
continue; continue;
} }
const pageNumber = annotation.pageNumber; const pageNumber = this.#devMode && this.#isDocumine ? ALL_ANNOTATIONS_PAGE : annotation.pageNumber;
if (!obj.has(pageNumber)) { if (!obj.has(pageNumber)) {
obj.set(pageNumber, []); obj.set(pageNumber, []);

View File

@ -73,3 +73,5 @@ export const ANNOTATION_ACTIONS = [
'Hide', 'Hide',
'Ausblenden', 'Ausblenden',
] as const; ] as const;
export const ALL_ANNOTATIONS_PAGE = 0;