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