fix: screen_layouts_pop 이중 감싸기(double-wrap) 자동 해제

getLayoutPop/saveLayoutPop에서 layout_data가 이중으로 감싸진 경우
(layout_data.layout_data.components) 자동 감지하여 내부 데이터를 추출.
13개 신규 POP 화면이 빈 화면으로 표시되던 문제 해결.
This commit is contained in:
SeongHyun Kim 2026-03-27 13:44:45 +09:00
parent 0aef19578a
commit f10946ae5b
1 changed files with 28 additions and 2 deletions

View File

@ -5957,7 +5957,21 @@ export class ScreenManagementService {
return null;
}
const layoutData = layout.layout_data;
let layoutData = layout.layout_data;
// 이중 래핑 감지 및 자동 언래핑
// layout_data 컬럼에 { version, layout_data: { components, ... } } 형태로 저장된 경우
// 실제 레이아웃은 내부 layout_data에 있으므로 언래핑한다
if (
layoutData &&
layoutData.layout_data &&
typeof layoutData.layout_data === "object" &&
!layoutData.components &&
layoutData.layout_data.components
) {
console.log(`POP 레이아웃 이중 래핑 감지 (screen_id=${screenId}), 자동 언래핑`);
layoutData = layoutData.layout_data;
}
// v1 → v2 자동 마이그레이션
if (layoutData && layoutData.version === "pop-1.0") {
@ -5994,10 +6008,22 @@ export class ScreenManagementService {
console.log(`=== POP 레이아웃 저장 (v5 그리드 시스템) ===`);
console.log(`화면 ID: ${screenId}, 회사: ${companyCode}`);
// 이중 래핑 방지: { version, layout_data: { components, ... } } 형태로 전달된 경우 언래핑
if (
layoutData &&
layoutData.layout_data &&
typeof layoutData.layout_data === "object" &&
!layoutData.components &&
layoutData.layout_data.components
) {
console.log(`저장 시 이중 래핑 감지 (screen_id=${screenId}), 자동 언래핑`);
layoutData = layoutData.layout_data;
}
// v5 그리드 레이아웃만 지원
const componentCount = Object.keys(layoutData.components || {}).length;
console.log(`컴포넌트: ${componentCount}`);
// v5 형식 검증
if (layoutData.version && layoutData.version !== "pop-5.0") {
console.warn(`레거시 버전 감지 (${layoutData.version}), v5로 변환 필요`);