]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/shared-moderation/batch-domains-modal.component.ts
Refactor modal buttons style
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-moderation / batch-domains-modal.component.ts
CommitLineData
67ed6552 1import { Component, EventEmitter, Input, OnInit, Output, ViewChild } from '@angular/core'
7ed1edbb 2import { FormReactive, FormValidatorService } from '@app/shared/shared-forms'
bb152476
RK
3import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
4import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
7ed1edbb 5import { DOMAINS_VALIDATOR, getNotEmptyHosts } from '../form-validators/batch-domains-validators'
bb152476
RK
6
7@Component({
8 selector: 'my-batch-domains-modal',
9 templateUrl: './batch-domains-modal.component.html',
10 styleUrls: [ './batch-domains-modal.component.scss' ]
11})
12export class BatchDomainsModalComponent extends FormReactive implements OnInit {
13 @ViewChild('modal', { static: true }) modal: NgbModal
14 @Input() placeholder = 'example.com'
15 @Input() action: string
16 @Output() domains = new EventEmitter<string[]>()
17
18 private openedModal: NgbModalRef
19
20 constructor (
21 protected formValidatorService: FormValidatorService,
7ed1edbb 22 private modalService: NgbModal
bb152476
RK
23 ) {
24 super()
25 }
26
27 ngOnInit () {
66357162 28 if (!this.action) this.action = $localize`Process domains`
bb152476
RK
29
30 this.buildForm({
7ed1edbb 31 domains: DOMAINS_VALIDATOR
bb152476
RK
32 })
33 }
34
35 openModal () {
36 this.openedModal = this.modalService.open(this.modal, { centered: true })
37 }
38
39 hide () {
40 this.openedModal.close()
41 }
42
43 submit () {
44 this.domains.emit(
7ed1edbb 45 getNotEmptyHosts(this.form.controls['domains'].value)
bb152476
RK
46 )
47 this.form.reset()
48 this.hide()
49 }
50}