diff options
Diffstat (limited to 'client/src/app/videos/+video-edit/video-add.component.ts')
-rw-r--r-- | client/src/app/videos/+video-edit/video-add.component.ts | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/client/src/app/videos/+video-edit/video-add.component.ts b/client/src/app/videos/+video-edit/video-add.component.ts index 57a9d0ca7..01fdfcb66 100644 --- a/client/src/app/videos/+video-edit/video-add.component.ts +++ b/client/src/app/videos/+video-edit/video-add.component.ts | |||
@@ -1,4 +1,4 @@ | |||
1 | import { Component, ViewChild } from '@angular/core' | 1 | import { Component, HostListener, ViewChild } from '@angular/core' |
2 | import { CanComponentDeactivate } from '@app/shared/guards/can-deactivate-guard.service' | 2 | import { CanComponentDeactivate } from '@app/shared/guards/can-deactivate-guard.service' |
3 | import { VideoImportUrlComponent } from '@app/videos/+video-edit/video-add-components/video-import-url.component' | 3 | import { VideoImportUrlComponent } from '@app/videos/+video-edit/video-add-components/video-import-url.component' |
4 | import { VideoUploadComponent } from '@app/videos/+video-edit/video-add-components/video-upload.component' | 4 | import { VideoUploadComponent } from '@app/videos/+video-edit/video-add-components/video-upload.component' |
@@ -32,7 +32,17 @@ export class VideoAddComponent implements CanComponentDeactivate { | |||
32 | this.secondStepType = undefined | 32 | this.secondStepType = undefined |
33 | } | 33 | } |
34 | 34 | ||
35 | canDeactivate () { | 35 | @HostListener('window:beforeunload', [ '$event' ]) |
36 | onUnload (event: any) { | ||
37 | const { text, canDeactivate } = this.canDeactivate() | ||
38 | |||
39 | if (canDeactivate) return | ||
40 | |||
41 | event.returnValue = text | ||
42 | return text | ||
43 | } | ||
44 | |||
45 | canDeactivate (): { canDeactivate: boolean, text?: string} { | ||
36 | if (this.secondStepType === 'upload') return this.videoUpload.canDeactivate() | 46 | if (this.secondStepType === 'upload') return this.videoUpload.canDeactivate() |
37 | if (this.secondStepType === 'import-url') return this.videoImportUrl.canDeactivate() | 47 | if (this.secondStepType === 'import-url') return this.videoImportUrl.canDeactivate() |
38 | if (this.secondStepType === 'import-torrent') return this.videoImportTorrent.canDeactivate() | 48 | if (this.secondStepType === 'import-torrent') return this.videoImportTorrent.canDeactivate() |