2017-12-19 13:53:46 +01:00
|
|
|
import {Component, ViewEncapsulation, ComponentRef, ElementRef, Input, EventEmitter, Output} from '@angular/core';
|
|
|
|
|
|
|
|
@Component({
|
|
|
|
selector: 'modal-select',
|
|
|
|
template: `
|
2020-10-13 21:04:50 +02:00
|
|
|
<div [class]="(!isOpen)?'uk-modal ':'uk-modal uk-open uk-animation-fade'" [open]="!isOpen" uk-modal="center:true"
|
|
|
|
tabindex="-1" role="dialog">
|
|
|
|
<div class="uk-modal-dialog" role="">
|
|
|
|
<div class="modal-content">
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2020-10-13 21:04:50 +02:00
|
|
|
<div class="modal-body">
|
|
|
|
<div>
|
|
|
|
<h4 class="text-center">{{message}}</h4>
|
|
|
|
<div class="-select" data--select>
|
|
|
|
<span></span>
|
|
|
|
<select (change)="selected=$event.target.value">
|
|
|
|
<option *ngFor="let option of options let i=index" value="{{option}}">{{option}}</option>
|
|
|
|
</select>
|
|
|
|
</div>
|
2017-12-19 13:53:46 +01:00
|
|
|
|
2020-10-13 21:04:50 +02:00
|
|
|
<div class="uk-modal-footer uk-text-right">
|
|
|
|
<button class=" uk-button uk-button-default" (click)="close()">Proceed</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2017-12-19 13:53:46 +01:00
|
|
|
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
2020-10-13 21:04:50 +02:00
|
|
|
<!--div class="uk-modal uk-open" aria-hidden="false" style="display: block; overflow-y: scroll;">
|
|
|
|
<div class="uk-modal-dialog" tabindex="">
|
|
|
|
<div class="uk-modal-spinner"></div>
|
|
|
|
</div>
|
|
|
|
</div-->
|
2017-12-19 13:53:46 +01:00
|
|
|
`,
|
|
|
|
encapsulation: ViewEncapsulation.None,
|
|
|
|
})
|
|
|
|
/**
|
2020-10-13 21:04:50 +02:00
|
|
|
* API to an open alert window.
|
|
|
|
*/
|
|
|
|
export class ModalSelect {
|
|
|
|
|
|
|
|
@Input() public message: string = "Loading";
|
|
|
|
@Input() public options: string[] = [];
|
|
|
|
|
|
|
|
public selected: string;
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
/**
|
2020-10-13 21:04:50 +02:00
|
|
|
* if the value is true alert will be visible or else it will be hidden.
|
|
|
|
*/
|
|
|
|
public isOpen: boolean = false;
|
2017-12-19 13:53:46 +01:00
|
|
|
/**
|
2020-10-13 21:04:50 +02:00
|
|
|
* Emitted when a ok button was clicked
|
|
|
|
* or when Ok method is called.
|
|
|
|
*/
|
|
|
|
@Output() public alertOutput: EventEmitter<any> = new EventEmitter();
|
|
|
|
|
|
|
|
constructor(public _elementRef: ElementRef) {
|
|
|
|
}
|
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
/**
|
2020-10-13 21:04:50 +02:00
|
|
|
* Opens a alert window creating backdrop.
|
|
|
|
*/
|
|
|
|
open() {
|
|
|
|
this.isOpen = true;
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|
2020-10-13 21:04:50 +02:00
|
|
|
|
|
|
|
close() {
|
2017-12-19 13:53:46 +01:00
|
|
|
this.isOpen = false;
|
2020-10-13 21:04:50 +02:00
|
|
|
if (!this.selected) {
|
2017-12-19 13:53:46 +01:00
|
|
|
this.selected = this.options[0];
|
|
|
|
}
|
|
|
|
this.alertOutput.emit(this.selected);
|
|
|
|
}
|
2020-10-13 21:04:50 +02:00
|
|
|
|
2017-12-19 13:53:46 +01:00
|
|
|
}
|