-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',
@Output() captionAdded = new EventEmitter<VideoCaptionEdit>()
- @ViewChild('modal') modal: ModalDirective
+ @ViewChild('modal', { static: true }) modal: ElementRef
- videoCaptionLanguages = []
+ videoCaptionLanguages: VideoConstant<string>[] = []
+ private openedModal: NgbModalRef
private closingModal = false
constructor (
protected formValidatorService: FormValidatorService,
+ private modalService: NgbModal,
private serverService: ServerService,
private videoCaptionsValidatorsService: VideoCaptionsValidatorsService
) {
}
show () {
- this.modal.show()
+ this.closingModal = false
+
+ this.openedModal = this.modalService.open(this.modal, { keyboard: false })
}
hide () {
- this.modal.hide()
+ this.closingModal = true
+ this.openedModal.close()
+ this.form.reset()
}
isReplacingExistingCaption () {
}
async addCaption () {
- this.closingModal = true
-
const languageId = this.form.value[ 'language' ]
const languageObject = this.videoCaptionLanguages.find(l => l.id === languageId)
this.captionAdded.emit({
language: languageObject,
- captionfile: this.form.value['captionfile']
+ captionfile: this.form.value[ 'captionfile' ]
})
this.hide()