X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=client%2Fsrc%2Fapp%2Fvideos%2F%2Bvideo-edit%2Fshared%2Fvideo-caption-add-modal.component.ts;h=86c6e03e75be6f16856ebdba28d659ae9f4e18a8;hb=f36da21e40104a50acb00132920b835240cebb38;hp=d084a490830a5dd50a494e148e204e54298634ea;hpb=337ba64efc5a54e83884f33a91de4012ed9b7d11;p=github%2FChocobozzz%2FPeerTube.git diff --git a/client/src/app/videos/+video-edit/shared/video-caption-add-modal.component.ts b/client/src/app/videos/+video-edit/shared/video-caption-add-modal.component.ts index d084a4908..86c6e03e7 100644 --- a/client/src/app/videos/+video-edit/shared/video-caption-add-modal.component.ts +++ b/client/src/app/videos/+video-edit/shared/video-caption-add-modal.component.ts @@ -1,10 +1,11 @@ -import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' -import { ModalDirective } from 'ngx-bootstrap/modal' +import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core' import { FormReactive } from '@app/shared' import { FormValidatorService } from '@app/shared/forms/form-validators/form-validator.service' import { VideoCaptionsValidatorsService } from '@app/shared/forms/form-validators/video-captions-validators.service' import { ServerService } from '@app/core' import { VideoCaptionEdit } from '@app/shared/video-caption/video-caption-edit.model' +import { NgbModal, NgbModalRef } from '@ng-bootstrap/ng-bootstrap' +import { VideoConstant } from '../../../../../../shared' @Component({ selector: 'my-video-caption-add-modal', @@ -17,14 +18,16 @@ export class VideoCaptionAddModalComponent extends FormReactive implements OnIni @Output() captionAdded = new EventEmitter() - @ViewChild('modal') modal: ModalDirective + @ViewChild('modal', { static: true }) modal: ElementRef - videoCaptionLanguages = [] + videoCaptionLanguages: VideoConstant[] = [] + private openedModal: NgbModalRef private closingModal = false constructor ( protected formValidatorService: FormValidatorService, + private modalService: NgbModal, private serverService: ServerService, private videoCaptionsValidatorsService: VideoCaptionsValidatorsService ) { @@ -51,13 +54,13 @@ export class VideoCaptionAddModalComponent extends FormReactive implements OnIni show () { this.closingModal = false - this.modal.show() + this.openedModal = this.modalService.open(this.modal, { keyboard: false }) } hide () { this.closingModal = true - - this.modal.hide() + this.openedModal.close() + this.form.reset() } isReplacingExistingCaption () { @@ -69,8 +72,6 @@ export class VideoCaptionAddModalComponent extends FormReactive implements OnIni } async addCaption () { - this.hide() - const languageId = this.form.value[ 'language' ] const languageObject = this.videoCaptionLanguages.find(l => l.id === languageId) @@ -79,6 +80,6 @@ export class VideoCaptionAddModalComponent extends FormReactive implements OnIni captionfile: this.form.value[ 'captionfile' ] }) - this.form.reset() + this.hide() } }