102 lines
14 KiB
JavaScript
102 lines
14 KiB
JavaScript
import { Injectable, Inject, createComponent } from '@angular/core';
|
|
import { DomHandler } from 'primeng/dom';
|
|
import { DynamicDialogComponent } from './dynamicdialog';
|
|
import { DynamicDialogInjector } from './dynamicdialog-injector';
|
|
import { DynamicDialogConfig } from './dynamicdialog-config';
|
|
import { DynamicDialogRef } from './dynamicdialog-ref';
|
|
import { DOCUMENT } from '@angular/common';
|
|
import * as i0 from "@angular/core";
|
|
/**
|
|
* Dynamic Dialog component methods.
|
|
* @group Service
|
|
*/
|
|
export class DialogService {
|
|
appRef;
|
|
injector;
|
|
document;
|
|
dialogComponentRefMap = new Map();
|
|
constructor(appRef, injector, document) {
|
|
this.appRef = appRef;
|
|
this.injector = injector;
|
|
this.document = document;
|
|
}
|
|
/**
|
|
* Displays the dialog using the dynamic dialog object options.
|
|
* @param {*} componentType - Dynamic component for content template.
|
|
* @param {DynamicDialogConfig} config - DynamicDialog object.
|
|
* @returns {DynamicDialogRef} DynamicDialog instance.
|
|
* @group Method
|
|
*/
|
|
open(componentType, config) {
|
|
if (!this.duplicationPermission(componentType, config)) {
|
|
return null;
|
|
}
|
|
const dialogRef = this.appendDialogComponentToBody(config, componentType);
|
|
this.dialogComponentRefMap.get(dialogRef).instance.childComponentType = componentType;
|
|
return dialogRef;
|
|
}
|
|
/**
|
|
* Returns the dynamic dialog component instance.
|
|
* @param {ref} DynamicDialogRef - DynamicDialog instance.
|
|
* @group Method
|
|
*/
|
|
getInstance(ref) {
|
|
return this.dialogComponentRefMap.get(ref).instance;
|
|
}
|
|
appendDialogComponentToBody(config, componentType) {
|
|
const map = new WeakMap();
|
|
map.set(DynamicDialogConfig, config);
|
|
const dialogRef = new DynamicDialogRef();
|
|
map.set(DynamicDialogRef, dialogRef);
|
|
const sub = dialogRef.onClose.subscribe(() => {
|
|
this.dialogComponentRefMap.get(dialogRef).instance.close();
|
|
});
|
|
const destroySub = dialogRef.onDestroy.subscribe(() => {
|
|
this.removeDialogComponentFromBody(dialogRef);
|
|
destroySub.unsubscribe();
|
|
sub.unsubscribe();
|
|
});
|
|
const componentRef = createComponent(DynamicDialogComponent, { environmentInjector: this.appRef.injector, elementInjector: new DynamicDialogInjector(this.injector, map) });
|
|
this.appRef.attachView(componentRef.hostView);
|
|
const domElem = componentRef.hostView.rootNodes[0];
|
|
if (!config.appendTo || config.appendTo === 'body') {
|
|
this.document.body.appendChild(domElem);
|
|
}
|
|
else {
|
|
DomHandler.appendChild(domElem, config.appendTo);
|
|
}
|
|
this.dialogComponentRefMap.set(dialogRef, componentRef);
|
|
return dialogRef;
|
|
}
|
|
removeDialogComponentFromBody(dialogRef) {
|
|
if (!dialogRef || !this.dialogComponentRefMap.has(dialogRef)) {
|
|
return;
|
|
}
|
|
const dialogComponentRef = this.dialogComponentRefMap.get(dialogRef);
|
|
this.appRef.detachView(dialogComponentRef.hostView);
|
|
dialogComponentRef.destroy();
|
|
this.dialogComponentRefMap.delete(dialogRef);
|
|
}
|
|
duplicationPermission(componentType, config) {
|
|
if (config.duplicate) {
|
|
return true;
|
|
}
|
|
let permission = true;
|
|
for (const [key, value] of this.dialogComponentRefMap) {
|
|
if (value.instance.childComponentType === componentType) {
|
|
permission = false;
|
|
break;
|
|
}
|
|
}
|
|
return permission;
|
|
}
|
|
static ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: DialogService, deps: [{ token: i0.ApplicationRef }, { token: i0.Injector }, { token: DOCUMENT }], target: i0.ɵɵFactoryTarget.Injectable });
|
|
static ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: DialogService });
|
|
}
|
|
i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.3.7", ngImport: i0, type: DialogService, decorators: [{
|
|
type: Injectable
|
|
}], ctorParameters: () => [{ type: i0.ApplicationRef }, { type: i0.Injector }, { type: Document, decorators: [{
|
|
type: Inject,
|
|
args: [DOCUM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