/* ============================================================================= * M02_MasterTemplete_UI_Side_Precombo.ts * 좌측 「일위대가」 칸(50-3 ③ · 51-4 · 134-3) — 서고 칸(`UI_Side_Library` · 716-4)에 일위대가 몫만 줌: * 종류 precombo · 그 층 목록표 고름 · 새 문서 몸 · 글. 층 단추는 페이지가 만듦(페이지 층과 따로). * 구분 · 상세구분은 문서 칸(상세 머리 · 고르기 창 거름 · `precomboClasses`) — 나무 폴더와 무관. * 문서 누름 = 편집 칸(UI_Main 종류 precombo = 일위대가 상세 모드) · 켜진 층 단추 다시 누름 = 목록표 * (`Library_List` · 생성 · 복사 · 삭제는 거기) · 그 층 주인(`owner`) · 고칠 권한(`canWrite`)은 고름에 실어 보냄. * ========================================================================== */ import type { TreeMenuItem } from "@ui/ui_template_tree"; import type { Kind } from "./M02_MasterTemplete_Api_Fetch"; import type { StructDef } from "./StructOptions/M02_SO_Def_Model"; import { tc } from "./M02_MasterTemplete_Labor_Text"; import type { Selection } from "./M02_MasterTemplete_UI_Main"; import { buildLibrarySection, type LibraryHandle, type LibraryOptions, type LibraryScope, } from "./M02_MasterTemplete_UI_Side_Library"; export type PrecomboKind = Extract; export const isPrecombo = (kind: Kind): kind is PrecomboKind => kind === "precombo"; /** 여러 구조물에 쓰는 묶음(콘크리트 · 거푸집 등) — 군마다 첫 상세구분(134-5) */ export const COMMON = "공통"; /** 사전조합 구분 · 상세구분(134-5) — 구조물군 A~G › 그 군 구조물 종류 + 「공통」(원천 `구조물정의.json` · * B05 구조물 배치와 같은 갈래 · 꺼진 종류도 넣음) */ export const precomboClasses = ( def: Pick, ): { name: string; details: string[] }[] => Object.entries(def.구조물군) .filter(([key]) => /^[A-G]$/.test(key)) .map(([key, name]) => ({ name, details: [COMMON, ...new Set(def.types.filter((t) => t.group === key).map((t) => t.name))], })); /** 사전조합 층(134-3) — 페이지 층과 따로 · `owner` null = 자기 층 */ export type PrecomboScope = LibraryScope; /** 그 층 목록표 고름(켜진 층 단추 다시 누름) */ export const precomboList = (scope: PrecomboScope): Selection => ({ layer: scope.layer, owner: scope.owner, canWrite: scope.canWrite, projectId: null, kind: "precombo", name: "", label: tc("Lib_PrecomboAll"), }); export interface PrecomboOptions { scope: () => PrecomboScope; /** 층 단추 줄(페이지가 만듦 · 그릴 때마다 새로 — 켜진 단추가 바뀜) · `add` = 「+」(720-2) */ bar: LibraryOptions["bar"]; confirmLeave: () => Promise; onOpen: (sel: Selection | null) => void; getOpen: () => Selection | null; /** 문서 줄 덧메뉴(706-1 회사에 올리기 요청) — 없거나 빈 목록이면 메뉴 없음 */ more?: (key: string, name: string) => TreeMenuItem[]; } export type PrecomboHandle = LibraryHandle; export const buildPrecomboSection = (opt: PrecomboOptions): PrecomboHandle => buildLibrarySection({ ...opt, kind: "precombo", list: precomboList, blank: (name) => ({ 이름: name, 구분: "", 상세구분: "", 단위: null, 담은로직: [] }), text: { none: tc("Lib_None"), newHere: tc("Lib_NewHere") }, });