feat(M02): 일위대가 사전조합 — 층 단추 따로 · 명시 owner · 구분 › 상세구분 2단 나무(134-3)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01SE9MxeXTu2uaDZ55BJowAY
This commit is contained in:
2026-10-09 15:01:16 +09:00
co-authored by Claude Opus 5.5
parent 15f2e7c4f5
commit 66efaf2834
16 changed files with 466 additions and 94 deletions
@@ -21,7 +21,6 @@ import "../M01_MasterData/M01_MasterData_UI_Style.css";
import {
deleteLayerTemplate,
deleteTemplate,
getActiveOwner,
listTemplates,
newLibrary,
readTemplate,
@@ -45,10 +44,14 @@ type Row = TemplateInfo & {
export interface LibraryListOptions {
layer: Layer;
/** 그 층 주인(134-3 · 사전조합 층 · null = 자기 층) */
owner: string | null;
kind: PrecomboKind;
canEdit: boolean;
/** 줄 누름 · 생성 · 복사 뒤 — 그 문서 상세 */
open: (key: string, label: string) => void;
/** 생성 · 복사 · 삭제 뒤 — 좌측 나무를 다시 그림 */
changed: () => void;
}
const SIZE = 30;
@@ -130,7 +133,9 @@ export function mountLibraryList(
const load = async (): Promise<void> => {
try {
rows = (await listTemplates(opt.layer, null)).filter((r) => r.종류 === opt.kind) as Row[];
rows = (await listTemplates(opt.layer, null, opt.owner)).filter(
(r) => r.종류 === opt.kind,
) as Row[];
} catch (error) {
rows = [];
showToast(L("M02_LoadFailed").replace("{value}", why(error)), "error");
@@ -171,10 +176,11 @@ export function mountLibraryList(
/** 새로 — 서버가 그 층 다음 키로 씀 → 그 문서 상세 */
const made = (key: string, label: string): void => {
showToast(L("M02_Created"), "success");
opt.changed();
opt.open(key, label);
};
const create = async (body: LibraryBody, label: string): Promise<void> =>
made((await newLibrary(opt.layer, opt.kind, body)).이름, label);
made((await newLibrary(opt.layer, opt.kind, body, opt.owner)).이름, label);
/** 사전조합 = 이름 + 구분 · 상세구분 처음 값 = 로직 구분 목록 첫 줄(51-12 · 상세에서 바꿈) · 빈 묶음 */
btnNew.addEventListener("click", () => {
@@ -196,14 +202,22 @@ export function mountLibraryList(
const from = rows.find((r) => r.이름 === picked);
if (!from) return;
nameDialog(L("M02_CopyTitle"), `${from.제목 ?? from.이름} (2)`, async (name) => {
const got = await newLibrary(opt.layer, opt.kind, {
본뜬: { 층: opt.layer, 주인: getActiveOwner(), 키: from.이름 },
});
const doc = await readTemplate(opt.layer, opt.kind, got.이름, null);
await saveTemplate(opt.layer, opt.kind, got.이름, null, got.판, {
...(doc.문서 as object),
이름: name,
});
const got = await newLibrary(
opt.layer,
opt.kind,
{ 본뜬: { 층: opt.layer, 주인: opt.owner, 키: from.이름 } },
opt.owner,
);
const doc = await readTemplate(opt.layer, opt.kind, got.이름, null, opt.owner);
await saveTemplate(
opt.layer,
opt.kind,
got.이름,
null,
got.판,
{ ...(doc.문서 as object), 이름: name },
opt.owner,
);
made(got.이름, name);
});
});
@@ -216,8 +230,9 @@ export function mountLibraryList(
if (!(await showConfirmDialog(L("M02_DeleteConfirm").replace("{value}", label)))) return;
try {
if (opt.layer === "system") await deleteTemplate(opt.kind, info.이름, info.판);
else await deleteLayerTemplate(opt.layer, opt.kind, info.이름, info.판);
else await deleteLayerTemplate(opt.layer, opt.kind, info.이름, info.판, opt.owner);
showToast(L("M02_Deleted"), "success");
opt.changed();
picked = null;
await load();
} catch (error) {