refactor: Improve label toggling functionality in ScreenDesigner and enhance SelectedItemsDetailInputComponent

- Updated the label toggling logic in ScreenDesigner to allow toggling of labels for selected components or all components based on the current selection.
- Enhanced the SelectedItemsDetailInputComponent by implementing a caching mechanism for table columns and refining the logic for loading category options based on field groups.
- Introduced a new helper function to convert category codes to labels, improving the clarity and maintainability of the price calculation logic.
- Added support for determining the source table for field groups, facilitating better data management and retrieval.
This commit is contained in:
DDD1542
2026-02-09 10:07:07 +09:00
parent 79d8f0b160
commit bb4d90fd58
4 changed files with 252 additions and 99 deletions

View File

@@ -214,19 +214,53 @@ export function matchComponentSize(
* 모든 컴포넌트의 라벨 표시/숨기기를 토글합니다.
* 숨겨진 라벨이 하나라도 있으면 모두 표시, 모두 표시되어 있으면 모두 숨기기
*/
export function toggleAllLabels(components: ComponentData[], forceShow?: boolean): ComponentData[] {
// 현재 라벨이 숨겨진(labelDisplay === false) 컴포넌트가 있는지 확인
const hasHiddenLabel = components.some(
(c) => c.type === "widget" && (c.style as any)?.labelDisplay === false
/**
* 라벨 토글 대상 타입 판별
* label 속성이 있고, style.labelDisplay를 지원하는 컴포넌트인지 확인
*/
function hasLabelSupport(component: ComponentData): boolean {
// 라벨이 없는 컴포넌트는 제외
if (!component.label) return false;
// 그룹, datatable 등은 라벨 토글 대상에서 제외
const excludedTypes = ["group", "datatable"];
if (excludedTypes.includes(component.type)) return false;
// 나머지 (widget, component, container, file, flow 등)는 대상
return true;
}
/**
* @param components - 전체 컴포넌트 배열
* @param selectedIds - 선택된 컴포넌트 ID 목록 (빈 배열이면 전체 대상)
* @param forceShow - 강제 표시/숨기기 (지정하지 않으면 자동 토글)
*/
export function toggleAllLabels(
components: ComponentData[],
selectedIds: string[] = [],
forceShow?: boolean
): ComponentData[] {
// 대상 컴포넌트 필터: selectedIds가 있으면 선택된 것만, 없으면 전체
const targetComponents = components.filter((c) => {
if (!hasLabelSupport(c)) return false;
if (selectedIds.length > 0) return selectedIds.includes(c.id);
return true;
});
// 대상 중 라벨이 숨겨진 컴포넌트가 있는지 확인
const hasHiddenLabel = targetComponents.some(
(c) => (c.style as any)?.labelDisplay === false
);
// forceShow가 지정되면 그 값 사용, 아니면 자동 판단
// 숨겨진 라벨이 있으면 모두 표시, 아니면 모두 숨기기
const shouldShow = forceShow !== undefined ? forceShow : hasHiddenLabel;
// 대상 ID Set (빠른 조회용)
const targetIdSet = new Set(targetComponents.map((c) => c.id));
return components.map((c) => {
// 위젯 타입만 라벨 토글 대상
if (c.type !== "widget") return c;
// 대상이 아닌 컴포넌트는 건드리지 않음
if (!targetIdSet.has(c.id)) return c;
return {
...c,