From 772d5642ba617865519ca5e590061adf174866d4 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 25 Jul 2018 10:28:43 +0200 Subject: Improve captions UX (at least I've tried) --- .../src/app/videos/+video-edit/video-update.component.ts | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'client/src/app/videos/+video-edit/video-update.component.ts') diff --git a/client/src/app/videos/+video-edit/video-update.component.ts b/client/src/app/videos/+video-edit/video-update.component.ts index 952fe0293..798c48f3c 100644 --- a/client/src/app/videos/+video-edit/video-update.component.ts +++ b/client/src/app/videos/+video-edit/video-update.component.ts @@ -29,6 +29,8 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { schedulePublicationPossible = false videoCaptions: VideoCaptionEdit[] = [] + private updateDone = false + constructor ( protected formValidatorService: FormValidatorService, private route: ActivatedRoute, @@ -65,7 +67,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { this.schedulePublicationPossible = this.video.privacy === VideoPrivacy.PRIVATE } - // FIXME: Angular does not detec + // FIXME: Angular does not detect the change inside this subscription, so use the patched setTimeout setTimeout(() => this.hydrateFormFromVideo()) }, @@ -76,6 +78,16 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { ) } + canDeactivate () { + if (this.updateDone === true) return { canDeactivate: true } + + for (const caption of this.videoCaptions) { + if (caption.action) return { canDeactivate: false } + } + + return { canDeactivate: this.formChanged === false } + } + checkForm () { this.forceCheck() @@ -100,6 +112,7 @@ export class VideoUpdateComponent extends FormReactive implements OnInit { ) .subscribe( () => { + this.updateDone = true this.isUpdatingVideo = false this.loadingBar.complete() this.notificationsService.success(this.i18n('Success'), this.i18n('Video updated.')) -- cgit v1.2.3