1
|
import {Component, ViewEncapsulation, ComponentRef, ElementRef, Input, EventEmitter, Output} from '@angular/core';
|
2
|
|
3
|
@Component({
|
4
|
selector: 'modal-select',
|
5
|
template: `
|
6
|
<div [class]="(!isOpen)?'uk-modal ':'uk-modal uk-open uk-animation-fade'" [open]="!isOpen" uk-modal="center:true"
|
7
|
tabindex="-1" role="dialog">
|
8
|
<div class="uk-modal-dialog" role="">
|
9
|
<div class="modal-content">
|
10
|
|
11
|
<div class="modal-body">
|
12
|
<div>
|
13
|
<h4 class="text-center">{{message}}</h4>
|
14
|
<div class="-select" data--select>
|
15
|
<span></span>
|
16
|
<select (change)="selected=$event.target.value">
|
17
|
<option *ngFor="let option of options let i=index" value="{{option}}">{{option}}</option>
|
18
|
</select>
|
19
|
</div>
|
20
|
|
21
|
<div class="uk-modal-footer uk-text-right">
|
22
|
<button class=" uk-button uk-button-default" (click)="close()">Proceed</button>
|
23
|
</div>
|
24
|
</div>
|
25
|
|
26
|
</div>
|
27
|
</div>
|
28
|
</div>
|
29
|
<!--div class="uk-modal uk-open" aria-hidden="false" style="display: block; overflow-y: scroll;">
|
30
|
<div class="uk-modal-dialog" tabindex="">
|
31
|
<div class="uk-modal-spinner"></div>
|
32
|
</div>
|
33
|
</div-->
|
34
|
`,
|
35
|
encapsulation: ViewEncapsulation.None,
|
36
|
})
|
37
|
/**
|
38
|
* API to an open alert window.
|
39
|
*/
|
40
|
export class ModalSelect {
|
41
|
|
42
|
@Input() public message: string = "Loading";
|
43
|
@Input() public options: string[] = [];
|
44
|
|
45
|
public selected: string;
|
46
|
|
47
|
/**
|
48
|
* if the value is true alert will be visible or else it will be hidden.
|
49
|
*/
|
50
|
public isOpen: boolean = false;
|
51
|
/**
|
52
|
* Emitted when a ok button was clicked
|
53
|
* or when Ok method is called.
|
54
|
*/
|
55
|
@Output() public alertOutput: EventEmitter<any> = new EventEmitter();
|
56
|
|
57
|
constructor(public _elementRef: ElementRef) {
|
58
|
}
|
59
|
|
60
|
/**
|
61
|
* Opens a alert window creating backdrop.
|
62
|
*/
|
63
|
open() {
|
64
|
this.isOpen = true;
|
65
|
}
|
66
|
|
67
|
close() {
|
68
|
this.isOpen = false;
|
69
|
if (!this.selected) {
|
70
|
this.selected = this.options[0];
|
71
|
}
|
72
|
this.alertOutput.emit(this.selected);
|
73
|
}
|
74
|
|
75
|
}
|