From 8c2d75e873c359f07b68009dd59a069d06b9510b Mon Sep 17 00:00:00 2001 From: Dan Percic Date: Wed, 9 Feb 2022 16:21:18 +0200 Subject: [PATCH] fix removed annotation click --- .../annotations-list.component.scss | 1 - .../annotations-list.component.ts | 4 ---- .../components/comments/comments.component.ts | 20 +++++++------------ .../entity-services/files-map.service.ts | 5 ++--- 4 files changed, 9 insertions(+), 21 deletions(-) diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotations-list/annotations-list.component.scss b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotations-list/annotations-list.component.scss index 671a083fd..047e483e4 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotations-list/annotations-list.component.scss +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotations-list/annotations-list.component.scss @@ -34,7 +34,6 @@ &.removed { text-decoration: line-through; color: variables.$grey-7; - cursor: default; } .actions-wrapper { diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotations-list/annotations-list.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotations-list/annotations-list.component.ts index 3cda27f73..062d28b62 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotations-list/annotations-list.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/annotations-list/annotations-list.component.ts @@ -41,10 +41,6 @@ export class AnnotationsListComponent implements OnChanges { return; } - if (annotation.isChangeLogRemoved) { - return; - } - this.pagesPanelActive.emit(false); if (this.isSelected(annotation.annotationId)) { diff --git a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/comments/comments.component.ts b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/comments/comments.component.ts index 6a6895765..c61620499 100644 --- a/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/comments/comments.component.ts +++ b/apps/red-ui/src/app/modules/dossier/screens/file-preview-screen/components/comments/comments.component.ts @@ -5,11 +5,10 @@ import { AnnotationWrapper } from '@models/file/annotation.wrapper'; import { UserService } from '@services/user.service'; import { PermissionsService } from '@services/permissions.service'; import { AutoUnsubscribe, InputWithActionComponent, LoadingService, trackByFactory } from '@iqser/common-ui'; -import { FilesMapService } from '@services/entity-services/files-map.service'; -import { ActivatedRoute } from '@angular/router'; import { firstValueFrom, Observable } from 'rxjs'; import { CommentingService } from '../../services/commenting.service'; import { tap } from 'rxjs/operators'; +import { FilePreviewStateService } from '../../services/file-preview-state.service'; @Component({ selector: 'redaction-comments', @@ -23,8 +22,6 @@ export class CommentsComponent extends AutoUnsubscribe implements OnChanges { readonly file$: Observable; @HostBinding('class.hidden') _hidden = true; @ViewChild(InputWithActionComponent) private readonly _input: InputWithActionComponent; - private readonly _fileId: string; - private readonly _dossierId: string; constructor( readonly permissionsService: PermissionsService, @@ -33,13 +30,10 @@ export class CommentsComponent extends AutoUnsubscribe implements OnChanges { private readonly _commentingService: CommentingService, private readonly _loadingService: LoadingService, private readonly _changeRef: ChangeDetectorRef, - readonly filesMapService: FilesMapService, - activatedRoute: ActivatedRoute, + private readonly _stateService: FilePreviewStateService, ) { super(); - this._fileId = activatedRoute.snapshot.paramMap.get('fileId'); - this._dossierId = activatedRoute.snapshot.paramMap.get('dossierId'); - this.file$ = filesMapService.watch$(this._dossierId, this._fileId); + this.file$ = _stateService.file$; } ngOnChanges() { @@ -58,9 +52,8 @@ export class CommentsComponent extends AutoUnsubscribe implements OnChanges { return; } this._loadingService.start(); - const commentId = await firstValueFrom( - this._manualAnnotationService.addComment(value, this.annotation.id, this._dossierId, this._fileId), - ); + const { dossierId, fileId } = this._stateService; + const commentId = await firstValueFrom(this._manualAnnotationService.addComment(value, this.annotation.id, dossierId, fileId)); this.annotation.comments.push({ text: value, id: commentId, @@ -80,7 +73,8 @@ export class CommentsComponent extends AutoUnsubscribe implements OnChanges { async deleteComment($event: MouseEvent, comment: IComment): Promise { $event.stopPropagation(); this._loadingService.start(); - await firstValueFrom(this._manualAnnotationService.deleteComment(comment.id, this.annotation.id, this._dossierId, this._fileId)); + const { dossierId, fileId } = this._stateService; + await firstValueFrom(this._manualAnnotationService.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/services/entity-services/files-map.service.ts b/apps/red-ui/src/app/services/entity-services/files-map.service.ts index 372fadc42..4dbc1875a 100644 --- a/apps/red-ui/src/app/services/entity-services/files-map.service.ts +++ b/apps/red-ui/src/app/services/entity-services/files-map.service.ts @@ -56,7 +56,6 @@ export class FilesMapService { this._map.get(key).next(newEntities); // Emit observables only after entities have been updated - for (const file of changedEntities) { this._entityChanged$.next(file); } @@ -69,9 +68,9 @@ export class FilesMapService { replace(entities: File[]) { const dossierId = entities[0].dossierId; const entityIds = entities.map(entity => entity.id); - let existingFiles = this.get(dossierId).filter(file => entityIds.includes(file.fileId)); + const existingFiles = this.get(dossierId).filter(file => entityIds.includes(file.fileId)); entities = entities.filter(entity => { - const existingFile = existingFiles.find(existingFile => existingFile.id === entity.id); + const existingFile = existingFiles.find(file => file.id === entity.id); return existingFile.lastUpdated !== entity.lastUpdated; }); if (entities.length) {