aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/confirm
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-06-23 14:10:17 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-06-23 16:00:49 +0200
commit67ed6552b831df66713bac9e672738796128d33f (patch)
tree59c97d41e0b49d75a90aa3de987968ab9b1ff447 /client/src/app/shared/confirm
parent0c4bacbff53bc732f5a2677d62a6ead7752e2405 (diff)
downloadPeerTube-67ed6552b831df66713bac9e672738796128d33f.tar.gz
PeerTube-67ed6552b831df66713bac9e672738796128d33f.tar.zst
PeerTube-67ed6552b831df66713bac9e672738796128d33f.zip
Reorganize client shared modules
Diffstat (limited to 'client/src/app/shared/confirm')
-rw-r--r--client/src/app/shared/confirm/confirm.component.html30
-rw-r--r--client/src/app/shared/confirm/confirm.component.scss21
-rw-r--r--client/src/app/shared/confirm/confirm.component.ts73
3 files changed, 0 insertions, 124 deletions
diff --git a/client/src/app/shared/confirm/confirm.component.html b/client/src/app/shared/confirm/confirm.component.html
deleted file mode 100644
index dbc8c23e3..000000000
--- a/client/src/app/shared/confirm/confirm.component.html
+++ /dev/null
@@ -1,30 +0,0 @@
1<ng-template #confirmModal let-close="close" let-dismiss="dismiss">
2
3 <div class="modal-header">
4 <h4 class="modal-title">{{ title }}</h4>
5
6 <my-global-icon iconName="cross" aria-label="Close" role="button" (click)="dismiss()"></my-global-icon>
7 </div>
8
9 <div class="modal-body" >
10 <div [innerHtml]="message"></div>
11
12 <div *ngIf="inputLabel && expectedInputValue" class="form-group">
13 <label for="confirmInput">{{ inputLabel }}</label>
14 <input type="text" id="confirmInput" name="confirmInput" [(ngModel)]="inputValue" />
15 </div>
16 </div>
17
18 <div class="modal-footer inputs">
19 <input
20 type="button" role="button" i18n-value value="Cancel" class="action-button action-button-cancel"
21 (click)="dismiss()" (key.enter)="dismiss()"
22 >
23
24 <input
25 ngbAutofocus
26 type="submit" [value]="confirmButtonText" class="action-button-submit" [disabled]="isConfirmationDisabled()"
27 (click)="close()" (key.enter)="confirm()"
28 >
29 </div>
30</ng-template>
diff --git a/client/src/app/shared/confirm/confirm.component.scss b/client/src/app/shared/confirm/confirm.component.scss
deleted file mode 100644
index ed226bc09..000000000
--- a/client/src/app/shared/confirm/confirm.component.scss
+++ /dev/null
@@ -1,21 +0,0 @@
1@import '_variables';
2@import '_mixins';
3
4.modal-body {
5 font-size: 15px;
6}
7
8.button {
9 padding: 0 13px;
10}
11
12input[type=text] {
13 @include peertube-input-text(100%);
14 display: block;
15}
16
17.form-group {
18 margin: 20px 0;
19}
20
21
diff --git a/client/src/app/shared/confirm/confirm.component.ts b/client/src/app/shared/confirm/confirm.component.ts
deleted file mode 100644
index c6e40fe72..000000000
--- a/client/src/app/shared/confirm/confirm.component.ts
+++ /dev/null
@@ -1,73 +0,0 @@
1import { Component, ElementRef, HostListener, OnInit, ViewChild } from '@angular/core'
2import { ConfirmService } from '@app/core/confirm/confirm.service'
3import { I18n } from '@ngx-translate/i18n-polyfill'
4import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
5import { NgbModalRef } from '@ng-bootstrap/ng-bootstrap/modal/modal-ref'
6import { POP_STATE_MODAL_DISMISS } from '@app/shared/misc/constants'
7
8@Component({
9 selector: 'my-confirm',
10 templateUrl: './confirm.component.html',
11 styleUrls: [ './confirm.component.scss' ]
12})
13export class ConfirmComponent implements OnInit {
14 @ViewChild('confirmModal', { static: true }) confirmModal: ElementRef
15
16 title = ''
17 message = ''
18 expectedInputValue = ''
19 inputLabel = ''
20
21 inputValue = ''
22 confirmButtonText = ''
23
24 private openedModal: NgbModalRef
25
26 constructor (
27 private modalService: NgbModal,
28 private confirmService: ConfirmService,
29 private i18n: I18n
30 ) { }
31
32 ngOnInit () {
33 this.confirmService.showConfirm.subscribe(
34 ({ title, message, expectedInputValue, inputLabel, confirmButtonText }) => {
35 this.title = title
36 this.message = message
37
38 this.inputLabel = inputLabel
39 this.expectedInputValue = expectedInputValue
40
41 this.confirmButtonText = confirmButtonText || this.i18n('Confirm')
42
43 this.showModal()
44 }
45 )
46 }
47
48 confirm () {
49 if (this.openedModal) this.openedModal.close()
50 }
51
52 isConfirmationDisabled () {
53 // No input validation
54 if (!this.inputLabel || !this.expectedInputValue) return false
55
56 return this.expectedInputValue !== this.inputValue
57 }
58
59 showModal () {
60 this.inputValue = ''
61
62 this.openedModal = this.modalService.open(this.confirmModal, { centered: true })
63
64 this.openedModal.result
65 .then(() => this.confirmService.confirmResponse.next(true))
66 .catch((reason: string) => {
67 // If the reason was that the user used the back button, we don't care about the confirm dialog result
68 if (!reason || reason !== POP_STATE_MODAL_DISMISS) {
69 this.confirmService.confirmResponse.next(false)
70 }
71 })
72 }
73}