aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/core/confirm
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
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')
-rw-r--r--client/src/app/core/confirm/confirm.component.html44
-rw-r--r--client/src/app/core/confirm/confirm.component.ts37
2 files changed, 33 insertions, 48 deletions
diff --git a/client/src/app/core/confirm/confirm.component.html b/client/src/app/core/confirm/confirm.component.html
index 0bb64cf00..43f0c6190 100644
--- a/client/src/app/core/confirm/confirm.component.html
+++ b/client/src/app/core/confirm/confirm.component.html
@@ -1,31 +1,25 @@
1<div bsModal #confirmModal="bs-modal" [config]="{ animated: false }" class="modal" tabindex="-1" role="dialog"> 1<ng-template #confirmModal let-close="close" let-dismiss="dismiss">
2 <div class="modal-dialog">
3 <div class="modal-content">
4 2
5 <div class="modal-header"> 3 <div class="modal-header">
6 <span class="close" aria-hidden="true" (click)="cancel()"></span> 4 <h4 class="modal-title">{{ title }}</h4>
7 <h4 class="modal-title">{{ title }}</h4> 5 <span class="close" aria-label="Close" role="button" (click)="dismiss()"></span>
8 </div> 6 </div>
9 7
10 <div class="modal-body" > 8 <div class="modal-body" >
11 <div [innerHtml]="message"></div> 9 <div [innerHtml]="message"></div>
12 10
13 <div *ngIf="inputLabel && expectedInputValue" class="form-group"> 11 <div *ngIf="inputLabel && expectedInputValue" class="form-group">
14 <label for="confirmInput">{{ inputLabel }}</label> 12 <label for="confirmInput">{{ inputLabel }}</label>
15 <input type="text" id="confirmInput" name="confirmInput" [(ngModel)]="inputValue" /> 13 <input type="text" id="confirmInput" name="confirmInput" [(ngModel)]="inputValue" />
16 </div> 14 </div>
15 </div>
17 16
18 <div class="form-group inputs"> 17 <div class="modal-footer inputs">
19 <span i18n class="action-button action-button-cancel" (click)="cancel()"> 18 <span i18n class="action-button action-button-cancel" (click)="dismiss()" role="button">Cancel</span>
20 Cancel
21 </span>
22 19
23 <input 20 <input
24 type="submit" [value]="confirmButtonText" class="action-button-submit" [disabled]="isConfirmationDisabled()" 21 type="submit" [value]="confirmButtonText" class="action-button-submit" [disabled]="isConfirmationDisabled()"
25 (click)="confirm()" 22 (click)="close()"
26 > 23 >
27 </div>
28 </div>
29 </div>
30 </div> 24 </div>
31</div> 25</ng-template>
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}