- 폼 옵션 아래 「집계 항목」 줄(이름 · 미지정 · [고르기] · [해제]) — 구조물 · 관 계열 하위 폼 · B05 · B06 한 코드 - 옵션 `visible:false` 는 폼에서 숨김(정의 · 옛 값 그대로) · [수정]은 폼이 그린 칸만 갈아 끼우고 안 그린 칸(상세 · 숨긴 칸) 보존 — 옵션 덮어쓰기 흠 고침 - 목록 줄 `.is-assigned` 색 · 툴팁 항목 이름 · 캐시는 지금 초안 기록 칸(structures · pipes) 안 summary_item - 미지정이면 칸을 안 실음 · 관은 서버 응답에 칸이 없으면 같은 측점에서 화면이 이어받음 - 항목 고르기 모달은 21-5 가 오기 전까지 같은 이름의 임시 함수 · Structures_Panel 700줄 넘어 옵션 그리기를 Panel_Options 로 나눔 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TULoa94ZFL26KU6ZqVpjkF
59 lines
2.6 KiB
TypeScript
59 lines
2.6 KiB
TypeScript
/* =============================================================================
|
|
* 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}`;
|
|
}
|