ERP-node/frontend/lib/registry/pop-components/pop-status-bar/index.tsx

88 lines
2.5 KiB
TypeScript
Raw Normal View History

refactor(pop): status-chip을 pop-status-bar 독립 컴포넌트로 분리 + 카운트 순환 문제 수정 pop-search에 내장되어 있던 status-chip 기능을 pop-status-bar라는 독립 컴포넌트로 분리하여 재사용성과 설정 유연성을 높인다. 상태 칩 클릭 시 카운트가 왜곡되던 순환 의존 문제를 해결한다. [pop-status-bar 신규 컴포넌트] - types.ts: StatusBarConfig, StatusChipOption, hiddenMessage 등 타입 정의 - PopStatusBarComponent: all_rows 구독 + 카운트 집계 + filter_value 발행 _source: "status-bar" 마커로 자신의 필터를 식별 hideUntilSubFilter: 하위 필터 선택 전 칩 숨김 + 설정 가능 안내 문구 - PopStatusBarConfig: 설정 패널 (DB 자동 채우기, 고유값 클릭 추가, 숨김 문구 설정, 하위 필터 가상 컬럼 안내) - index.tsx: 레지스트리 등록, connectionMeta(filter_value/all_rows/set_value) [카운트 순환 문제 수정] - PopCardListV2Component: externalFilters에 _source 필드 저장 all_rows 발행 시 status-bar 소스 필터를 제외한 rowsForStatusCount 계산 상태 칩 클릭해도 전체 카운트가 유지됨 [pop-search에서 status-chip 제거] - PopSearchComponent: StatusChipInput, allRows 구독, autoSubStatusColumn 제거 - PopSearchConfig: StatusChipDetailSettings 제거, 분리 안내 메시지로 대체 - index.tsx: receivable에서 all_rows 제거 - types.ts: StatusChipStyle, StatusChipConfig에 @deprecated 주석 추가 [설정 UX 개선] - "전체 칩 자동 추가" → "전체 보기 칩 표시" + 설명 문구 추가 - hiddenMessage: 숨김 상태 안내 문구 설정 가능 (하드코딩 제거) - useSubCount 활성 시 가상 컬럼 안내 경고 표시
2026-03-11 16:35:49 +09:00
"use client";
import { PopComponentRegistry } from "../../PopComponentRegistry";
import { PopStatusBarComponent } from "./PopStatusBarComponent";
import { PopStatusBarConfigPanel } from "./PopStatusBarConfig";
import type { StatusBarConfig } from "./types";
import { DEFAULT_STATUS_BAR_CONFIG } from "./types";
function PopStatusBarPreviewComponent({
config,
label,
}: {
config?: StatusBarConfig;
label?: string;
}) {
const cfg = config || DEFAULT_STATUS_BAR_CONFIG;
const options = cfg.options || [];
const displayLabel = label || "상태 바";
return (
<div className="flex h-full w-full flex-col items-center justify-center gap-1 p-2">
<span className="text-[10px] font-medium text-muted-foreground">
{displayLabel}
</span>
<div className="flex items-center gap-1">
{options.length === 0 ? (
<span className="text-[9px] text-muted-foreground">
</span>
) : (
options.slice(0, 4).map((opt) => (
<div
key={opt.value}
className="flex flex-col items-center rounded bg-muted/60 px-2 py-0.5"
>
<span className="text-[10px] font-bold leading-tight">0</span>
<span className="text-[8px] leading-tight text-muted-foreground">
{opt.label}
</span>
</div>
))
)}
</div>
</div>
);
}
PopComponentRegistry.registerComponent({
id: "pop-status-bar",
name: "상태 바",
description: "상태별 건수 대시보드 + 필터",
category: "display",
icon: "BarChart3",
component: PopStatusBarComponent,
configPanel: PopStatusBarConfigPanel,
preview: PopStatusBarPreviewComponent,
defaultProps: DEFAULT_STATUS_BAR_CONFIG,
connectionMeta: {
sendable: [
{
key: "filter_value",
label: "필터 값",
type: "filter_value",
category: "filter",
description: "선택한 상태 칩 값을 카드에 필터로 전달",
},
],
receivable: [
{
key: "all_rows",
label: "전체 데이터",
type: "all_rows",
category: "data",
description: "연결된 카드의 전체 데이터를 받아 상태별 건수 집계",
},
{
key: "set_value",
label: "값 설정",
type: "filter_value",
category: "filter",
description: "외부에서 선택 값 설정",
},
],
},
touchOptimized: true,
supportedDevices: ["mobile", "tablet"],
});