Merge remote-tracking branch 'origin/sub_laptop_3' into sub_laptop_1

충돌 둘(Structures_List · Panel_Types)은 양쪽을 모두 살려 풂 — 측점 글은 공용 stationLabel · 집계 항목 읽기 · isB05Option · SummaryItem 을 한 벌로, 쓰지 않게 된 isB05Option 가져오기는 뺌.
This commit is contained in:
2026-09-29 12:29:53 +09:00
23 changed files with 1018 additions and 105 deletions
+58
View File
@@ -0,0 +1,58 @@
/* =============================================================================
* common_util_summary_item.ts
* 구조물 집계표 항목 참조(PLAN 21-1) — 구조물 · 관 지점이 「어느 집계표 항목」인지 가리키는 값.
*
* summary_item: { layer: "system"|"company"|"personal", owner: null|"{회사}"|"{회사}/{사용자}",
* key: "SS000004", name: "돌기슭막이 메쌓기 1.2m" }
*
* 없으면 null(= 미지정 · 집계표에 안 들어감). 옵션(options) 밖의 칸이다.
* import 없음 — 시험이 이 파일만 옮겨 돌림.
* ========================================================================== */
export type SummaryLayer = "system" | "company" | "personal";
export interface SummaryItem {
layer: SummaryLayer;
owner: string | null;
key: string;
name: string;
}
const LAYERS: readonly string[] = ["system", "company", "personal"];
/** 참조 모양이 맞는가 — 서버 응답 · 세션 초안을 읽을 때 걸러 쓴다. */
export function isSummaryItem(value: unknown): value is SummaryItem {
if (!value || typeof value !== "object") return false;
const item = value as Record<string, unknown>;
return (
typeof item.layer === "string" &&
LAYERS.includes(item.layer) &&
(item.owner === null || typeof item.owner === "string") &&
typeof item.key === "string" &&
item.key !== "" &&
typeof item.name === "string"
);
}
/** 같은 항목인가 — 층 · 주인 · 키가 같으면 같음(이름은 바뀔 수 있어 안 봄). */
export function sameSummaryItem(left: SummaryItem | null, right: SummaryItem | null): boolean {
if (!left || !right) return left === right;
return left.layer === right.layer && left.owner === right.owner && left.key === right.key;
}
/** 서버 · 세션에서 온 값을 참조 또는 null 로 — 모양이 틀리면 null(미지정). */
export function readSummaryItem(value: unknown): SummaryItem | null {
return isSummaryItem(value) ? value : null;
}
/** 표시 글 — 이름(없으면 「미지정」). 키는 앞에 내세우지 않는다(PLAN 21-0). */
export function summaryLabel(item: SummaryItem | null): string {
return item ? item.name || item.key : "미지정";
}
/** 툴팁 — 이름 + 어느 그룹 것인지 · 키는 작은 글로만. */
export function summaryTooltip(item: SummaryItem | null): string {
if (!item) return "집계 항목 미지정 — 집계표에 안 들어감";
const group = { system: "마스터", company: "회사용", personal: "개인용" }[item.layer];
return `${item.name} · ${group} · ${item.key}`;
}