[Library | Trunk]: Fs modal redesign

git-svn-id: https://svn.driver.research-infrastructures.eu/driver/dnet40/modules/uoa-services-library/trunk/ng-openaire-library/src/app@60632 d315682c-612b-4755-9ff5-7f18f6832af3
This commit is contained in:
k.triantafyllou 2021-03-12 09:39:06 +00:00
parent 1042733054
commit b37a64809e
1 changed files with 27 additions and 28 deletions

View File

@ -1,35 +1,25 @@
import {Component, ElementRef, EventEmitter, Input, OnInit, Output} from "@angular/core"; import {Component, ElementRef, EventEmitter, OnInit, Output} from "@angular/core";
import {fromEvent, Subscription} from 'rxjs';
import {delay} from "rxjs/operators";
@Component({ @Component({
selector: 'fs-modal', selector: 'fs-modal',
template: ` template: `
<div class="fs-modal"> <div class="fs-modal" (click)="close()">
<div id="fs-modal" (click)="$event.stopPropagation()" class="fs-modal-dialog">
<a class="close" (click)="close()"> <a class="close" (click)="close()">
<icon name="close" ratio="2"></icon> <icon name="close"></icon>
</a> </a>
<div class="header"> <div class="header">
<div class="uk-position-relative uk-height-1-1"> <h6 *ngIf="title">{{title}}</h6>
<h5 *ngIf="title" class="uk-position-center">
{{title}}
</h5>
<div *ngIf="keys" class="uk-position-center-right uk-visible@m">
<button class="uk-button uk-button-secondary outlined" (click)="close()">{{cancelButtonText}}</button>
<button class="uk-button uk-button-secondary space" (click)="ok()">{{okButtonText}}</button>
</div> </div>
</div> <div class="content" [class.hasFooter]="keys">
</div>
<div class="content">
<div class="content-header">
<div *ngIf="keys" class="uk-flex uk-flex-center uk-width-1-1 uk-margin-medium-bottom uk-hidden@m">
<button class="uk-button uk-button-secondary outlined" (click)="close()">{{cancelButtonText}}</button>
<button class="uk-button uk-button-secondary space" (click)="ok()">{{okButtonText}}</button>
</div>
<ng-content select="[header]">
</ng-content>
</div>
<div class="content-inner">
<ng-content></ng-content> <ng-content></ng-content>
</div> </div>
<div *ngIf="keys" class="footer uk-flex uk-flex-right">
<button class="uk-button uk-button-secondary outlined" (click)="close()">{{cancelButtonText}}</button>
<button class="uk-button uk-button-secondary space" (click)="ok()">{{okButtonText}}</button>
</div>
</div> </div>
</div> </div>
` `
@ -45,6 +35,7 @@ export class FullScreenModalComponent implements OnInit {
cancelEmitter: EventEmitter<boolean> = new EventEmitter<boolean>(); cancelEmitter: EventEmitter<boolean> = new EventEmitter<boolean>();
opened: boolean = false; opened: boolean = false;
private readonly element: any; private readonly element: any;
private subscriptions: any[] = [];
constructor(private el: ElementRef) { constructor(private el: ElementRef) {
this.element = el.nativeElement; this.element = el.nativeElement;
@ -53,11 +44,19 @@ export class FullScreenModalComponent implements OnInit {
ngOnInit() { ngOnInit() {
if (typeof document !== "undefined") { if (typeof document !== "undefined") {
document.body.appendChild(this.element); document.body.appendChild(this.element);
this.subscriptions.push(fromEvent(document, 'keydown').pipe(delay(1)).subscribe((event: KeyboardEvent) => {
this.close();
}));
} }
} }
ngOnDestroy(): void { ngOnDestroy(): void {
this.element.remove(); this.element.remove();
this.subscriptions.forEach(subscription => {
if (subscription instanceof Subscription) {
subscription.unsubscribe();
}
})
} }
open() { open() {