From fa0ae7e333855e3eca14207cbfc15c6ba9b5283f Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Sat, 11 Feb 2023 23:34:18 +0200 Subject: [PATCH] RED-6144: some refactorings --- .../annotation-card.component.html | 2 +- .../annotation-card.component.ts | 3 +- .../annotation-reference.component.ts | 22 ++++----- .../annotation-references-list.component.html | 3 +- .../annotation-references-list.component.ts | 3 +- ...ion-references-page-indicator.component.ts | 3 +- .../annotation-wrapper.component.html | 11 +++-- .../annotation-wrapper.component.ts | 46 ++++++++++--------- .../annotations-list.component.html | 13 ++---- .../annotations-list.component.ts | 14 +----- .../comments/comments.component.html | 4 +- .../components/comments/comments.component.ts | 26 ++++------- .../document-info/document-info.component.ts | 3 +- .../file-workload.component.html | 1 - .../file-workload/file-workload.component.ts | 26 +++-------- .../highlights-separator.component.ts | 3 +- .../components/pages/pages.component.ts | 4 +- ...ile-preview-right-container.component.html | 18 +------- .../file-preview-right-container.component.ts | 21 +-------- .../user-management.component.html | 14 +++--- .../user-management.component.ts | 9 ++-- .../file-preview-screen.component.ts | 4 +- .../services/file-data.service.ts | 1 - .../services/manual-redaction.service.ts | 11 +++-- .../services/pdf-proxy.service.ts | 12 ++--- 25 files changed, 100 insertions(+), 177 deletions(-) diff --git a/apps/red-ui/src/app/modules/file-preview/components/annotation-card/annotation-card.component.html b/apps/red-ui/src/app/modules/file-preview/components/annotation-card/annotation-card.component.html index c45f95a1f..88a1c413f 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/annotation-card/annotation-card.component.html +++ b/apps/red-ui/src/app/modules/file-preview/components/annotation-card/annotation-card.component.html @@ -1,7 +1,7 @@
diff --git a/apps/red-ui/src/app/modules/file-preview/components/annotation-card/annotation-card.component.ts b/apps/red-ui/src/app/modules/file-preview/components/annotation-card/annotation-card.component.ts index e864ad4ec..d32a7c768 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/annotation-card/annotation-card.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/annotation-card/annotation-card.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; +import { Component, Input } from '@angular/core'; import { AnnotationWrapper } from '@models/file/annotation.wrapper'; import { MultiSelectService } from '../../services/multi-select.service'; import { annotationTypesTranslations } from '@translations/annotation-types-translations'; @@ -8,7 +8,6 @@ import { ROLES } from '@users/roles'; selector: 'redaction-annotation-card', templateUrl: './annotation-card.component.html', styleUrls: ['./annotation-card.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush, }) export class AnnotationCardComponent { readonly roles = ROLES; diff --git a/apps/red-ui/src/app/modules/file-preview/components/annotation-reference/annotation-reference.component.ts b/apps/red-ui/src/app/modules/file-preview/components/annotation-reference/annotation-reference.component.ts index b1296d397..1d0f135b1 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/annotation-reference/annotation-reference.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/annotation-reference/annotation-reference.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, ChangeDetectorRef, Component, HostBinding, Input, OnChanges, OnDestroy } from '@angular/core'; +import { ChangeDetectorRef, Component, HostBinding, Input, OnChanges, OnDestroy } from '@angular/core'; import { AnnotationWrapper } from '@models/file/annotation.wrapper'; import { BehaviorSubject, filter, Subscription } from 'rxjs'; import { switchMap, tap } from 'rxjs/operators'; @@ -7,7 +7,6 @@ import { AnnotationsListingService } from '../../services/annotations-listing.se @Component({ selector: 'redaction-annotation-reference [annotation]', templateUrl: './annotation-reference.component.html', - changeDetection: ChangeDetectionStrategy.OnPush, }) export class AnnotationReferenceComponent implements OnChanges, OnDestroy { @Input() annotation: AnnotationWrapper; @@ -16,16 +15,15 @@ export class AnnotationReferenceComponent implements OnChanges, OnDestroy { readonly #subscription: Subscription; constructor(private readonly _listingService: AnnotationsListingService, private readonly _changeRef: ChangeDetectorRef) { - this.#subscription = this.#annotationChanged$ - .pipe( - filter(annotation => !!annotation), - switchMap(annotation => this._listingService.isSelected$(annotation)), - tap((isSelected: boolean) => { - this.isSelected = isSelected; - this._changeRef.markForCheck(); - }), - ) - .subscribe(); + const annotationsChanged$ = this.#annotationChanged$.pipe( + filter(annotation => !!annotation), + switchMap(annotation => this._listingService.isSelected$(annotation)), + tap((isSelected: boolean) => { + this.isSelected = isSelected; + this._changeRef.markForCheck(); + }), + ); + this.#subscription = annotationsChanged$.subscribe(); } ngOnChanges(): void { diff --git a/apps/red-ui/src/app/modules/file-preview/components/annotation-references-list/annotation-references-list.component.html b/apps/red-ui/src/app/modules/file-preview/components/annotation-references-list/annotation-references-list.component.html index 75c1de2de..ad8059702 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/annotation-references-list/annotation-references-list.component.html +++ b/apps/red-ui/src/app/modules/file-preview/components/annotation-references-list/annotation-references-list.component.html @@ -2,10 +2,11 @@
- {{ 'references' | translate: { count: references.length } }} + {{ 'references' | translate : { count: references.length } }}
+
diff --git a/apps/red-ui/src/app/modules/file-preview/components/annotation-references-list/annotation-references-list.component.ts b/apps/red-ui/src/app/modules/file-preview/components/annotation-references-list/annotation-references-list.component.ts index dabf65b46..08dfaaf16 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/annotation-references-list/annotation-references-list.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/annotation-references-list/annotation-references-list.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, EventEmitter, Output } from '@angular/core'; +import { Component, EventEmitter, Output } from '@angular/core'; import { AnnotationWrapper } from '@models/file/annotation.wrapper'; import { AnnotationReferencesService } from '../../services/annotation-references.service'; import { Observable, switchMap } from 'rxjs'; @@ -9,7 +9,6 @@ import { filter } from 'rxjs/operators'; selector: 'redaction-annotation-references-list', templateUrl: './annotation-references-list.component.html', styleUrls: ['./annotation-references-list.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush, }) export class AnnotationReferencesListComponent { @Output() readonly referenceClicked = new EventEmitter(); diff --git a/apps/red-ui/src/app/modules/file-preview/components/annotation-references-page-indicator/annotation-references-page-indicator.component.ts b/apps/red-ui/src/app/modules/file-preview/components/annotation-references-page-indicator/annotation-references-page-indicator.component.ts index 55edb86bc..4b1ee0e31 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/annotation-references-page-indicator/annotation-references-page-indicator.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/annotation-references-page-indicator/annotation-references-page-indicator.component.ts @@ -1,10 +1,9 @@ -import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; +import { Component, Input } from '@angular/core'; @Component({ selector: 'redaction-annotation-references-page-indicator', templateUrl: './annotation-references-page-indicator.component.html', styleUrls: ['./annotation-references-page-indicator.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush, }) export class AnnotationReferencesPageIndicatorComponent { @Input() number: number; diff --git a/apps/red-ui/src/app/modules/file-preview/components/annotation-wrapper/annotation-wrapper.component.html b/apps/red-ui/src/app/modules/file-preview/components/annotation-wrapper/annotation-wrapper.component.html index f64120c3e..51e8453d4 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/annotation-wrapper/annotation-wrapper.component.html +++ b/apps/red-ui/src/app/modules/file-preview/components/annotation-wrapper/annotation-wrapper.component.html @@ -20,10 +20,13 @@
- +
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 78092c2dc..f6f52c154 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,46 +1,50 @@ -import { ChangeDetectionStrategy, ChangeDetectorRef, Component, HostBinding, Input, OnChanges, TemplateRef } from '@angular/core'; +import { Component, HostBinding, Input, OnChanges } from '@angular/core'; import { BehaviorSubject, Observable } from 'rxjs'; -import { switchMap, tap } from 'rxjs/operators'; +import { distinctUntilChanged, switchMap, tap } from 'rxjs/operators'; import { AnnotationWrapper } from '@models/file/annotation.wrapper'; import { MultiSelectService } from '../../services/multi-select.service'; import { AnnotationsListingService } from '../../services/annotations-listing.service'; +import { PdfProxyService } from '../../services/pdf-proxy.service'; +import { ScrollableParentViews } from '@iqser/common-ui'; +import { ActionsHelpModeKeys } from '../../utils/constants'; @Component({ - selector: 'redaction-annotation-wrapper [annotation] [annotationActionsTemplate]', + selector: 'redaction-annotation-wrapper [annotation]', templateUrl: './annotation-wrapper.component.html', styleUrls: ['./annotation-wrapper.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush, }) export class AnnotationWrapperComponent implements OnChanges { @Input() annotation!: AnnotationWrapper; - @Input() annotationActionsTemplate: TemplateRef; readonly isSelected$!: Observable; @HostBinding('attr.annotation-id') annotationId: string; - @HostBinding('attr.annotation-page') annotationPage: number; - @HostBinding('class.active') active: boolean; - private readonly _annotationChanged$ = new BehaviorSubject(undefined); + @HostBinding('class.active') active = false; + readonly scrollableParentView = ScrollableParentViews.ANNOTATIONS_LIST; + readonly #annotationChanged$ = new BehaviorSubject(undefined); constructor( - private readonly _changeRef: ChangeDetectorRef, readonly listingService: AnnotationsListingService, readonly multiSelectService: MultiSelectService, + readonly pdfProxyService: PdfProxyService, ) { - this.isSelected$ = this._annotationChanged$.pipe( - tap(annotation => { - this.annotationId = annotation.id; - this.annotationPage = annotation.pageNumber; - this._changeRef.markForCheck(); - }), + this.isSelected$ = this.#annotationChanged$.pipe( switchMap(entity => this.listingService.isSelected$(entity)), - tap(isSelected => { - this.active = isSelected; - this._changeRef.markForCheck(); - }), + distinctUntilChanged(), + tap(isSelected => (this.active = isSelected)), ); } - ngOnChanges(): void { - this._annotationChanged$.next(this.annotation); + ngOnChanges() { + this.#annotationChanged$.next(this.annotation); + this.annotationId = this.annotation.id; + } + + getActionsHelpModeKey(annotation: AnnotationWrapper): string { + const type = annotation?.typeLabel?.split('.')[1]; + const typeValue = annotation?.typeValue; + if (type === 'hint' && (typeValue === 'ocr' || typeValue === 'formula' || typeValue === 'image')) { + return ActionsHelpModeKeys[`${type}-${typeValue}`]; + } + return ActionsHelpModeKeys[type]; } } diff --git a/apps/red-ui/src/app/modules/file-preview/components/annotations-list/annotations-list.component.html b/apps/red-ui/src/app/modules/file-preview/components/annotations-list/annotations-list.component.html index 4d28f4d07..7637759e9 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/annotations-list/annotations-list.component.html +++ b/apps/red-ui/src/app/modules/file-preview/components/annotations-list/annotations-list.component.html @@ -3,13 +3,10 @@
- + - - - + 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 84955a2e9..fa66e28c7 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 @@ -1,14 +1,4 @@ -import { - ChangeDetectionStrategy, - ChangeDetectorRef, - Component, - ElementRef, - EventEmitter, - Input, - OnChanges, - Output, - TemplateRef, -} from '@angular/core'; +import { ChangeDetectorRef, Component, ElementRef, EventEmitter, Input, OnChanges, Output } from '@angular/core'; import { AnnotationWrapper } from '@models/file/annotation.wrapper'; import { FilterService, HasScrollbarDirective, IqserEventTarget } from '@iqser/common-ui'; import { MultiSelectService } from '../../services/multi-select.service'; @@ -24,11 +14,9 @@ import { AnnotationsListingService } from '../../services/annotations-listing.se selector: 'redaction-annotations-list', templateUrl: './annotations-list.component.html', styleUrls: ['./annotations-list.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush, }) export class AnnotationsListComponent extends HasScrollbarDirective implements OnChanges { @Input() annotations: AnnotationWrapper[]; - @Input() annotationActionsTemplate: TemplateRef; @Output() readonly pagesPanelActive = new EventEmitter(); diff --git a/apps/red-ui/src/app/modules/file-preview/components/comments/comments.component.html b/apps/red-ui/src/app/modules/file-preview/components/comments/comments.component.html index 37411ebe8..7d566fc69 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/comments/comments.component.html +++ b/apps/red-ui/src/app/modules/file-preview/components/comments/comments.component.html @@ -1,9 +1,9 @@
-
+
{{ comment.user | name }} - {{ comment.date | date: 'sophisticatedDate' }} + {{ comment.date | date : 'sophisticatedDate' }}
diff --git a/apps/red-ui/src/app/modules/file-preview/components/comments/comments.component.ts b/apps/red-ui/src/app/modules/file-preview/components/comments/comments.component.ts index edbeb31c1..22c1e3e67 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/comments/comments.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/comments/comments.component.ts @@ -1,10 +1,9 @@ -import { ChangeDetectionStrategy, ChangeDetectorRef, Component, HostBinding, Input, OnInit, ViewChild } from '@angular/core'; -import { Dossier, File, IComment } from '@red/domain'; +import { ChangeDetectorRef, Component, HostBinding, Input, OnInit, ViewChild } from '@angular/core'; +import type { Dossier, File, IComment, User } from '@red/domain'; import { AnnotationWrapper } from '@models/file/annotation.wrapper'; -import { UserService } from '@users/user.service'; import { PermissionsService } from '@services/permissions.service'; -import { InputWithActionComponent, LoadingService, trackByFactory, ContextComponent } from '@iqser/common-ui'; -import { firstValueFrom, Observable } from 'rxjs'; +import { ContextComponent, getCurrentUser, InputWithActionComponent, LoadingService, trackByFactory } from '@iqser/common-ui'; +import { Observable } from 'rxjs'; import { CommentingService } from '../../services/commenting.service'; import { tap } from 'rxjs/operators'; import { FilePreviewStateService } from '../../services/file-preview-state.service'; @@ -20,20 +19,17 @@ interface CommentsContext { selector: 'redaction-comments', templateUrl: './comments.component.html', styleUrls: ['./comments.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush, }) export class CommentsComponent extends ContextComponent implements OnInit { @Input() annotation: AnnotationWrapper; readonly trackBy = trackByFactory(); - readonly file$: Observable; - readonly dossier$: Observable; + readonly currentUser = getCurrentUser(); hiddenComments$: Observable; @HostBinding('class.hidden') _hidden = true; @ViewChild(InputWithActionComponent) private readonly _input: InputWithActionComponent; constructor( readonly permissionsService: PermissionsService, - private readonly _userService: UserService, private readonly _manualRedactionService: ManualRedactionService, private readonly _commentingService: CommentingService, private readonly _loadingService: LoadingService, @@ -41,8 +37,6 @@ export class CommentsComponent extends ContextComponent impleme private readonly _stateService: FilePreviewStateService, ) { super(); - this.file$ = _stateService.file$; - this.dossier$ = _stateService.dossier$; } ngOnInit() { @@ -53,8 +47,8 @@ export class CommentsComponent extends ContextComponent impleme ); super._initContext({ - file: this.file$, - dossier: this.dossier$, + file: this._stateService.file$, + dossier: this._stateService.dossier$, hiddenComments: this.hiddenComments$, }); } @@ -65,12 +59,12 @@ export class CommentsComponent extends ContextComponent impleme } this._loadingService.start(); const { dossierId, fileId } = this._stateService; - const commentId = await firstValueFrom(this._manualRedactionService.addComment(value, this.annotation.id, dossierId, fileId)); + const commentId = await this._manualRedactionService.addComment(value, this.annotation.id, dossierId, fileId); this.annotation.comments.push({ text: value, id: commentId, annotationId: this.annotation.id, - user: this._userService.currentUser.id, + user: this.currentUser.id, }); this._input.reset(); this._changeRef.markForCheck(); @@ -86,7 +80,7 @@ export class CommentsComponent extends ContextComponent impleme $event.stopPropagation(); this._loadingService.start(); const { dossierId, fileId } = this._stateService; - await firstValueFrom(this._manualRedactionService.deleteComment(comment.id, this.annotation.id, dossierId, fileId)); + await this._manualRedactionService.deleteComment(comment.id, this.annotation.id, dossierId, fileId); this.annotation.comments.splice(this.annotation.comments.indexOf(comment), 1); this._changeRef.markForCheck(); this._loadingService.stop(); diff --git a/apps/red-ui/src/app/modules/file-preview/components/document-info/document-info.component.ts b/apps/red-ui/src/app/modules/file-preview/components/document-info/document-info.component.ts index 7503142bf..3d3039c81 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/document-info/document-info.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/document-info/document-info.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component } from '@angular/core'; +import { Component } from '@angular/core'; import { DossierTemplatesService } from '@services/dossier-templates/dossier-templates.service'; import { DocumentInfoService } from '../../services/document-info.service'; import { combineLatest, Observable, switchMap } from 'rxjs'; @@ -19,7 +19,6 @@ interface FileAttribute { selector: 'redaction-document-info', templateUrl: './document-info.component.html', styleUrls: ['./document-info.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush, }) export class DocumentInfoComponent { readonly fileAttributes$: Observable; diff --git a/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.html b/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.html index 67c5ba8ed..992bf5aa0 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.html +++ b/apps/red-ui/src/app/modules/file-preview/components/file-workload/file-workload.component.html @@ -203,7 +203,6 @@
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 a637a1dad..6e8fba035 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 @@ -1,17 +1,7 @@ -import { - ChangeDetectionStrategy, - ChangeDetectorRef, - Component, - ElementRef, - HostListener, - Input, - OnDestroy, - TemplateRef, - ViewChild, -} from '@angular/core'; +import { ChangeDetectorRef, Component, ElementRef, HostListener, Input, OnDestroy, ViewChild } from '@angular/core'; import { AnnotationWrapper } from '@models/file/annotation.wrapper'; import { AnnotationProcessingService } from '../../services/annotation-processing.service'; -import { MatDialogRef, MatDialogState } from '@angular/material/dialog'; +import { MatDialogState } from '@angular/material/dialog'; import scrollIntoView from 'scroll-into-view-if-needed'; import { AutoUnsubscribe, @@ -25,7 +15,7 @@ import { shareDistinctLast, shareLast, } from '@iqser/common-ui'; -import { combineLatest, firstValueFrom, Observable } from 'rxjs'; +import { combineLatest, delay, Observable } from 'rxjs'; import { map, tap } from 'rxjs/operators'; import { File } from '@red/domain'; import { ExcludedPagesService } from '../../services/excluded-pages.service'; @@ -49,7 +39,6 @@ const ALL_HOTKEY_ARRAY = ['ArrowLeft', 'ArrowRight', 'ArrowUp', 'ArrowDown']; selector: 'redaction-file-workload [file]', templateUrl: './file-workload.component.html', styleUrls: ['./file-workload.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush, }) export class FileWorkloadComponent extends AutoUnsubscribe implements OnDestroy { readonly iconButtonTypes = IconButtonTypes; @@ -57,9 +46,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnDestroy displayedAnnotations = new Map(); @Input() activeViewerPage: number; - @Input() dialogRef: MatDialogRef; @Input() file!: File; - @Input() annotationActionsTemplate: TemplateRef; displayedPages: number[] = []; pagesPanelActive = true; readonly displayedAnnotations$: Observable>; @@ -166,6 +153,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnDestroy const secondary$ = this.filterService.getFilterModels$('secondaryFilters'); return combineLatest([this.fileDataService.all$, primary$, secondary$]).pipe( + delay(0), map(([annotations, primary, secondary]) => this._filterAnnotations(annotations, primary, secondary)), ); } @@ -198,7 +186,7 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnDestroy handleKeyEvent($event: KeyboardEvent): void { if ( !ALL_HOTKEY_ARRAY.includes($event.key) || - this.dialogRef?.getState() === MatDialogState.OPEN || + this.state.dialogRef?.getState() === MatDialogState.OPEN || ($event.target as IqserEventTarget).localName === 'input' ) { return; @@ -273,8 +261,8 @@ export class FileWorkloadComponent extends AutoUnsubscribe implements OnDestroy this.pdf.navigateTo(1); } - scrollQuickNavLast(): Promise { - return firstValueFrom(this.state.file$).then(file => this.pdf.navigateTo(file.numberOfPages)); + scrollQuickNavLast() { + this.pdf.navigateTo(this.state.file.numberOfPages); } preventKeyDefault($event: KeyboardEvent): void { diff --git a/apps/red-ui/src/app/modules/file-preview/components/highlights-separator/highlights-separator.component.ts b/apps/red-ui/src/app/modules/file-preview/components/highlights-separator/highlights-separator.component.ts index 6dcf1bac0..0ace5b714 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/highlights-separator/highlights-separator.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/highlights-separator/highlights-separator.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, Input } from '@angular/core'; +import { Component, Input } from '@angular/core'; import { CircleButtonTypes } from '@iqser/common-ui'; import { EarmarkGroup, EarmarkOperation } from '@red/domain'; import { FilePreviewStateService } from '../../services/file-preview-state.service'; @@ -12,7 +12,6 @@ import { ROLES } from '@users/roles'; selector: 'redaction-highlights-separator [highlightGroup] [annotation]', templateUrl: './highlights-separator.component.html', styleUrls: ['./highlights-separator.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush, }) export class HighlightsSeparatorComponent { @Input() highlightGroup: EarmarkGroup; diff --git a/apps/red-ui/src/app/modules/file-preview/components/pages/pages.component.ts b/apps/red-ui/src/app/modules/file-preview/components/pages/pages.component.ts index fe0c578bf..cc451f6c1 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/pages/pages.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/pages/pages.component.ts @@ -1,4 +1,4 @@ -import { ChangeDetectionStrategy, Component, inject, Input } from '@angular/core'; +import { Component, inject, Input } from '@angular/core'; import { List } from '@iqser/common-ui'; import { PdfViewer } from '../../../pdf-viewer/services/pdf-viewer.service'; import { MultiSelectService } from '../../services/multi-select.service'; @@ -12,13 +12,11 @@ import { ViewedPage } from '@red/domain'; selector: 'redaction-pages [pages] [activePage] [displayedAnnotations]', templateUrl: './pages.component.html', styleUrls: ['./pages.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush, }) export class PagesComponent { @Input() pages: List; @Input() activePage: number; @Input() displayedAnnotations: Map; - readonly #pdf = inject(PdfViewer); readonly #state = inject(FilePreviewStateService); readonly viewedPages$ = inject(ViewedPagesMapService).get$(this.#state.fileId); diff --git a/apps/red-ui/src/app/modules/file-preview/components/right-container/file-preview-right-container.component.html b/apps/red-ui/src/app/modules/file-preview/components/right-container/file-preview-right-container.component.html index a7b7f9135..e003c3081 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/right-container/file-preview-right-container.component.html +++ b/apps/red-ui/src/app/modules/file-preview/components/right-container/file-preview-right-container.component.html @@ -8,21 +8,5 @@ - - - - - + diff --git a/apps/red-ui/src/app/modules/file-preview/components/right-container/file-preview-right-container.component.ts b/apps/red-ui/src/app/modules/file-preview/components/right-container/file-preview-right-container.component.ts index d8da4997e..3be19f097 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/right-container/file-preview-right-container.component.ts +++ b/apps/red-ui/src/app/modules/file-preview/components/right-container/file-preview-right-container.component.ts @@ -1,38 +1,19 @@ -import { ChangeDetectionStrategy, Component } from '@angular/core'; +import { Component } from '@angular/core'; import { DocumentInfoService } from '../../services/document-info.service'; import { ExcludedPagesService } from '../../services/excluded-pages.service'; import { PdfViewer } from '../../../pdf-viewer/services/pdf-viewer.service'; import { FilePreviewStateService } from '../../services/file-preview-state.service'; -import { PdfProxyService } from '../../services/pdf-proxy.service'; -import { AnnotationWrapper } from '@models/file/annotation.wrapper'; -import { ActionsHelpModeKeys } from '../../utils/constants'; -import { ScrollableParentView, ScrollableParentViews } from '@iqser/common-ui'; @Component({ selector: 'redaction-file-preview-right-container', templateUrl: './file-preview-right-container.component.html', styleUrls: ['./file-preview-right-container.component.scss'], - changeDetection: ChangeDetectionStrategy.OnPush, }) export class FilePreviewRightContainerComponent { constructor( readonly pdf: PdfViewer, - readonly pdfProxyService: PdfProxyService, readonly state: FilePreviewStateService, readonly documentInfoService: DocumentInfoService, readonly excludedPagesService: ExcludedPagesService, ) {} - - get scrollableParentView(): ScrollableParentView { - return ScrollableParentViews.ANNOTATIONS_LIST; - } - - getActionsHelpModeKey(annotation: AnnotationWrapper): string { - const type = annotation?.typeLabel?.split('.')[1]; - const typeValue = annotation?.typeValue; - if (type === 'hint' && (typeValue === 'ocr' || typeValue === 'formula' || typeValue === 'image')) { - return ActionsHelpModeKeys[`${type}-${typeValue}`]; - } - return ActionsHelpModeKeys[type]; - } } diff --git a/apps/red-ui/src/app/modules/file-preview/components/user-management/user-management.component.html b/apps/red-ui/src/app/modules/file-preview/components/user-management/user-management.component.html index debe7cbdf..8be9ccc97 100644 --- a/apps/red-ui/src/app/modules/file-preview/components/user-management/user-management.component.html +++ b/apps/red-ui/src/app/modules/file-preview/components/user-management/user-management.component.html @@ -7,7 +7,7 @@
-
+
; readonly canAssignReviewer$: Observable; readonly canAssignToSelf$: Observable; - readonly editingReviewer$ = new BehaviorSubject(false); + editingReviewer = false; readonly canAssignOrUnassign$: Observable; readonly canAssign$: Observable; readonly usersOptions$: Observable; @@ -113,6 +112,6 @@ export class UserManagementComponent { this.loadingService.stop(); this.toaster.success(_('assignment.reviewer'), { params: { reviewerName, filename } }); - this.editingReviewer$.next(false); + this.editingReviewer = false; } } 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 89bd74b12..8e2644b5d 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 @@ -1,6 +1,5 @@ import { AfterViewInit, - ChangeDetectionStrategy, ChangeDetectorRef, Component, ElementRef, @@ -78,7 +77,6 @@ const textActions = [TextPopups.ADD_DICTIONARY, TextPopups.ADD_FALSE_POSITIVE]; templateUrl: './file-preview-screen.component.html', styleUrls: ['./file-preview-screen.component.scss'], providers: filePreviewScreenProviders, - changeDetection: ChangeDetectionStrategy.OnPush, }) export class FilePreviewScreenComponent extends AutoUnsubscribe @@ -300,7 +298,7 @@ export class FilePreviewScreenComponent await firstValueFrom(reanalyzeFiles); } - this.pdfProxyService.loadViewer(); + this.pdfProxyService.configureElements(); } ngAfterViewInit() { diff --git a/apps/red-ui/src/app/modules/file-preview/services/file-data.service.ts b/apps/red-ui/src/app/modules/file-preview/services/file-data.service.ts index 0841d0ba5..42d695c72 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/file-data.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/file-data.service.ts @@ -5,7 +5,6 @@ import { IRedactionLog, IRedactionLogEntry, LogEntryStatuses, - ManualRedactionType, ViewedPage, ViewMode, ViewModes, diff --git a/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts b/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts index 9433ff52f..879e5a07e 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/manual-redaction.service.ts @@ -12,7 +12,7 @@ import type { } from '@red/domain'; import { type AnnotationWrapper } from '@models/file/annotation.wrapper'; import { GenericService, IqserPermissionsService, List, RequiredParam, Toaster, Validate } from '@iqser/common-ui'; -import { map, tap } from 'rxjs/operators'; +import { tap } from 'rxjs/operators'; import { PermissionsService } from '@services/permissions.service'; import { dictionaryActionsTranslations, manualRedactionActionsTranslations } from '@translations/annotation-actions-translations'; import { marker as _ } from '@biesbjerg/ngx-translate-extract-marker'; @@ -21,7 +21,7 @@ import { ActiveDossiersService } from '@services/dossiers/active-dossiers.servic import { type ManualRedactionEntryType } from '@models/file/manual-redaction-entry.wrapper'; import { NGXLogger } from 'ngx-logger'; import { ROLES } from '@users/roles'; -import { of } from 'rxjs'; +import { firstValueFrom, of } from 'rxjs'; function getResponseType(error: boolean, isConflict: boolean) { const isConflictError = isConflict ? 'conflictError' : 'error'; @@ -54,15 +54,16 @@ export class ManualRedactionService extends GenericService { } @Validate() - addComment(@RequiredParam() comment: string, @RequiredParam() annotationId: string, dossierId: string, fileId: string) { + async addComment(@RequiredParam() comment: string, @RequiredParam() annotationId: string, dossierId: string, fileId: string) { const url = `${this._defaultModelPath}/comment/add/${dossierId}/${fileId}/${annotationId}`; - return this._post<{ commentId: string }>({ text: comment }, url).pipe(map(res => res.commentId)); + const request = await firstValueFrom(this._post<{ commentId: string }>({ text: comment }, url)); + return request.commentId; } @Validate() deleteComment(@RequiredParam() commentId: string, @RequiredParam() annotationId: string, dossierId: string, fileId: string) { const url = `${this._defaultModelPath}/comment/undo/${dossierId}/${fileId}/${annotationId}/${commentId}`; - return super.delete({}, url); + return firstValueFrom(super.delete({}, url)); } addRecommendation(annotations: AnnotationWrapper[], dossierId: string, fileId: string, comment = { text: 'Accepted Recommendation' }) { diff --git a/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts b/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts index f3b47a5bb..8592c8b3d 100644 --- a/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts +++ b/apps/red-ui/src/app/modules/file-preview/services/pdf-proxy.service.ts @@ -112,8 +112,10 @@ export class PdfProxyService { this._changeDetectorRef.markForCheck(); } - loadViewer() { - this._configureElements(); + configureElements() { + const hexColor = this._dictionariesMapService.get(this._state.dossierTemplateId, 'manual').hexColor; + const color = this._annotationDrawService.convertColor(hexColor); + this._documentViewer.setRectangleToolStyles(color); } #deactivateMultiSelect() { @@ -185,12 +187,6 @@ export class PdfProxyService { this._annotationsActionsService.cancelResize(null, wrapper).then(); } - private _configureElements() { - const hexColor = this._dictionariesMapService.get(this._state.dossierTemplateId, 'manual').hexColor; - const color = this._annotationDrawService.convertColor(hexColor); - this._documentViewer.setRectangleToolStyles(color); - } - #configureAnnotationSpecificActions(viewerAnnotations: Annotation[]) { if (!this.canPerformActions) { return this._pdf.resetAnnotationActions();