EchoTex_Payroll/HRM.UI/ClientApp/src/app/app.windowPopup.service.ts
2024-10-14 10:01:49 +06:00

76 lines
1.9 KiB
TypeScript

import {Injectable, TemplateRef} from '@angular/core';
import {Observable, Subject} from 'rxjs';
import {WindowRef, WindowService} from '@progress/kendo-angular-dialog';
@Injectable({
providedIn: 'root',
})
export class AppWindowPopUp {
public _window: WindowRef;
public _subject: Subject<any> = new Subject<any>();
public _boObject: any;
private _width = 625;
private _height = 325;
private _top = 50;
private _left = 250;
constructor(private windowService: WindowService) {
// if (this._window.result != undefined) {
// this._window.result.subscribe((result) => {
// if (result instanceof WindowCloseResult) {
// this._subject.next("No Return value");
// }
// });
// }
}
public show(scontent: string | TemplateRef<any> | any, Title: string, boObject: any, Width?: number, Height?: number
, Top?: number, Left?: number): Observable<any> {
let cwidth = this._width;
let cheight = this._height;
let ctop = this._top;
let cleft = this._left;
this._boObject = boObject;
if (Width !== undefined) {
cwidth = Width;
}
if (Height !== undefined) {
cheight = Height;
}
if (Top !== undefined) {
ctop = Top;
}
if (Left !== undefined) {
cleft = Left;
}
this._window = this.windowService.open({
title: Title,
content: scontent,
width: cwidth,
height: cheight,
left: cleft,
top: ctop,
});
this._subject.unsubscribe();
this._subject = new Subject<any>();
return this._subject.asObservable();
}
public Close(returnValue?: any) {
this._subject.next(returnValue);
this._window.close();
}
}