Adjust Settings Popup Position
This commit is contained in:
1 parent
010771b22a
commit
898df6a318
9 files changed
+64
-19
No files matched your search
@@ -1,5 +1,10 @@
|
||||
import { Injectable, signal, Type } from '@angular/core';
|
||||
|
||||
export interface PopupInstance {
|
||||
component: Type<any>;
|
||||
inputs?: Record<string, any>;
|
||||
}
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root',
|
||||
})
|
||||
@@ -7,15 +12,15 @@ export class PopupService {
|
||||
/**
|
||||
* 현재 활성화된 팝업 컴포넌트들의 리스트 (Signal)
|
||||
*/
|
||||
activePopups = signal<Type<any>[]>([]);
|
||||
activePopups = signal<PopupInstance[]>([]);
|
||||
|
||||
/**
|
||||
* 팝업을 엽니다. 이미 열려있는 동일한 컴포넌트가 있다면 중복해서 열지 않습니다.
|
||||
*/
|
||||
open<T>(component: Type<T>) {
|
||||
open<T>(component: Type<T>, inputs?: Record<string, any>) {
|
||||
this.activePopups.update((popups) => {
|
||||
if (popups.includes(component)) return popups;
|
||||
return [...popups, component];
|
||||
if (popups.some((p) => p.component === component)) return popups;
|
||||
return [...popups, { component, inputs }];
|
||||
});
|
||||
}
|
||||
|
||||
@@ -23,7 +28,7 @@ export class PopupService {
|
||||
* 특정 컴포넌트를 닫습니다.
|
||||
*/
|
||||
close(component: Type<any>) {
|
||||
this.activePopups.update((popups) => popups.filter((p) => p !== component));
|
||||
this.activePopups.update((popups) => popups.filter((p) => p.component !== component));
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in new issue
Block a user