- 위 · 보조 탭 줄 = 부품 탭(fillTabs · 밑줄 · 알약) · B09 좌측 스위치 = 분할 고르기 - 연결 칩 · 검사 탭 이름 · 끌기 태그 = 배지 · 이정표 도구 · 머리 줄 · 저장 줄 = 도구줄 · 구간 고침 · 행 고름 창 = 떠 있는 판 - 안내 · 빈 줄 · 상태 글 = 보조 글 · 운반 칸 = 카드 · 인쇄 미리보기 좌측 줄 = B09 dock 한 벌 · 쪽 체크 = 라디오 · 체크 부품 - 시험 흉내 틀 · 문구 맞춤 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
93 lines
3.8 KiB
TypeScript
93 lines
3.8 KiB
TypeScript
/* =============================================================================
|
|
* B09_Estimation_UI_Check.ts
|
|
* B09 좌측 「데이터 점검」 묶음(PLAN 203-1) — [업데이트] · 연결 점검(옛 「연결 점검」 탭 내용).
|
|
*
|
|
* [업데이트] = 단가를 지금 M01 값으로 새로 굳힘 · 서버가 낡았다고 보면(`payload.stale` 까닭 한 줄)
|
|
* 단추에 점 배지(`is-pending`) · 굳힌 시각 · 까닭 = 공용 호버
|
|
* 연결 점검 = 「연결 없음」 줄 목록(누르면 그 탭 그 줄로 · 까닭 = 공용 호버) + 서버 알림 · M01 에 없는 키
|
|
* ========================================================================== */
|
|
|
|
import { attachHoverInfo } from "@ui/ui_template_hover_info";
|
|
import { createBadge } from "@ui/ui_template_badge";
|
|
import { createText } from "@ui/ui_template_text";
|
|
import type { Row } from "./B09_Estimation_Calc_Base";
|
|
import { tabName, type Link, type TabId } from "./B09_Estimation_UI_Tabs";
|
|
|
|
export interface CheckItem {
|
|
link: Link;
|
|
tab: string;
|
|
name: string;
|
|
why: string;
|
|
}
|
|
|
|
/** 빠진 연결 줄 · 알림 글(서버 알림 + M01 에 없는 키) */
|
|
export function checkItems(sheets: Row, payload: Row): { items: CheckItem[]; notes: string[] } {
|
|
const gaps: Row[] = sheets.gaps || [];
|
|
const items = gaps.map((g) => ({
|
|
link: { tab: g.tab as TabId, key: g.key },
|
|
tab: tabName(g.tab),
|
|
name: String(g.name ?? ""),
|
|
why: String(g.why ?? ""),
|
|
}));
|
|
const notes: string[] = [...(payload.notes || [])];
|
|
const missing: string[] = payload.inputs?.missing || [];
|
|
if (missing.length) notes.push(`M01 에 없는 키 ${missing.length} — ${missing.join(" · ")}`);
|
|
return { items, notes };
|
|
}
|
|
|
|
/** [업데이트] 호버 글 — 굳힌 시각 + 낡은 까닭 */
|
|
export function refreshTip(payload: Row | null): string {
|
|
const made = payload?.book?.made;
|
|
const when = made ? `단가 굳힘 ${String(made).replace("T", " ")}` : "단가 아직 안 굳힘";
|
|
const stale = payload?.stale;
|
|
return `${when} · 누르면 지금 M01 값으로 새로 굳힘${stale ? ` · 업데이트 필요 — ${stale}` : ""}`;
|
|
}
|
|
|
|
export interface CheckPanel {
|
|
/** 묶음 안 연결 점검 자리 */
|
|
list: HTMLElement;
|
|
draw: (payload: Row, sheets: Row) => void;
|
|
}
|
|
|
|
export function createCheckPanel(refresh: HTMLElement, goto: (link: Link) => void): CheckPanel {
|
|
let payload: Row | null = null;
|
|
let items: CheckItem[] = [];
|
|
attachHoverInfo(refresh, () => refreshTip(payload));
|
|
const list = document.createElement("div");
|
|
list.className = "b09-check";
|
|
attachHoverInfo(list, (row) => items[Number(row.dataset.i)]?.why, "[data-i]");
|
|
|
|
const draw = (next: Row, sheets: Row): void => {
|
|
payload = next;
|
|
refresh.classList.toggle("is-pending", Boolean(next.stale));
|
|
const made = checkItems(sheets, next);
|
|
items = made.items;
|
|
const head = createText(`연결 없음 ${items.length}곳`, "muted");
|
|
head.classList.add("b09-check__head");
|
|
const rows = document.createElement("div");
|
|
rows.className = "ui-sidebar-list";
|
|
rows.append(
|
|
...items.map((item, i) => {
|
|
const row = document.createElement("button");
|
|
row.type = "button";
|
|
row.className = "ui-sidebar-row";
|
|
row.dataset.i = String(i);
|
|
const name = document.createElement("span");
|
|
name.textContent = item.name;
|
|
const tab = createBadge(item.tab, "neutral", { size: 18 });
|
|
tab.classList.add("b09-check__tab");
|
|
row.append(name, tab);
|
|
row.addEventListener("click", () => goto(item.link));
|
|
return row;
|
|
}),
|
|
);
|
|
const notes = made.notes.map((text) => {
|
|
const p = createText(text, "muted");
|
|
p.classList.add("b09-check__note");
|
|
return p;
|
|
});
|
|
list.replaceChildren(head, ...(items.length ? [rows] : []), ...notes);
|
|
};
|
|
return { list, draw };
|
|
}
|