mirror of
https://github.com/Alfresco/alfresco-ng2-components.git
synced 2025-07-24 17:32:15 +00:00
[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:
@@ -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();
|
||||
}));
|
||||
});
|
||||
});
|
||||
|
@@ -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(() => {
|
||||
|
Reference in New Issue
Block a user