[ACA-4677] Added download functionality on DownloadPromptDialog (#8467)

* [ACA-4677] Added download functionality on DownloadPromptDialog

* [ACA-4677] Added downloadFile event emitter documentation to ViewerComponent README. Updated reference of NonResponsiveDialog to DownloadPromptDialog

* [ACA-4677] Corrected typo in documentation for downloadFile event

* [ACA-4677] Updated test case to check for method call via actual event handling instead of calling the method manually
This commit is contained in:
swapnil-verma-gl
2023-04-20 13:53:45 +05:30
committed by GitHub
parent 0ebdecbe74
commit 760798338f
6 changed files with 51 additions and 12 deletions

View File

@@ -675,5 +675,15 @@ describe('ViewerComponent', () => {
flush();
discardPeriodicTasks();
}));
it('should emit downloadFileEvent when DownloadPromptDialog return DownloadPromptActions.DOWNLOAD on close', fakeAsync( () => {
dialogOpenSpy.and.returnValue({ afterClosed: () => of(DownloadPromptActions.DOWNLOAD) } as any);
spyOn(component.downloadFile, 'emit');
fixture.detectChanges();
tick(3000);
fixture.detectChanges();
expect(component.downloadFile.emit).toHaveBeenCalled();
}));
});
});

View File

@@ -190,6 +190,12 @@ export class ViewerComponent<T> implements OnDestroy, OnInit, OnChanges {
* */
downloadPromptReminderDelay: number = 15;
/**
* Emitted when user clicks on download button on download prompt dialog.
* */
@Output()
downloadFile: EventEmitter<void> = new EventEmitter<void>();
/** Emitted when user clicks 'Navigate Before' ("<") button. */
@Output()
navigateBefore = new EventEmitter<MouseEvent | KeyboardEvent>();
@@ -388,7 +394,10 @@ export class ViewerComponent<T> implements OnDestroy, OnInit, OnChanges {
this.isDialogVisible = true;
this.dialog.open(DownloadPromptDialogComponent, { disableClose: true }).afterClosed().pipe(first()).subscribe((result: DownloadPromptActions) => {
this.isDialogVisible = false;
if (result === DownloadPromptActions.WAIT) {
if (result === DownloadPromptActions.DOWNLOAD) {
this.downloadFile.emit();
this.onClose();
} else if (result === DownloadPromptActions.WAIT) {
if (this.enableDownloadPromptReminder) {
this.clearDownloadPromptTimeouts();
this.downloadPromptReminderTimer = window.setTimeout(() => {