Files
Aislo/M01_MasterData/M01_MasterData_UI_Logic_List.ts
T
eomsangdonandClaude Opus 5 6c9ac97b29 feat(master_data): 키 개편 — 테이블ID+6자리 키 · 인력·기계 한 테이블 · 장 파일 이름
- 모든 요소·표·로직 줄의 열쇠 → 키(LB000123 꼴) · 옛 열쇠·원문 번호는 원문번호 칸 · 대장 _키대장.json (키 36,840 · 다음 번호)
- 변수 적는 법 키로 — 로직 식·연결·준용·통합·후보·조달 연결 일괄 변환 · {이름} 낀 참조는 ID:원문번호
- 인력 8 파일 → 인력.json(줄마다 조사 · 머리 조사 묶음) · 기계 2 파일 → 기계.json(세부분류)
- 소요량·계수·로직 파일 이름 = 그룹_원문_NN장_장 제목 · 머리 부문·차례
- 엔진(값 찾기 · 알림에 키 옆 이름) · check_master(키 모양·겹침·대장·끊긴 키 · 기계 요소 줄도 본문 결손 대조) · M01 서버(새 줄 키는 대장 다음 번호 · 키 못 고침) · 화면 칸 이름만 맞춤
- 로직 일괄 시험 계산 1,351 줄 — 옮기기 전후 줄마다 결과·금액 같음

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JgUhN55Z3BCYhUJTjwTNfj
2026-09-20 01:56:30 +09:00

156 lines
5.0 KiB
TypeScript

/* =============================================================================
* M01_MasterData_UI_Logic_List.ts
* 왼쪽 로직 목록 — 원문 · 장 · 이름 찾기 · 막힘만 · 막힘(⛔)·고침(●) 표시
* 거르기는 화면에서(목록은 한 번 받음 · 391 줄 남짓)
* ========================================================================== */
import { el } from "@ui/ui_template_elements";
import type { LogicSummary } from "./M01_MasterData_UI_Logic_Api";
import { tx } from "./M01_MasterData_UI_Logic_Text";
export type ListMark = "edited" | "new" | "deleted";
export interface ListItem {
id: string;
book: string;
chapter: string;
key: string;
name: string;
blocked: boolean;
reasons: string[];
}
export interface ListHandle {
root: HTMLElement;
setItems: (items: LogicSummary[]) => void;
/** 저장 안 한 새 로직도 목록 맨 위에 */
setMarks: (marks: Map<string, ListMark>, extra: ListItem[]) => void;
setActive: (id: string | null) => void;
}
export const logicId = (book: string, key: string): string => `${book}\n${key}`;
export function buildList(onOpen: (item: ListItem) => void): ListHandle {
let items: ListItem[] = [];
let extra: ListItem[] = [];
let marks = new Map<string, ListMark>();
let active: string | null = null;
const book = el("select", { className: "m01-logic__input" });
const chapter = el("select", { className: "m01-logic__input" });
const search = el("input", {
className: "m01-logic__input",
attrs: { type: "search", placeholder: tx("List_Search") },
});
const blockedOnly = el("input", { attrs: { type: "checkbox" } });
const count = el("span", { className: "m01-logic__muted" });
const list = el("ul", { className: "m01-logic__list" });
const options = (select: HTMLSelectElement, all: string, values: string[]): void => {
const keep = select.value;
select.replaceChildren(
el("option", { text: all, attrs: { value: "" } }),
...values.map((v) => el("option", { text: v, attrs: { value: v } })),
);
select.value = values.includes(keep) ? keep : "";
};
const chapters = (): void =>
options(chapter, tx("List_AllChapters"), [
...new Set(items.filter((x) => !book.value || x.book === book.value).map((x) => x.chapter)),
]);
const draw = (): void => {
const q = search.value.trim().toLowerCase();
const shown = [...extra, ...items].filter(
(x) =>
(!book.value || x.book === book.value) &&
(!chapter.value || x.chapter === chapter.value) &&
(!blockedOnly.checked || x.blocked) &&
(!q || x.key.toLowerCase().includes(q) || x.name.toLowerCase().includes(q)),
);
count.textContent = tx("List_Count", { n: shown.length });
list.replaceChildren(...shown.slice(0, 500).map(line));
};
const line = (item: ListItem): HTMLElement => {
const mark = marks.get(item.id);
const badges: HTMLElement[] = [];
if (item.blocked) {
badges.push(
el("span", {
className: "m01-logic__badge m01-logic__badge--blocked",
text: `⛔ ${tx("List_Blocked")}`,
attrs: { title: item.reasons.join("\n") },
}),
);
}
if (mark) {
const label = { edited: "List_Edited", new: "List_New", deleted: "List_Deleted" } as const;
badges.push(el("span", { className: "m01-logic__badge", text: `● ${tx(label[mark])}` }));
}
const button = el("button", {
className: `m01-logic__item${item.id === active ? " is-active" : ""}`,
attrs: { type: "button", title: item.key },
children: [
el("span", { className: "m01-logic__muted", text: `${item.book} ${item.chapter}` }),
el("span", { text: item.name || item.key }),
el("span", { className: "m01-logic__badges", children: badges }),
],
});
button.addEventListener("click", () => onOpen(item));
return el("li", { children: [button] });
};
book.addEventListener("change", () => {
chapters();
draw();
});
chapter.addEventListener("change", draw);
search.addEventListener("input", draw);
blockedOnly.addEventListener("change", draw);
const root = el("aside", {
className: "m01-logic__side",
children: [
el("div", {
className: "m01-logic__filters",
children: [
book,
chapter,
search,
el("label", {
className: "m01-logic__check",
children: [blockedOnly, el("span", { text: tx("List_BlockedOnly") })],
}),
count,
],
}),
list,
],
});
return {
root,
setItems: (logics) => {
items = logics.map((x) => ({
id: logicId(x.book, x.),
book: x.book,
chapter: x.chapter,
key: x.키,
name: x.이름,
blocked: x.blocked,
reasons: x.reasons,
}));
options(book, tx("List_AllBooks"), [...new Set(items.map((x) => x.book))]);
chapters();
draw();
},
setMarks: (next, more) => {
marks = next;
extra = more;
draw();
},
setActive: (id) => {
active = id;
draw();
},
};
}