Files
Aislo/M02_MasterTemplete/M02_MasterTemplete_UI_Side_Precombo.ts
T
eomsangdonandClaude Opus 5.5 e4b9b3e5a3 refactor(859-5 ②): 구조물 정의 코드 M02 StructOptions → M01_MasterData/StructOptions
- 파일 23 개 git mv · 이름 M02_SO_* → M01_SO_* · 내용 · 동작 · 화면 글 그대로
- 서버 주소 /api/m02 → /api/m01(이름만 · 10 길 · 수 469 그대로) · main.py 등록 이름 m01_so_*
- 화면 부름 = common_util_m02_call 의 call 에 base 인자(기본 /m02 · 구조물 정의만 /m01)
- import 고침 = B05 · B07 · B08 · M01 · M02 · main · 시험 · 도우미
- 소스 글자만 보던 시험 셋 지움(구조물 정의 옮김에 걸림 · 결과를 안 봄):
  test_m02_structure_options 좌측 줄 · test_m02_structure_option_groups 좌측 정의 줄 · test_136_3 M02 미리보기 단추 CSS
- test_553_5 부품 훑기 폴더 = 옮긴 자리

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-18 21:42:33 +09:00

76 lines
3.4 KiB
TypeScript

/* =============================================================================
* 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 "../M01_MasterData/StructOptions/M01_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<Kind, "precombo">;
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<StructDef, "구조물군" | "types">,
): { 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<boolean>;
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") },
});