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

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

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

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

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

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

    
37
  public hideModal(): void {
38
    this.autoShownModal.hide();
39
  }
40

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

    
45
  public confirmedAction() {
46
    this.emitObject.emit(this._ids);
47
    if(this.confirmed) {
48
      this.hideModal();
49
    }
50
  }
51
}
(4-4/8)