- 파일 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>
46 lines
2.5 KiB
TypeScript
46 lines
2.5 KiB
TypeScript
/* =============================================================================
|
|
* M01_SO_Def_Add.ts
|
|
* 종류 더하기(PLAN 323-7) — 본보기(구조물 정본 원본 종류)를 그대로 복사한 새 종류.
|
|
*
|
|
* 키 자동(`{본보기}_xxxxxx` · 만든 뒤 안 바뀜) · 이름 「{본보기} 2」(겹치면 3 …) · 군 · 자리꼴 · 옵션 · 표시 · 그룹 ·
|
|
* 배치 · 규칙 · 종류 덧칸(동작 · 이름 표) · 반영 그대로 · `종류.{새}.본보기 = 원본` — 구조물 표가 본보기 처음값을
|
|
* 이어받고(`resolveCatalog` · 일곱 갈래 = 목록 · 횡단도 · 카드이름 · 형상 · 형상칸 · 3D · 자리꼴), 손코딩 동작 ·
|
|
* 명세도 본보기 키로 고름(`baseType`). 관 지점 정본 종류는 본보기에서 뺌(관 시설 폼 · 정본 목록이 따로).
|
|
* ========================================================================== */
|
|
|
|
import { clone, newKey, type StructDef } from "./M01_SO_Def_Model";
|
|
|
|
/** 본보기로 고를 수 있는 종류 — 구조물 정본 · 원본(본보기 아님) · [키, 이름] (정의 차례). */
|
|
export const templates = (def: StructDef): Array<[string, string]> =>
|
|
def.types
|
|
.filter((t) => !t.managed_by && !def.종류[t.type_id]?.본보기)
|
|
.map((t) => [t.type_id, t.name] as [string, string]);
|
|
|
|
/** 본보기를 복사해 그 뒤에 새 종류를 끼움 — 새 키(못 하면 null). */
|
|
export function addFromTemplate(def: StructDef, sourceId: string): string | null {
|
|
const index = def.types.findIndex((t) => t.type_id === sourceId);
|
|
const src = def.types[index];
|
|
if (!src || src.managed_by || def.종류[sourceId]?.본보기) return null;
|
|
const key = newKey(
|
|
`${sourceId}_`,
|
|
def.types.map((t) => t.type_id),
|
|
);
|
|
const names = new Set(def.types.map((t) => t.name));
|
|
let n = 2;
|
|
while (names.has(`${src.name} ${n}`)) n += 1;
|
|
const copy = clone(src);
|
|
copy.type_id = key;
|
|
copy.name = `${src.name} ${n}`;
|
|
delete copy.drawing_views; // 안 읽는 칸(323-7)
|
|
def.types.splice(index + 1, 0, copy);
|
|
def.종류[key] = { ...clone(def.종류[sourceId] ?? {}), 본보기: sourceId };
|
|
for (const table of [def.표시, def.그룹, def.배치] as Array<Record<string, unknown>>)
|
|
if (table[sourceId] !== undefined) table[key] = clone(table[sourceId]);
|
|
def.규칙.push(
|
|
...def.규칙.filter((r) => r.종류 === sourceId).map((r) => ({ ...clone(r), 종류: key })),
|
|
);
|
|
const reflect = (def as { 반영?: Record<string, unknown> }).반영;
|
|
if (reflect?.[sourceId] !== undefined) reflect[key] = clone(reflect[sourceId]);
|
|
return key;
|
|
}
|