aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core/confirm/confirm.component.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2018-08-09 14:55:06 +0200
committerChocobozzz <me@florianbigard.com>2018-08-09 14:55:06 +0200
commit63347a0ff966c7863e5b7431effa1cb0668df893 (patch)
tree8f89d9b4a73f7157103574c05832eff21e338272 /client/src/app/core/confirm/confirm.component.ts
parentb34a444e291c8ec90b4c2c965f7d0d6904d1faa7 (diff)
downloadPeerTube-63347a0ff966c7863e5b7431effa1cb0668df893.tar.gz
PeerTube-63347a0ff966c7863e5b7431effa1cb0668df893.tar.zst
PeerTube-63347a0ff966c7863e5b7431effa1cb0668df893.zip
Migrate to bootstrap 4 and ng-bootstrap
Diffstat (limited to 'client/src/app/core/confirm/confirm.component.ts')
-rw-r--r--client/src/app/core/confirm/confirm.component.ts37
1 files changed, 14 insertions, 23 deletions
diff --git a/client/src/app/core/confirm/confirm.component.ts b/client/src/app/core/confirm/confirm.component.ts
index a13152496..0d18c38e8 100644
--- a/client/src/app/core/confirm/confirm.component.ts
+++ b/client/src/app/core/confirm/confirm.component.ts
@@ -1,9 +1,8 @@
1import { Component, HostListener, OnInit, ViewChild } from '@angular/core' 1import { Component, ElementRef, HostListener, OnInit, ViewChild } from '@angular/core'
2
3import { ModalDirective } from 'ngx-bootstrap/modal'
4
5import { ConfirmService } from './confirm.service' 2import { ConfirmService } from './confirm.service'
6import { I18n } from '@ngx-translate/i18n-polyfill' 3import { I18n } from '@ngx-translate/i18n-polyfill'
4import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
5import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
7 6
8@Component({ 7@Component({
9 selector: 'my-confirm', 8 selector: 'my-confirm',
@@ -11,7 +10,7 @@ import { I18n } from '@ngx-translate/i18n-polyfill'
11 styleUrls: [ './confirm.component.scss' ] 10 styleUrls: [ './confirm.component.scss' ]
12}) 11})
13export class ConfirmComponent implements OnInit { 12export class ConfirmComponent implements OnInit {
14 @ViewChild('confirmModal') confirmModal: ModalDirective 13 @ViewChild('confirmModal') confirmModal: ElementRef
15 14
16 title = '' 15 title = ''
17 message = '' 16 message = ''
@@ -21,7 +20,10 @@ export class ConfirmComponent implements OnInit {
21 inputValue = '' 20 inputValue = ''
22 confirmButtonText = '' 21 confirmButtonText = ''
23 22
23 private openedModal: NgbModalRef
24
24 constructor ( 25 constructor (
26 private modalService: NgbModal,
25 private confirmService: ConfirmService, 27 private confirmService: ConfirmService,
26 private i18n: I18n 28 private i18n: I18n
27 ) { 29 ) {
@@ -29,11 +31,6 @@ export class ConfirmComponent implements OnInit {
29 } 31 }
30 32
31 ngOnInit () { 33 ngOnInit () {
32 this.confirmModal.config = {
33 backdrop: 'static',
34 keyboard: false
35 }
36
37 this.confirmService.showConfirm.subscribe( 34 this.confirmService.showConfirm.subscribe(
38 ({ title, message, expectedInputValue, inputLabel, confirmButtonText }) => { 35 ({ title, message, expectedInputValue, inputLabel, confirmButtonText }) => {
39 this.title = title 36 this.title = title
@@ -49,16 +46,9 @@ export class ConfirmComponent implements OnInit {
49 ) 46 )
50 } 47 }
51 48
52 @HostListener('keydown.enter') 49 @HostListener('document:keydown.enter')
53 confirm () { 50 confirm () {
54 this.confirmService.confirmResponse.next(true) 51 if (this.openedModal) this.openedModal.close()
55 this.hideModal()
56 }
57
58 @HostListener('keydown.esc')
59 cancel () {
60 this.confirmService.confirmResponse.next(false)
61 this.hideModal()
62 } 52 }
63 53
64 isConfirmationDisabled () { 54 isConfirmationDisabled () {
@@ -70,10 +60,11 @@ export class ConfirmComponent implements OnInit {
70 60
71 showModal () { 61 showModal () {
72 this.inputValue = '' 62 this.inputValue = ''
73 this.confirmModal.show()
74 }
75 63
76 hideModal () { 64 this.openedModal = this.modalService.open(this.confirmModal)
77 this.confirmModal.hide() 65
66 this.openedModal.result
67 .then(() => this.confirmService.confirmResponse.next(true))
68 .catch(() => this.confirmService.confirmResponse.next(false))
78 } 69 }
79} 70}