Project

General

Profile

1
/**
2
 * Created by stefania on 5/2/17.
3
 */
4
import { Component, EventEmitter, Input, Output, ViewChild } from '@angular/core';
5
import { ModalDirective } from 'ngx-bootstrap';
6

    
7
@Component({
8
  selector: 'confirmation-dialog',
9
  templateUrl: './confirmation-dialog.component.html'
10
})
11
export class ConfirmationDialogComponent {
12

    
13
  @ViewChild('autoShownModal') public autoShownModal: ModalDirective;
14

    
15
  @Input() public isModalShown: boolean = false;
16

    
17
  @Input() public confirmed: boolean = true;
18

    
19
  @Input() public title: string;
20

    
21
  @Input() public confirmActionButton: string;
22
  @Input() public confirmButNotCloseButton: string;
23

    
24
  @Input() public hideModalButton: string = 'Cancel';
25

    
26
  @Output() emitObject: EventEmitter<any> = new EventEmitter();
27

    
28
  private _ids: string[] = [];
29

    
30
  public set ids(ids: string[]) {
31
    this._ids = ids;
32
  }
33

    
34
  public showModal(): void {
35
    this.isModalShown = true;
36
  }
37

    
38
  public hideModal(): void {
39
    this.isModalShown = false;
40
    // this.autoShownModal.hide();
41
  }
42

    
43
  public onHidden(): void {
44
    this.isModalShown = false;
45
  }
46

    
47
  public confirmedAction() {
48
    this.emitObject.emit(this._ids);
49
    if(this.confirmed) {
50
      this.isModalShown = false;
51
      // this.hideModal();
52
    }
53
  }
54

    
55
  public confirmedButNotCloseAction() {
56
    this.emitObject.emit(this._ids);
57
  }
58
}
(4-4/9)