2022-05-30 16:56:47 +02:00
|
|
|
import {Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild} from "@angular/core";
|
2021-03-12 10:39:06 +01:00
|
|
|
import {fromEvent, Subscription} from 'rxjs';
|
|
|
|
import {delay} from "rxjs/operators";
|
2021-03-05 14:31:54 +01:00
|
|
|
|
2022-05-30 16:56:47 +02:00
|
|
|
declare var UIkit;
|
2021-03-05 14:31:54 +01:00
|
|
|
@Component({
|
|
|
|
selector: 'fs-modal',
|
|
|
|
template: `
|
2022-05-30 16:56:47 +02:00
|
|
|
<div #modal_full class="uk-modal-full" uk-modal>
|
2022-05-30 15:52:28 +02:00
|
|
|
<div class="uk-modal-dialog uk-height-1-1">
|
2022-05-30 16:56:47 +02:00
|
|
|
<button class="uk-modal-close-full uk-close-large uk-margin-medium-top uk-margin-medium-right" type="button" uk-close></button>
|
2022-05-30 15:52:28 +02:00
|
|
|
<div class="uk-height-1-1">
|
|
|
|
<div class="header">
|
|
|
|
<ng-content select="[actions]"></ng-content>
|
|
|
|
</div>
|
|
|
|
<div class="content uk-height-1-1">
|
|
|
|
<ng-content></ng-content>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- <div class="fs-modal">
|
2021-03-22 16:10:18 +01:00
|
|
|
<div class="fs-modal-bg" (click)="close()"></div>
|
|
|
|
<div id="fs-modal" class="fs-modal-dialog">
|
2021-03-12 10:39:06 +01:00
|
|
|
<div class="header">
|
2021-03-17 16:42:43 +01:00
|
|
|
<div class="uk-flex-middle uk-grid" uk-grid>
|
|
|
|
<h4 *ngIf="title" class="uk-margin-remove uk-width-expand uk-text-truncate">{{title}}</h4>
|
|
|
|
<div *ngIf="cancelButton || okButton" class="uk-flex uk-flex-right">
|
|
|
|
<div>
|
|
|
|
<ng-content select="[actions]"></ng-content>
|
|
|
|
</div>
|
|
|
|
<button *ngIf="cancelButton" class="uk-button uk-button-secondary outlined uk-margin-small-left" [disabled]="cancelButtonDisabled" (click)="close()">{{cancelButtonText}}</button>
|
|
|
|
<button *ngIf="okButton" class="uk-button uk-button-secondary uk-margin-small-left" [disabled]="okButtonDisabled" (click)="ok()">{{okButtonText}}</button>
|
|
|
|
</div>
|
|
|
|
</div>
|
2021-03-05 14:31:54 +01:00
|
|
|
</div>
|
2021-03-17 16:42:43 +01:00
|
|
|
<div class="content">
|
2021-03-05 14:31:54 +01:00
|
|
|
<ng-content></ng-content>
|
|
|
|
</div>
|
|
|
|
</div>
|
2022-05-30 15:52:28 +02:00
|
|
|
</div> -->
|
2021-03-05 14:31:54 +01:00
|
|
|
`
|
|
|
|
})
|
|
|
|
export class FullScreenModalComponent implements OnInit {
|
|
|
|
okButtonText = 'OK';
|
|
|
|
cancelButtonText = 'Cancel';
|
2021-03-12 11:29:58 +01:00
|
|
|
cancelButton: boolean = false;
|
|
|
|
okButton: boolean = false;
|
2021-03-05 14:31:54 +01:00
|
|
|
title: string = null;
|
2021-03-12 11:00:56 +01:00
|
|
|
@Input()
|
|
|
|
okButtonDisabled = false;
|
|
|
|
@Input()
|
|
|
|
cancelButtonDisabled = false;
|
2021-03-05 14:31:54 +01:00
|
|
|
@Output()
|
|
|
|
okEmitter: EventEmitter<boolean> = new EventEmitter<boolean>();
|
2021-03-11 17:27:28 +01:00
|
|
|
@Output()
|
|
|
|
cancelEmitter: EventEmitter<boolean> = new EventEmitter<boolean>();
|
2021-03-05 14:31:54 +01:00
|
|
|
opened: boolean = false;
|
2022-05-30 16:56:47 +02:00
|
|
|
@ViewChild('modal_full') element: ElementRef;
|
2021-03-12 10:39:06 +01:00
|
|
|
private subscriptions: any[] = [];
|
2021-03-22 16:10:18 +01:00
|
|
|
private clickedInside: boolean;
|
2021-03-05 14:31:54 +01:00
|
|
|
|
|
|
|
constructor(private el: ElementRef) {
|
|
|
|
this.element = el.nativeElement;
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnInit() {
|
2021-03-12 10:39:06 +01:00
|
|
|
if (typeof document !== "undefined") {
|
|
|
|
this.subscriptions.push(fromEvent(document, 'keydown').pipe(delay(1)).subscribe((event: KeyboardEvent) => {
|
2021-03-12 13:49:01 +01:00
|
|
|
if(event.keyCode === 27) {
|
|
|
|
this.close();
|
|
|
|
}
|
2021-03-12 10:39:06 +01:00
|
|
|
}));
|
2021-03-05 14:31:54 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ngOnDestroy(): void {
|
2021-03-12 10:39:06 +01:00
|
|
|
this.subscriptions.forEach(subscription => {
|
|
|
|
if (subscription instanceof Subscription) {
|
|
|
|
subscription.unsubscribe();
|
|
|
|
}
|
|
|
|
})
|
2021-03-05 14:31:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
open() {
|
2022-05-30 16:56:47 +02:00
|
|
|
UIkit.modal(this.element.nativeElement).show();
|
2021-03-05 14:31:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
close() {
|
2022-05-30 16:56:47 +02:00
|
|
|
UIkit.modal(this.element.nativeElement).hide();
|
|
|
|
this.cancelEmitter.emit();
|
2021-03-05 14:31:54 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
ok() {
|
|
|
|
this.close();
|
|
|
|
this.okEmitter.emit(true);
|
|
|
|
}
|
|
|
|
}
|