feat(m01-sl): Entry 를 SL 이름(slList · newLogic · SheetLogic)으로 맞춤

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016PSXsvyDxjNmufteN5bqmt
This commit is contained in:
2026-10-01 13:01:58 +09:00
co-authored by Claude Opus 5.5
parent 67ae40f161
commit 913f04998e
+34 -7
View File
@@ -17,6 +17,8 @@ import {
} from "@ui/ui_template_elements";
import { openModal } from "@ui/ui_template_modal";
import { listEasy, plainError, type EasyListItem } from "../EasyCalc/M01_EasyCalc_Api";
import { slList, type SlListItem } from "./M01_SL_Api";
import { newLogic, type SheetLogic } from "./M01_SL_Model";
import "./M01_SL_Entry.css";
const TEXT = {
@@ -74,6 +76,16 @@ const amountOf = (resultUnit: string): string => {
};
const isMoney = (resultUnit: string): boolean => resultUnit.startsWith("원/");
/* ponytail: SL Api(sub4) · Model(sub7) 속이 「준비 중」 인 동안만 대신함 — 채워지면 두 catch 를 지움 */
const loadMine = (): Promise<SlListItem[]> => slList().catch(() => []);
const blankLogic = (name: string, unit: string): SheetLogic | null => {
try {
return newLogic(name, unit);
} catch {
return null;
}
};
/** 「로직 만들기(시험)」 옆에 놓는 단추 — 누르면 큰 창 */
export function createSheetLogicButton(): HTMLButtonElement {
return createButton({ label: te("Open"), variant: "filled", onClick: openSheetLogic });
@@ -82,7 +94,7 @@ export function createSheetLogicButton(): HTMLButtonElement {
function openSheetLogic(): void {
let body: HTMLElement;
/** 고치는 화면이 열려 있을 때만 */
let paper: { dirty(): boolean } | null = null;
let paper: { dirty(): boolean; sl: SheetLogic | null } | null = null;
let logics: EasyListItem[] | null = null;
let query = "";
@@ -110,15 +122,30 @@ function openSheetLogic(): void {
return row;
};
const mineRow = (item: SlListItem): HTMLElement => {
const row = el("button", {
className: "m01-sl__item",
attrs: { type: "button" },
children: [
el("span", { className: "m01-sl__item-name", text: item.이름 }),
el("span", { className: "m01-sl__item-unit", text: item.결과단위 }),
],
});
row.addEventListener("click", notYet);
return row;
};
const showStart = async (): Promise<void> => {
paper = null;
const status = el("p", { className: "m01-sl__muted", text: te("Loading") });
const trialHost = el("div", { className: "m01-sl__list" });
const foundHost = el("div", { className: "m01-sl__list" });
const mineHost = el("div", {
className: "m01-sl__list",
children: [muted(te("Start_MineNone"))],
});
const mineHost = el("div", { className: "m01-sl__list" });
void loadMine().then((mine) =>
mineHost.replaceChildren(
...(mine.length ? mine.map(mineRow) : [muted(te("Start_MineNone"))]),
),
);
const search = createInputField({
type: "search",
placeholder: te("Start_Search"),
@@ -207,7 +234,8 @@ function openSheetLogic(): void {
const showPaper = (): void => {
let dirty = false;
paper = { dirty: () => dirty };
const units = unitChoices();
paper = { dirty: () => dirty, sl: blankLogic("", units[0]) };
const unsaved = createTag(te("Unsaved"), "warning");
unsaved.hidden = true;
@@ -221,7 +249,6 @@ function openSheetLogic(): void {
onInput: touched,
});
name.root.classList.add("m01-sl__name");
const units = unitChoices();
const unit = createSelectField({
label: te("Unit"),
options: units.map((u) => ({ value: u, text: u.replace(/^원\//, "") })),