fix: Enhance layout loading logic in screen management
- Updated the ScreenManagementService to allow SUPER_ADMIN or users with companyCode as "*" to load layouts based on the screen's company code. - Improved layout loading in ScreenViewPage and EditModal components by implementing fallback mechanisms to ensure a valid layout is always set. - Added console warnings for better debugging when layout loading fails, enhancing error visibility and user experience. - Refactored label display logic in various components to ensure consistent behavior across input types.
This commit is contained in:
@@ -413,9 +413,28 @@ export const EditModal: React.FC<EditModalProps> = ({ className }) => {
|
||||
|
||||
// V2 없으면 기존 API fallback
|
||||
if (!layoutData) {
|
||||
console.warn("[EditModal] V2 레이아웃 없음, getLayout fallback 시도:", screenId);
|
||||
layoutData = await screenApi.getLayout(screenId);
|
||||
}
|
||||
|
||||
// getLayout도 실패하면 기본 레이어(layer_id=1) 직접 로드
|
||||
if (!layoutData || !layoutData.components || layoutData.components.length === 0) {
|
||||
console.warn("[EditModal] getLayout도 실패, getLayerLayout(1) 최종 fallback:", screenId);
|
||||
try {
|
||||
const baseLayerData = await screenApi.getLayerLayout(screenId, 1);
|
||||
if (baseLayerData && isValidV2Layout(baseLayerData)) {
|
||||
layoutData = convertV2ToLegacy(baseLayerData);
|
||||
if (layoutData) {
|
||||
layoutData.screenResolution = baseLayerData.screenResolution || layoutData.screenResolution;
|
||||
}
|
||||
} else if (baseLayerData?.components) {
|
||||
layoutData = baseLayerData;
|
||||
}
|
||||
} catch (fallbackErr) {
|
||||
console.error("[EditModal] getLayerLayout(1) fallback 실패:", fallbackErr);
|
||||
}
|
||||
}
|
||||
|
||||
if (screenInfo && layoutData) {
|
||||
const components = layoutData.components || [];
|
||||
|
||||
@@ -1440,7 +1459,7 @@ export const EditModal: React.FC<EditModalProps> = ({ className }) => {
|
||||
</div>
|
||||
</DialogHeader>
|
||||
|
||||
<div className="flex flex-1 items-center justify-center overflow-y-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-gray-300 [&::-webkit-scrollbar-track]:bg-transparent">
|
||||
<div className="flex flex-1 justify-center overflow-y-auto [&::-webkit-scrollbar]:w-2 [&::-webkit-scrollbar-thumb]:rounded-full [&::-webkit-scrollbar-thumb]:bg-gray-300 [&::-webkit-scrollbar-track]:bg-transparent">
|
||||
{loading ? (
|
||||
<div className="flex h-full items-center justify-center">
|
||||
<div className="text-center">
|
||||
@@ -1455,7 +1474,7 @@ export const EditModal: React.FC<EditModalProps> = ({ className }) => {
|
||||
>
|
||||
<div
|
||||
data-screen-runtime="true"
|
||||
className="relative bg-white"
|
||||
className="relative m-auto bg-white"
|
||||
style={{
|
||||
width: screenDimensions?.width || 800,
|
||||
// 조건부 레이어가 활성화되면 높이 자동 확장
|
||||
|
||||
@@ -2191,10 +2191,11 @@ export const InteractiveScreenViewer: React.FC<InteractiveScreenViewerProps> = (
|
||||
|
||||
// 라벨 표시 여부 계산
|
||||
const shouldShowLabel =
|
||||
!hideLabel && // hideLabel이 true면 라벨 숨김
|
||||
(component.style?.labelDisplay ?? true) &&
|
||||
!hideLabel &&
|
||||
(component.style?.labelDisplay ?? true) !== false &&
|
||||
component.style?.labelDisplay !== "false" &&
|
||||
(component.label || component.style?.labelText) &&
|
||||
!templateTypes.includes(component.type); // 템플릿 컴포넌트는 라벨 표시 안함
|
||||
!templateTypes.includes(component.type);
|
||||
|
||||
const labelText = component.style?.labelText || component.label || "";
|
||||
|
||||
|
||||
@@ -1109,7 +1109,7 @@ export const InteractiveScreenViewerDynamic: React.FC<InteractiveScreenViewerPro
|
||||
type === "v2-input" || type === "v2-select" || type === "v2-date" ||
|
||||
compType === "v2-input" || compType === "v2-select" || compType === "v2-date";
|
||||
const hasVisibleLabel = isV2InputComponent &&
|
||||
style?.labelDisplay !== false &&
|
||||
style?.labelDisplay !== false && style?.labelDisplay !== "false" &&
|
||||
(style?.labelText || (component as any).label);
|
||||
|
||||
// 라벨 위치에 따라 오프셋 계산 (좌/우 배치 시 세로 오프셋 불필요)
|
||||
|
||||
Reference in New Issue
Block a user