feat(M01): 새로 만들기 모달에 새 길 잇기 — 절 목록으로 원문 절 고르기 · 절로 표 거르기 · 표 조건 값 목록 · 초안 시험 계산 · 자체 로직 저장(GX) · 본떠 만들기
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WRFJmmhPi4exAzHgPZHMT
This commit is contained in:
@@ -0,0 +1,62 @@
|
||||
/* =============================================================================
|
||||
* M01_MasterData_UI_Logic_Wizard_Copy.ts
|
||||
* 본떠 만들기 — 이미 있는 로직(정본·자체)을 찾아 새 이름으로 복제(`POST /logic/copy`) · 키 GX 는 서버가 붙임
|
||||
* ========================================================================== */
|
||||
|
||||
import { createButton, createInputField, el, showToast } from "@ui/ui_template_elements";
|
||||
import { copyLogic, searchLogics, type LogicBrief } from "./M01_MasterData_UI_Logic_Wizard_Api";
|
||||
import { tw } from "./M01_MasterData_UI_Logic_Wizard_Text";
|
||||
import { fail } from "./M01_MasterData_UI_Logic_Wizard_Ui";
|
||||
|
||||
export function copyBox(done: (key: string) => void): HTMLElement {
|
||||
const find = createInputField({ placeholder: tw("Copy_Find"), type: "search" });
|
||||
const list = el("div", { className: "m01w__found" });
|
||||
const name = createInputField({ placeholder: tw("Copy_Name"), type: "text" });
|
||||
let from: LogicBrief | null = null;
|
||||
const go = createButton({
|
||||
label: tw("Copy_Do"),
|
||||
disabled: true,
|
||||
onClick: () => {
|
||||
if (!from) return;
|
||||
const target = from;
|
||||
void copyLogic(target.키, name.input.value.trim() || `${target.이름} (수정)`)
|
||||
.then((made) => {
|
||||
showToast(tw("Copy_Done"), "success");
|
||||
done(made.key);
|
||||
})
|
||||
.catch(fail);
|
||||
},
|
||||
});
|
||||
let timer = 0;
|
||||
find.input.addEventListener("input", () => {
|
||||
window.clearTimeout(timer);
|
||||
timer = window.setTimeout(() => {
|
||||
const q = find.input.value.trim();
|
||||
if (!q) return list.replaceChildren();
|
||||
void searchLogics(q)
|
||||
.then((r) =>
|
||||
list.replaceChildren(
|
||||
...r.logics.slice(0, 8).map((l) => {
|
||||
const row = el("button", {
|
||||
className: "m01w__row",
|
||||
attrs: { type: "button", "data-copy": l.키 },
|
||||
text: `${l.원문번호} ${l.이름} · ${l.결과단위} · ${l.키}`,
|
||||
});
|
||||
row.addEventListener("click", () => {
|
||||
from = l;
|
||||
name.input.value = `${l.이름} (수정)`;
|
||||
go.disabled = false;
|
||||
list.replaceChildren(row);
|
||||
});
|
||||
return row;
|
||||
}),
|
||||
),
|
||||
)
|
||||
.catch(fail);
|
||||
}, 250);
|
||||
});
|
||||
return el("div", {
|
||||
className: "m01w__card",
|
||||
children: [el("h4", { text: tw("Copy_Title") }), find.root, list, name.root, go],
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user