모달열기 액션 통합
This commit is contained in:
@@ -306,11 +306,11 @@ export const ButtonPrimaryComponent: React.FC<ButtonPrimaryComponentProps> = ({
|
||||
|
||||
// 동적 import로 modalDataStore 구독
|
||||
let unsubscribe: (() => void) | undefined;
|
||||
|
||||
|
||||
import("@/stores/modalDataStore").then(({ useModalDataStore }) => {
|
||||
// 초기값 설정
|
||||
setModalStoreData(useModalDataStore.getState().dataRegistry);
|
||||
|
||||
|
||||
// 상태 변경 구독
|
||||
unsubscribe = useModalDataStore.subscribe((state) => {
|
||||
setModalStoreData(state.dataRegistry);
|
||||
@@ -325,7 +325,7 @@ export const ButtonPrimaryComponent: React.FC<ButtonPrimaryComponentProps> = ({
|
||||
// 🆕 행 선택 기반 비활성화 조건 계산
|
||||
const isRowSelectionDisabled = useMemo(() => {
|
||||
const actionConfig = component.componentConfig?.action;
|
||||
|
||||
|
||||
// requireRowSelection이 활성화되어 있지 않으면 비활성화하지 않음
|
||||
if (!actionConfig?.requireRowSelection) {
|
||||
return false;
|
||||
@@ -365,7 +365,7 @@ export const ButtonPrimaryComponent: React.FC<ButtonPrimaryComponentProps> = ({
|
||||
selectionSource = "splitPanelLeft (context)";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 🆕 modalDataStore에서도 확인 (SplitPanelLayoutComponent에서 저장)
|
||||
if (!hasSelection && Object.keys(modalStoreData).length > 0) {
|
||||
// modalDataStore에서 데이터가 있는지 확인
|
||||
@@ -390,39 +390,16 @@ export const ButtonPrimaryComponent: React.FC<ButtonPrimaryComponentProps> = ({
|
||||
}
|
||||
}
|
||||
|
||||
// 디버깅 로그
|
||||
console.log("🔍 [ButtonPrimary] 행 선택 체크:", component.label, {
|
||||
rowSelectionSource,
|
||||
hasSelection,
|
||||
selectionCount,
|
||||
selectionSource,
|
||||
hasSplitPanelContext: !!splitPanelContext,
|
||||
selectedLeftData: splitPanelContext?.selectedLeftData,
|
||||
selectedRowsData: selectedRowsData?.length,
|
||||
selectedRows: selectedRows?.length,
|
||||
flowSelectedData: flowSelectedData?.length,
|
||||
modalStoreDataKeys: Object.keys(modalStoreData),
|
||||
});
|
||||
|
||||
// 선택된 데이터가 없으면 비활성화
|
||||
if (!hasSelection) {
|
||||
console.log("🚫 [ButtonPrimary] 행 선택 필요 → 비활성화:", component.label);
|
||||
return true;
|
||||
}
|
||||
|
||||
// 다중 선택 허용하지 않는 경우, 정확히 1개만 선택되어야 함
|
||||
if (!allowMultiRowSelection && selectionCount !== 1) {
|
||||
console.log("🚫 [ButtonPrimary] 정확히 1개 행 선택 필요 → 비활성화:", component.label, {
|
||||
selectionCount,
|
||||
allowMultiRowSelection,
|
||||
});
|
||||
return true;
|
||||
}
|
||||
|
||||
console.log("✅ [ButtonPrimary] 행 선택 조건 충족:", component.label, {
|
||||
selectionCount,
|
||||
selectionSource,
|
||||
});
|
||||
return false;
|
||||
}, [
|
||||
component.componentConfig?.action,
|
||||
@@ -526,7 +503,7 @@ export const ButtonPrimaryComponent: React.FC<ButtonPrimaryComponentProps> = ({
|
||||
dataflowTiming: component.webTypeConfig?.dataflowTiming,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
// 스타일 계산
|
||||
// height: 100%로 부모(RealtimePreviewDynamic의 내부 div)의 높이를 따라감
|
||||
// width는 항상 100%로 고정 (부모 컨테이너가 gridColumns로 크기 제어)
|
||||
@@ -699,7 +676,7 @@ export const ButtonPrimaryComponent: React.FC<ButtonPrimaryComponentProps> = ({
|
||||
// (조건부 컨테이너의 다른 섹션으로 전환했을 때 이전 컴포넌트 ID가 남아있는 경우 대응)
|
||||
if (!sourceProvider) {
|
||||
console.log(`⚠️ [ButtonPrimary] 지정된 소스 컴포넌트를 찾을 수 없음: ${dataTransferConfig.sourceComponentId}`);
|
||||
console.log(`🔍 [ButtonPrimary] 현재 화면에서 DataProvider 자동 탐색...`);
|
||||
console.log("🔍 [ButtonPrimary] 현재 화면에서 DataProvider 자동 탐색...");
|
||||
|
||||
const allProviders = screenContext.getAllDataProviders();
|
||||
|
||||
@@ -1024,9 +1001,7 @@ export const ButtonPrimaryComponent: React.FC<ButtonPrimaryComponentProps> = ({
|
||||
if (groupByColumns && groupByColumns.length > 0 && effectiveSelectedRowsData.length > 1) {
|
||||
// 첫 번째 그룹핑 컬럼 기준으로 중복 체크 (예: order_no)
|
||||
const groupByColumn = groupByColumns[0];
|
||||
const uniqueValues = new Set(
|
||||
effectiveSelectedRowsData.map((row: any) => row[groupByColumn]).filter(Boolean)
|
||||
);
|
||||
const uniqueValues = new Set(effectiveSelectedRowsData.map((row: any) => row[groupByColumn]).filter(Boolean));
|
||||
|
||||
if (uniqueValues.size > 1) {
|
||||
// 컬럼명을 한글로 변환 (order_no -> 수주번호)
|
||||
@@ -1109,10 +1084,12 @@ export const ButtonPrimaryComponent: React.FC<ButtonPrimaryComponentProps> = ({
|
||||
// 🆕 분할 패널 부모 데이터 (좌측 화면에서 선택된 데이터)
|
||||
splitPanelParentData,
|
||||
// 🆕 분할 패널 컨텍스트 (quickInsert 등에서 좌측 패널 데이터 접근용)
|
||||
splitPanelContext: splitPanelContext ? {
|
||||
selectedLeftData: splitPanelContext.selectedLeftData,
|
||||
refreshRightPanel: splitPanelContext.refreshRightPanel,
|
||||
} : undefined,
|
||||
splitPanelContext: splitPanelContext
|
||||
? {
|
||||
selectedLeftData: splitPanelContext.selectedLeftData,
|
||||
refreshRightPanel: splitPanelContext.refreshRightPanel,
|
||||
}
|
||||
: undefined,
|
||||
} as ButtonActionContext;
|
||||
|
||||
// 확인이 필요한 액션인지 확인
|
||||
@@ -1233,15 +1210,16 @@ export const ButtonPrimaryComponent: React.FC<ButtonPrimaryComponentProps> = ({
|
||||
}
|
||||
|
||||
// 🆕 최종 비활성화 상태 (설정 + 조건부 비활성화 + 행 선택 필수)
|
||||
const finalDisabled = componentConfig.disabled || isOperationButtonDisabled || isRowSelectionDisabled || statusLoading;
|
||||
const finalDisabled =
|
||||
componentConfig.disabled || isOperationButtonDisabled || isRowSelectionDisabled || statusLoading;
|
||||
|
||||
// 공통 버튼 스타일
|
||||
// 🔧 component.style에서 background/backgroundColor 충돌 방지
|
||||
const userStyle = component.style
|
||||
? Object.fromEntries(
|
||||
Object.entries(component.style).filter(
|
||||
([key]) => !["width", "height", "background", "backgroundColor"].includes(key)
|
||||
)
|
||||
([key]) => !["width", "height", "background", "backgroundColor"].includes(key),
|
||||
),
|
||||
)
|
||||
: {};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user