From 6affd59ca98d7e1c01ebf6ad5d1d32829b9d1a2c Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Fri, 15 Sep 2023 18:06:42 +0300 Subject: [PATCH 1/2] DM-473 no line breaks or hyphens removal needed --- .../manual-annotation-dialog.component.ts | 2 -- .../modules/file-preview/file-preview-screen.component.ts | 3 +-- apps/red-ui/src/app/utils/functions.ts | 8 -------- 3 files changed, 1 insertion(+), 12 deletions(-) diff --git a/apps/red-ui/src/app/modules/file-preview/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts b/apps/red-ui/src/app/modules/file-preview/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts index 53595cb9b..829047265 100644 --- a/apps/red-ui/src/app/modules/file-preview/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/dialogs/manual-redaction-dialog/manual-annotation-dialog.component.ts @@ -9,7 +9,6 @@ import { ActiveDossiersService } from '@services/dossiers/active-dossiers.servic import { DictionaryService } from '@services/entity-services/dictionary.service'; import { JustificationsService } from '@services/entity-services/justifications.service'; import { Roles } from '@users/roles'; -import { removeHyphensAndSpecialChars } from '@utils/functions'; import { firstValueFrom } from 'rxjs'; import { ManualRedactionService } from '../../services/manual-redaction.service'; @@ -186,7 +185,6 @@ export class ManualAnnotationDialogComponent extends BaseDialogComponent impleme addRedactionRequest.value = addRedactionRequest.rectangle ? this.form.get('classification').value : this.form.get('selectedText').value; - addRedactionRequest.value = removeHyphensAndSpecialChars(addRedactionRequest.value); } #selectReason() { diff --git a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts index 27edbab0c..cf56904e0 100644 --- a/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/file-preview-screen.component.ts @@ -52,7 +52,7 @@ import JSZip from 'jszip'; import { NGXLogger } from 'ngx-logger'; import { combineLatest, first, firstValueFrom, of, pairwise } from 'rxjs'; import { catchError, filter, map, startWith, switchMap, tap } from 'rxjs/operators'; -import { byId, byPage, download, handleFilterDelta, hasChanges, removeHyphensAndSpecialChars } from '../../utils'; +import { byId, byPage, download, handleFilterDelta, hasChanges } from '../../utils'; import { AnnotationDrawService } from '../pdf-viewer/services/annotation-draw.service'; import { REDAnnotationManager } from '../pdf-viewer/services/annotation-manager.service'; import { REDDocumentViewer } from '../pdf-viewer/services/document-viewer.service'; @@ -533,7 +533,6 @@ export class FilePreviewScreenComponent } const hint = manualRedactionEntryWrapper.type === ManualRedactionEntryTypes.HINT; - result.redaction.value = removeHyphensAndSpecialChars(result.redaction.value); const add$ = this._manualRedactionService.addAnnotation([result.redaction], this.dossierId, this.fileId, { hint, dictionaryLabel: result.dictionary?.label, diff --git a/apps/red-ui/src/app/utils/functions.ts b/apps/red-ui/src/app/utils/functions.ts index df12eb1d3..06fd984ca 100644 --- a/apps/red-ui/src/app/utils/functions.ts +++ b/apps/red-ui/src/app/utils/functions.ts @@ -133,11 +133,3 @@ export function calcTextWidthInPixels(text: string): number { return width; } - -export function removeHyphensAndSpecialChars(text: string): string { - return text?.replace( - // eslint-disable-next-line no-control-regex,max-len - /([^\s\d-]{2,})[-\u00AD]\u000A\u000D|[\u000A\u000B\u000C\u000D\u0085\u2028\u2029]/gi, - '$1', - ); -} From ae2797f2b8fb09dd18462aec39887b687a66affc Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Fri, 15 Sep 2023 19:10:03 +0300 Subject: [PATCH 2/2] RED-7612 fix annotations selected when opened file --- .../annotation-wrapper.component.ts | 15 +++--- .../annotations-list.component.ts | 2 +- .../file-workload/file-workload.component.ts | 46 +++++++++---------- .../services/annotation-manager.service.ts | 1 - libs/common-ui | 2 +- 5 files changed, 32 insertions(+), 34 deletions(-) diff --git a/apps/red-ui/src/app/modules/file-preview/components/annotation-wrapper/annotation-wrapper.component.ts b/apps/red-ui/src/app/modules/file-preview/components/annotation-wrapper/annotation-wrapper.component.ts index 5ec1cb170..ce271befd 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/annotation-wrapper/annotation-wrapper.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/annotation-wrapper/annotation-wrapper.component.ts @@ -1,10 +1,10 @@ import { Component, HostBinding, inject, Input, OnChanges } from '@angular/core'; +import { getConfig } from '@iqser/common-ui'; import { AnnotationWrapper } from '@models/file/annotation.wrapper'; -import { PdfProxyService } from '../../services/pdf-proxy.service'; -import { ActionsHelpModeKeys } from '../../utils/constants'; import { ListItem } from '@models/file/list-item'; import { MultiSelectService } from '../../services/multi-select.service'; -import { getConfig } from '@iqser/common-ui'; +import { PdfProxyService } from '../../services/pdf-proxy.service'; +import { ActionsHelpModeKeys } from '../../utils/constants'; @Component({ selector: 'redaction-annotation-wrapper', @@ -12,14 +12,13 @@ import { getConfig } from '@iqser/common-ui'; styleUrls: ['./annotation-wrapper.component.scss'], }) export class AnnotationWrapperComponent implements OnChanges { - @Input({ required: true }) annotation!: ListItem; - - @HostBinding('attr.annotation-id') annotationId: string; - @HostBinding('class.active') active = false; - actionsHelpModeKey?: string; readonly #isDocumine = getConfig().IS_DOCUMINE; protected readonly _pdfProxyService = inject(PdfProxyService); protected readonly _multiSelectService = inject(MultiSelectService); + @Input({ required: true }) annotation!: ListItem; + @HostBinding('attr.annotation-id') annotationId: string; + @HostBinding('class.active') active = false; + actionsHelpModeKey?: string; ngOnChanges() { this.annotationId = this.annotation.item.id; diff --git a/apps/red-ui/src/app/modules/file-preview/components/annotations-list/annotations-list.component.ts b/apps/red-ui/src/app/modules/file-preview/components/annotations-list/annotations-list.component.ts index 2abe4b8fe..1c53f1b14 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/annotations-list/annotations-list.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/annotations-list/annotations-list.component.ts @@ -24,7 +24,7 @@ export class AnnotationsListComponent extends HasScrollbarDirective implements O } return [] as EarmarkGroup[]; }); - @Input() annotations: ListItem[]; + @Input({ required: true }) annotations: ListItem[]; @Output() readonly pagesPanelActive = new EventEmitter(); constructor( diff --git a/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts b/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts index 78dcd0814..8a2de4483 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.ts @@ -37,7 +37,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On @ViewChild('annotationsElement') private readonly _annotationsElement: ElementRef; @ViewChild('quickNavigation') private readonly _quickNavigationElement: ElementRef; readonly #isDocumine = getConfig().IS_DOCUMINE; - readonly #devMode = this._userPreferenceService.isIqserDevMode; + readonly #isIqserDevMode = this._userPreferenceService.isIqserDevMode; readonly iconButtonTypes = IconButtonTypes; readonly circleButtonTypes = CircleButtonTypes; displayedAnnotations = new Map(); @@ -96,14 +96,14 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On }); effect(() => { - const __ = this.viewModeService.viewMode(); + this.viewModeService.viewMode(); this._scrollViews(); }); effect( () => { if (this.excludedPagesService.shown()) { - this._disableMultiSelectAndDocumentInfo(); + this.#disableMultiSelectAndDocumentInfo(); } }, { allowSignalWrites: true }, @@ -130,8 +130,8 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On this._pageRotationService.rotations$, ]).pipe( delay(0), - map(([annotations, primary, secondary]) => this._filterAnnotations(annotations, primary, secondary)), - map(annotations => this._mapListItemsFromAnnotationWrapperArray(annotations)), + map(([annotations, primary, secondary]) => this.#filterAnnotations(annotations, primary, secondary)), + map(annotations => this.#mapListItemsFromAnnotationWrapperArray(annotations)), ); } @@ -196,7 +196,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On // selected annotation on this page and not in multi select mode if (!this.pagesPanelActive && this.multiSelectService.inactive()) { this._documentViewer.clearSelection(); - this._selectFirstAnnotationOnCurrentPageIfNecessary(); + this.#selectFirstAnnotationOnCurrentPageIfNecessary(); } this._changeDetectorRef.markForCheck(); return; @@ -209,7 +209,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On this.navigateAnnotations($event); } } else { - this._navigatePages($event); + this.#navigatePages($event); } this._changeDetectorRef.markForCheck(); @@ -247,7 +247,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On if (quickNavPageIndex === -1 || this.displayedPages[quickNavPageIndex] !== currentPage) { quickNavPageIndex = Math.max(0, quickNavPageIndex - 1); } - this._scrollQuickNavigationToPage(this.displayedPages[quickNavPageIndex]); + this.#scrollQuickNavigationToPage(this.displayedPages[quickNavPageIndex]); } scrollQuickNavFirst(): void { @@ -265,11 +265,11 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On } jumpToPreviousWithAnnotations(): void { - this.pdf.navigateTo(this._prevPageWithAnnotations()); + this.pdf.navigateTo(this.#prevPageWithAnnotations()); } jumpToNextWithAnnotations(): void { - this.pdf.navigateTo(this._nextPageWithAnnotations()); + this.pdf.navigateTo(this.#nextPageWithAnnotations()); } navigateAnnotations($event: KeyboardEvent) { @@ -281,12 +281,12 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On } // Displayed page doesn't have annotations if ($event.key === 'ArrowDown') { - const nextPage = this._nextPageWithAnnotations(); + const nextPage = this.#nextPageWithAnnotations(); return this.listingService.selectAnnotations(this.displayedAnnotations.get(nextPage)[0]); } - const prevPage = this._prevPageWithAnnotations(); + const prevPage = this.#prevPageWithAnnotations(); const prevPageAnnotations = this.displayedAnnotations.get(prevPage); return this.listingService.selectAnnotations(prevPageAnnotations[prevPageAnnotations.length - 1]); @@ -339,12 +339,12 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On this.scrollAnnotations(); } - private _disableMultiSelectAndDocumentInfo(): void { + #disableMultiSelectAndDocumentInfo(): void { this.multiSelectService.deactivate(); this.documentInfoService.hide(); } - private _filterAnnotations( + #filterAnnotations( annotations: AnnotationWrapper[], primary: INestedFilter[], secondary: INestedFilter[] = [], @@ -359,7 +359,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On annotations = annotations.filter(a => !bool(a.isChangeLogRemoved)); } - if (this.#isDocumine && !this.#devMode) { + if (this.#isDocumine && !this.#isIqserDevMode) { annotations = annotations.filter(a => !a.isOCR); } @@ -383,7 +383,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On return this.displayedAnnotations; } - private _selectFirstAnnotationOnCurrentPageIfNecessary() { + #selectFirstAnnotationOnCurrentPageIfNecessary() { const currentPage = this.pdf.currentPage(); if ( (!this._firstSelectedAnnotation || currentPage !== this._firstSelectedAnnotation.pageNumber) && @@ -394,13 +394,13 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On } } - private _navigatePages($event: KeyboardEvent) { + #navigatePages($event: KeyboardEvent) { const pageIdx = this.displayedPages.indexOf(this.pdf.currentPage()); if ($event.key !== 'ArrowDown') { if (pageIdx === -1) { // If active page doesn't have annotations - const prevPage = this._prevPageWithAnnotations(); + const prevPage = this.#prevPageWithAnnotations(); if (prevPage) { this.pdf.navigateTo(prevPage); } @@ -414,7 +414,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On } if (pageIdx === -1) { // If active page doesn't have annotations - const nextPage = this._nextPageWithAnnotations(); + const nextPage = this.#nextPageWithAnnotations(); if (nextPage) { this.pdf.navigateTo(nextPage); } @@ -426,7 +426,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On } } - private _nextPageWithAnnotations() { + #nextPageWithAnnotations() { let idx = 0; for (const page of this.displayedPages) { if (page > this.pdf.currentPage() && this.displayedAnnotations.get(page)) { @@ -437,7 +437,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On return idx < this.displayedPages.length ? this.displayedPages[idx] : this.displayedPages[this.displayedPages.length - 1]; } - private _prevPageWithAnnotations() { + #prevPageWithAnnotations() { let idx = this.displayedPages.length - 1; const reverseDisplayedPages = [...this.displayedPages].reverse(); for (const page of reverseDisplayedPages) { @@ -449,14 +449,14 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnInit, On return idx >= 0 ? this.displayedPages[idx] : this.displayedPages[0]; } - private _scrollQuickNavigationToPage(page: number) { + #scrollQuickNavigationToPage(page: number) { if (this._quickNavigationElement) { const elements: HTMLElement[] = this._quickNavigationElement.nativeElement.querySelectorAll(`#quick-nav-page-${page}`); FileWorkloadComponent._scrollToFirstElement(elements); } } - private _mapListItemsFromAnnotationWrapperArray(annotations: Map) { + #mapListItemsFromAnnotationWrapperArray(annotations: Map) { const listItemsMap = new Map[]>(); if (!annotations) { return listItemsMap; diff --git a/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-manager.service.ts b/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-manager.service.ts index 8aa406601..e19af623a 100644 --- a/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-manager.service.ts +++ b/apps/red-ui/src/app/modules/pdf-viewer/services/annotation-manager.service.ts @@ -154,7 +154,6 @@ export class REDAnnotationManager { this.#manager.selectAnnotation(annotation); annotation.disableRotationControl(); } - this.#annotationSelected$.next([annotations, action]); }); } diff --git a/libs/common-ui b/libs/common-ui index a4132b82f..6cb63fcf4 160000 --- a/libs/common-ui +++ b/libs/common-ui @@ -1 +1 @@ -Subproject commit a4132b82f52e92025f2348fb83587680790ca3a8 +Subproject commit 6cb63fcf43fbbf522b847f57467156808bbe72a1