From b37b7251576499e6749c92cc13fdcc4ece0960ff Mon Sep 17 00:00:00 2001 From: Minh Tho DUONG Date: Thu, 4 Apr 2024 16:08:21 +1100 Subject: [PATCH] refactor: migrate the comments-modal - update functions in TypeScript files --- src/app/common/file-downloader/file-downloader.service.ts | 2 ++ .../pdf-image-comment/pdf-image-comment.component.ts | 6 ++++-- .../task-comments-viewer/task-comments-viewer.component.ts | 4 ++-- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/app/common/file-downloader/file-downloader.service.ts b/src/app/common/file-downloader/file-downloader.service.ts index ba49cd64d..f37330e4a 100644 --- a/src/app/common/file-downloader/file-downloader.service.ts +++ b/src/app/common/file-downloader/file-downloader.service.ts @@ -51,6 +51,8 @@ export class FileDownloaderService { downloadLink.click(); downloadLink.parentNode.removeChild(downloadLink); + + this.alerts.add('info', 'File downloaded.', 3000); }, (error: any) => { this.alerts.add('danger', `Error downloading file - ${error}`); diff --git a/src/app/tasks/task-comments-viewer/pdf-image-comment/pdf-image-comment.component.ts b/src/app/tasks/task-comments-viewer/pdf-image-comment/pdf-image-comment.component.ts index cc3817cf6..35c7a3e8e 100644 --- a/src/app/tasks/task-comments-viewer/pdf-image-comment/pdf-image-comment.component.ts +++ b/src/app/tasks/task-comments-viewer/pdf-image-comment/pdf-image-comment.component.ts @@ -46,10 +46,12 @@ export class PdfImageCommentComponent implements OnInit, OnDestroy { } public openCommentsModal() { - if (this.resourceUrl) { + if (this.comment.commentType == 'image') { this.commentsModalRef.show(this.resourceUrl, this.comment.commentType); } else { - this.downloadCommentResource(this.openCommentsModal.bind(this)); + if (this.comment.commentType === 'pdf') { + this.fileDownloaderService.downloadFile(this.comment.attachmentUrl, "view.pdf"); + } } } } diff --git a/src/app/tasks/task-comments-viewer/task-comments-viewer.component.ts b/src/app/tasks/task-comments-viewer/task-comments-viewer.component.ts index 3aa677152..3aa72a774 100644 --- a/src/app/tasks/task-comments-viewer/task-comments-viewer.component.ts +++ b/src/app/tasks/task-comments-viewer/task-comments-viewer.component.ts @@ -143,10 +143,10 @@ export class TaskCommentsViewerComponent implements OnChanges, OnInit { document.querySelector(`#comment-${commentID}`).scrollIntoView(); } - openCommentsModal(comment: TaskComment) { + /*openCommentsModal(comment: TaskComment) { const resourceUrl = comment.attachmentUrl; this.commentsModalRef.show(resourceUrl, comment.commentType); - } + }*/ shouldShowAuthorIcon(commentType: string) { return !(commentType === 'extension' || commentType === 'status' || commentType == 'assessment');