diff options
Diffstat (limited to 'client/src/app/core/confirm')
-rw-r--r-- | client/src/app/core/confirm/confirm.component.ts | 48 | ||||
-rw-r--r-- | client/src/app/core/confirm/confirm.service.ts | 16 | ||||
-rw-r--r-- | client/src/app/core/confirm/index.ts | 4 |
3 files changed, 34 insertions, 34 deletions
diff --git a/client/src/app/core/confirm/confirm.component.ts b/client/src/app/core/confirm/confirm.component.ts index ae42ff68a..066e3fc5f 100644 --- a/client/src/app/core/confirm/confirm.component.ts +++ b/client/src/app/core/confirm/confirm.component.ts | |||
@@ -1,12 +1,12 @@ | |||
1 | import { Component, HostListener, OnInit, ViewChild } from '@angular/core'; | 1 | import { Component, HostListener, OnInit, ViewChild } from '@angular/core' |
2 | 2 | ||
3 | import { ModalDirective } from 'ngx-bootstrap/modal'; | 3 | import { ModalDirective } from 'ngx-bootstrap/modal' |
4 | 4 | ||
5 | import { ConfirmService } from './confirm.service'; | 5 | import { ConfirmService } from './confirm.service' |
6 | 6 | ||
7 | export interface ConfigChangedEvent { | 7 | export interface ConfigChangedEvent { |
8 | columns: { [id: string]: { isDisplayed: boolean }; }; | 8 | columns: { [id: string]: { isDisplayed: boolean } } |
9 | config: { resultsPerPage: number }; | 9 | config: { resultsPerPage: number } |
10 | } | 10 | } |
11 | 11 | ||
12 | @Component({ | 12 | @Component({ |
@@ -14,48 +14,48 @@ export interface ConfigChangedEvent { | |||
14 | templateUrl: './confirm.component.html' | 14 | templateUrl: './confirm.component.html' |
15 | }) | 15 | }) |
16 | export class ConfirmComponent implements OnInit { | 16 | export class ConfirmComponent implements OnInit { |
17 | @ViewChild('confirmModal') confirmModal: ModalDirective; | 17 | @ViewChild('confirmModal') confirmModal: ModalDirective |
18 | 18 | ||
19 | title = ''; | 19 | title = '' |
20 | message = ''; | 20 | message = '' |
21 | 21 | ||
22 | constructor (private confirmService: ConfirmService) { | 22 | constructor (private confirmService: ConfirmService) { |
23 | // Empty | 23 | // Empty |
24 | } | 24 | } |
25 | 25 | ||
26 | ngOnInit() { | 26 | ngOnInit () { |
27 | this.confirmModal.config = { | 27 | this.confirmModal.config = { |
28 | backdrop: 'static', | 28 | backdrop: 'static', |
29 | keyboard: false | 29 | keyboard: false |
30 | }; | 30 | } |
31 | 31 | ||
32 | this.confirmService.showConfirm.subscribe( | 32 | this.confirmService.showConfirm.subscribe( |
33 | ({ title, message }) => { | 33 | ({ title, message }) => { |
34 | this.title = title; | 34 | this.title = title |
35 | this.message = message; | 35 | this.message = message |
36 | 36 | ||
37 | this.showModal(); | 37 | this.showModal() |
38 | } | 38 | } |
39 | ); | 39 | ) |
40 | } | 40 | } |
41 | 41 | ||
42 | @HostListener('keydown.enter') | 42 | @HostListener('keydown.enter') |
43 | confirm() { | 43 | confirm () { |
44 | this.confirmService.confirmResponse.next(true); | 44 | this.confirmService.confirmResponse.next(true) |
45 | this.hideModal(); | 45 | this.hideModal() |
46 | } | 46 | } |
47 | 47 | ||
48 | @HostListener('keydown.esc') | 48 | @HostListener('keydown.esc') |
49 | abort() { | 49 | abort () { |
50 | this.confirmService.confirmResponse.next(false); | 50 | this.confirmService.confirmResponse.next(false) |
51 | this.hideModal(); | 51 | this.hideModal() |
52 | } | 52 | } |
53 | 53 | ||
54 | showModal() { | 54 | showModal () { |
55 | this.confirmModal.show(); | 55 | this.confirmModal.show() |
56 | } | 56 | } |
57 | 57 | ||
58 | hideModal() { | 58 | hideModal () { |
59 | this.confirmModal.hide(); | 59 | this.confirmModal.hide() |
60 | } | 60 | } |
61 | } | 61 | } |
diff --git a/client/src/app/core/confirm/confirm.service.ts b/client/src/app/core/confirm/confirm.service.ts index 08127a66f..f12ff1848 100644 --- a/client/src/app/core/confirm/confirm.service.ts +++ b/client/src/app/core/confirm/confirm.service.ts | |||
@@ -1,15 +1,15 @@ | |||
1 | import { Injectable } from '@angular/core'; | 1 | import { Injectable } from '@angular/core' |
2 | import { Subject } from 'rxjs/Subject'; | 2 | import { Subject } from 'rxjs/Subject' |
3 | import 'rxjs/add/operator/first'; | 3 | import 'rxjs/add/operator/first' |
4 | 4 | ||
5 | @Injectable() | 5 | @Injectable() |
6 | export class ConfirmService { | 6 | export class ConfirmService { |
7 | showConfirm = new Subject<{ title, message }>(); | 7 | showConfirm = new Subject<{ title, message }>() |
8 | confirmResponse = new Subject<boolean>(); | 8 | confirmResponse = new Subject<boolean>() |
9 | 9 | ||
10 | confirm(message = '', title = '') { | 10 | confirm (message = '', title = '') { |
11 | this.showConfirm.next({ title, message }); | 11 | this.showConfirm.next({ title, message }) |
12 | 12 | ||
13 | return this.confirmResponse.asObservable().first(); | 13 | return this.confirmResponse.asObservable().first() |
14 | } | 14 | } |
15 | } | 15 | } |
diff --git a/client/src/app/core/confirm/index.ts b/client/src/app/core/confirm/index.ts index 789e7e547..44aabfc13 100644 --- a/client/src/app/core/confirm/index.ts +++ b/client/src/app/core/confirm/index.ts | |||
@@ -1,2 +1,2 @@ | |||
1 | export * from './confirm.component'; | 1 | export * from './confirm.component' |
2 | export * from './confirm.service'; | 2 | export * from './confirm.service' |