Merge remote-tracking branch 'origin/main_laptop_1' into sub_laptop_6

This commit is contained in:
2026-09-30 20:25:12 +09:00
9 changed files with 211 additions and 14 deletions
@@ -33,6 +33,7 @@ import {
getActiveLayer,
readTemplate,
type StructureNumbers,
type TreeEdit,
} from "./M02_MasterTemplete_Api_Fetch";
import {
createItemCards,
@@ -221,6 +222,18 @@ export function comboMerge<T>(stored: unknown, edited: T): T {
} as unknown as T;
}
/** 표 머리 이름 칸 고침 → 나무 이름 바꾸기(PLAN 31-1 · 한 정본 = 나무) — 칸이 항목 이름(가장 깊은 칸)이면
* 항목(열 id 로 부름) · 위 칸이면 그 폴더(머리 앞마디 경로). */
export function headRenameEdit(col: StructureColumn, level: number, name: string): TreeEdit {
const named = (parts: (string | null)[]): string[] =>
parts.filter((p): p is string => !!p && p.trim() !== "");
const path = named(col.머리);
const upto = named(col.머리.slice(0, level + 1));
return upto.length >= path.length
? { op: "rename", 경로: path.slice(0, -1), 키: col.id, 이름: name }
: { op: "rename", 경로: upto, 이름: name };
}
/** 구조물 이름 + 변수값 — 제목행 층을 빈칸으로 이음(빈 층은 건너뜀 · 다 비면 열 id) */
export const columnHead = (col: StructureColumn): string =>
col.머리.filter((part): part is string => !!part && part.trim() !== "").join(" ") || col.id;
@@ -110,6 +110,8 @@ export interface TreePanelHandle {
select: (colId: string | null) => void;
/** 「새 항목」 — 고른 폴더 안(없으면 맨 위)에 항목 추가 창 */
newItem: () => void;
/** 표 머리에서 온 나무 고침(이름 바꾸기 · PLAN 31-1) — 메뉴 고침과 같은 길(저장 물음 · 막힘 안내 · 다시 그림) */
editFromTable: (body: TreeEdit, colId: string | null) => Promise<void>;
}
const why = (error: unknown): string => (error instanceof Error ? error.message : "");
@@ -685,5 +687,8 @@ export function createTreePanel(opt: TreePanelOptions): TreePanelHandle {
void addItem(at?.kind === "folder" ? at.path : []);
};
return { root, search: search.root, add: tools, refresh, select, newItem };
const editFromTable = async (body: TreeEdit, colId: string | null): Promise<void> => {
if (opt.canEdit && (await ready())) await edit(body, colId);
};
return { root, search: search.root, add: tools, refresh, select, newItem, editFromTable };
}
@@ -118,6 +118,8 @@ export interface MainExtras {
search?: HTMLElement;
newItem?: HTMLElement;
onColumn?: (column: string | null) => void;
/** 구조물 조합 표 머리 이름 칸 고침 → 나무 이름 바꾸기(쓸 수 있는 층만 · PLAN 31-1) */
onHeadRename?: (col: StructureColumn, level: number, name: string) => void;
}
/** 상세 제목 줄 오른쪽 끝 「새 …」 단추 — 공용 모양 `m02-main__new`(일위대가 「새 조합」과 같게 · 30-5) */
@@ -402,6 +404,16 @@ export function createMain(
drawingLabel: (colId: string) => struct.numbers()[colId]?.도번 ?? "",
areaLabel: (colId: string) => struct.numbers()[colId]?.면적번 ?? "",
materialLabel: (colId: string) => struct.numbers()[colId]?.재료번 ?? "",
combo: {
...(readOnly || !extras.onHeadRename
? {}
: {
onHeadEdit: (colId: string, level: number, name: string) => {
const col = columns().find((c) => c.id === colId);
if (col) extras.onHeadRename?.(col, level, name);
},
}),
},
onSelect: (s: { colId: string | null }) => {
struct.show(s.colId, columns());
extras.onColumn?.(s.colId);
@@ -28,7 +28,11 @@ import {
type Root,
} from "./M02_MasterTemplete_Layer";
import { buildLaborLibrary, buildLaborSection } from "./M02_MasterTemplete_Labor";
import { STRUCTURE_TABLE } from "./M02_MasterTemplete_Structure";
import {
headRenameEdit,
STRUCTURE_TABLE,
type StructureColumn,
} from "./M02_MasterTemplete_Structure";
import { createTreePanel } from "./M02_MasterTemplete_TreePanel";
import {
companyOwner,
@@ -135,6 +139,13 @@ export async function renderM02MasterTemplate(root: HTMLElement): Promise<Mounte
readOnlyBar?.setColumn(column);
tree.select(column);
},
// 표 머리 이름 칸 고침 = 나무 이름 바꾸기(31-1) · 쓸 수 있는 층만
...(canEdit(layer, isAdmin)
? {
onHeadRename: (col: StructureColumn, level: number, name: string) =>
void tree.editFromTable(headRenameEdit(col, level, name), col.id),
}
: {}),
},
);
// 첫 화면 · 닫은 뒤(양식 지움 · 자재 조합 상세 닫음) = 구조물집계표 — 빈 화면 없음