fix(860-2): 이름 100 자 · 나무 줄 한 줄 말줄임 — 157 자 이름이 저장되고 나무 줄이 열 줄로 접히던 것

- 값 한 곳 = 파이썬 M02_MasterTemplete_Tree.MAX_NAME 100(60 → 100) ↔ TS ui_template_input NAME_MAX(짝 · 거울 시험)
- 서버 저장 길 — 폴더 · 항목(tree._name) · 서고 문서 단가산출 · 사전조합(store.write → check_name) · 내 기계(clean) · 내 재료(_checked) 101 자 = 400 · 422
- 화면 입력 칸 — createInputField maxLength(넘친 글 자르고 칸 아래 「… 100자까지」) · 서고 이름 창 · 새 항목 창 · 새 단가산출 창 · 고르기 창 · 내 재료 · 내 기계 이름 칸
- 공용 나무 줄 글 = 한 줄 「…」 · 마우스 = 온 이름(ui_template_tree)
- 시험 test_860_2_name_max(새) · test_m02_tree 긴 이름 61 → 101 · test_m02_tree_paste 의 「항목 추가 창 카드 격자 표 접기」 지움(소스 글자 대조뿐 — 결과를 안 봄)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-19 10:18:49 +09:00
co-authored by Claude Opus 5.5
parent 73f1b6b44f
commit d9597899d7
16 changed files with 151 additions and 41 deletions
+2 -2
View File
@@ -13,7 +13,7 @@
import { API_BASE_URL } from "@config/config_frontend";
import { setUiDiff } from "@ui/ui_template_button";
import { attachCollapsible, createPanelCard } from "@ui/ui_template_collapsible";
import { createInputField, createSelectField, el } from "@ui/ui_template_elements";
import { createInputField, createSelectField, el, NAME_MAX } from "@ui/ui_template_elements";
import { createFindList } from "@ui/ui_template_find_list";
import { t as L } from "@ui/ui_template_locale";
import { attachPickSearch } from "@ui/ui_template_pick_search";
@@ -403,7 +403,7 @@ export function createMachineSheet(o: MachineSheetOptions) {
was: string,
set: (v: string) => void,
): HTMLElement => {
const f = createInputField({ label: lab, value: get, size: 28 });
const f = createInputField({ label: lab, value: get, size: 28, maxLength: NAME_MAX });
f.input.readOnly = ro;
setUiDiff(f.input, get !== was ? "mine" : null); // 848-3 저장 안 한 바뀜 = 파랑
f.input.addEventListener("input", () => {
@@ -12,6 +12,7 @@ import {
createButton,
createInputField,
el,
NAME_MAX,
showConfirmDialog,
showToast,
} from "@ui/ui_template_elements";
@@ -105,7 +106,11 @@ export const nameDialog = (
start: string,
onOk: (name: string) => Promise<void>,
): void => {
const name = createInputField({ label: L("M02_Name"), placeholder: L("M02_Name") });
const name = createInputField({
label: L("M02_Name"),
placeholder: L("M02_Name"),
maxLength: NAME_MAX,
});
name.input.value = start;
openModal({
title,
@@ -137,6 +137,13 @@ def read(kind: str, name: str) -> dict[str, Any]:
return {"종류": kind, "이름": name, "판": version_of(raw), "문서": json.loads(raw)}
def check_name(name: Any, what: str = "이름") -> None:
"""화면에서 받는 이름 길이 — 서고 문서 · 내 기계 · 내 재료(폴더 = `tree._name`) · 값 = `tree.MAX_NAME`."""
size = len(name.strip()) if isinstance(name, str) else 0
if size > tree.MAX_NAME:
raise StoreError(400, f"{what}은 {tree.MAX_NAME}자까지 — 지금 {size}자")
def _check_skeleton(kind: str, doc: Any) -> None:
"""빈 문서·뼈대 없는 문서는 거절 — 층 저장과 같은 규칙(`layers.check_skeleton`)."""
try:
@@ -167,6 +174,7 @@ def write(kind: str, name: str, version: str, doc: Any, screen: bool = False) ->
doc, cancels = area_table.apply_cancels(name, doc)
_check_skeleton(kind, doc)
if kind in layers.LIBRARY_KINDS: # 서고 문서 키 = 파일 이름(50-3)
check_name(doc.get("이름"))
doc = {**doc, "키": name}
origins = _take_origins(doc) if kind == "table" else {}
if kind == "table" and name == STRUCTURE_TABLE:
@@ -20,7 +20,9 @@ from typing import Any
MIN_LEVELS = 4 # 옛 약속 — 종류 · 분류1 · 분류2 · 분류3
_OLD_NAMES = ("종류", "분류1", "분류2", "분류3")
OPS = ("add-folder", "add-item", "rename", "move", "delete")
MAX_NAME = 60
#: 이름 글자 수 상한 — 폴더 · 항목 · 서고 문서 · 내 기계 · 내 재료(`store.check_name`)
#: 짝 = TS `ui_template/ui_template_input.ts` `NAME_MAX`(거울 시험 test_860_2_name_max)
MAX_NAME = 100
_BAD = re.compile(r"[\x00-\x1f]")
@@ -4,7 +4,13 @@
* 모두 약속(Promise)으로 답함 — 닫기 · Esc · 바깥 누르기 = 취소(null / "cancel").
* ========================================================================== */
import { createButton, createInputField, createSelectField, el } from "@ui/ui_template_elements";
import {
createButton,
createInputField,
createSelectField,
el,
NAME_MAX,
} from "@ui/ui_template_elements";
import { t as L } from "@ui/ui_template_locale";
import { openModal } from "@ui/ui_template_modal";
@@ -37,7 +43,7 @@ export function askText(
mount: (body, close) => {
const inputs = fields.map((f) => ({
f,
field: createInputField({ label: f.label, value: f.value }),
field: createInputField({ label: f.label, value: f.value, maxLength: NAME_MAX }),
}));
const ok = createButton({ label: okLabel, variant: "filled" });
const submit = (): void => {
@@ -96,7 +102,9 @@ export function askNewItem(opt: {
dialogClass: "m02-modal m02-treedlg",
beforeClose: () => (finish(null), true),
mount: (body, close) => {
const kind = opt.at.length ? null : createInputField({ label: L("M02_NewItemKind") });
const kind = opt.at.length
? null
: createInputField({ label: L("M02_NewItemKind"), maxLength: NAME_MAX });
if (kind) {
const list = el("datalist", {
attrs: { id: `m02-kinds-${Date.now()}` },
@@ -111,7 +119,7 @@ export function askNewItem(opt: {
text: L("M02_NewItemAt").replace("{value}", opt.at.join(" / ")),
})
: null;
const name = createInputField({ label: L("M02_TreeItemName") });
const name = createInputField({ label: L("M02_TreeItemName"), maxLength: NAME_MAX });
const ok = createButton({ label: L("M02_TreeOk"), variant: "filled" });
const need = (field: typeof name, label: string): boolean => {
const empty = !field.input.value.trim();
+1
View File
@@ -97,6 +97,7 @@ def _checked(body: dict[str, Any], others: list[dict[str, Any]]) -> dict[str, An
row = {k: _text(body.get(k)) for k in COLS}
if not row["이름"] or not row["단위"]:
raise store.StoreError(400, "품명 · 단위는 꼭 적음")
store.check_name(row["이름"], "품명")
row["값"] = _value(body.get("값"))
if any(all(_norm(x.get(k)) == _norm(row[k]) for k in COLS) for x in others):
raise store.StoreError(409, f"이미 있는 자재 「{row['이름']} {row['규격']}」")
+7 -2
View File
@@ -8,7 +8,7 @@
* 모양(`m02-pick*`)은 `M02_MasterTemplete_Structure.css`.
* ========================================================================== */
import { createButton, createInputField, el, showToast } from "@ui/ui_template_elements";
import { createButton, createInputField, el, NAME_MAX, showToast } from "@ui/ui_template_elements";
import { openModal } from "@ui/ui_template_modal";
import { searchMaterials } from "../M01_MasterData/M01_MasterData_Api_Fetch";
import { addMyMaterial, listMyMaterials, type MyMaterial } from "./M02_MyMaterial_Api";
@@ -188,7 +188,12 @@ function newForm(
back: () => void,
backLabel: string = TEXT.back,
): HTMLElement {
const name = createInputField({ label: TEXT.name, value: seed, required: true });
const name = createInputField({
label: TEXT.name,
value: seed,
required: true,
maxLength: NAME_MAX,
});
const spec = createInputField({ label: TEXT.spec });
const price = createInputField({ label: TEXT.price, type: "number", min: 0 });
let unit = "";
+1
View File
@@ -289,6 +289,7 @@ def clean(raw: Any) -> dict[str, Any]:
name, spec = str(raw.get("이름") or "").strip(), str(raw.get("규격") or "").strip()
if not name:
raise _bad("이름 없음")
store.check_name(name)
how = raw.get("방식") or EASY
if how not in (EASY, BOOK, DIRECT):
raise _bad("방식은 바로 · 품셈 · 직접")
+8 -2
View File
@@ -11,7 +11,13 @@
import { createButton } from "@ui/ui_template_button";
import { createDataTable } from "@ui/ui_template_data_table";
import { createInputField, el, showConfirmDialog, showToast } from "@ui/ui_template_elements";
import {
createInputField,
el,
NAME_MAX,
showConfirmDialog,
showToast,
} from "@ui/ui_template_elements";
import { createText } from "@ui/ui_template_text";
import { createUnitPick, NO_UNIT } from "@ui/ui_template_unit_pick";
import { StaleError } from "./M02_MasterTemplete_Api_Fetch";
@@ -67,7 +73,7 @@ export function buildMyMaterialBlock(opt: MyMaterialBlockOptions): HTMLElement {
rows: [],
onRowClick: (i) => canWrite && open(rows[i]),
});
const name = createInputField({ label: TEXT.name, required: true });
const name = createInputField({ label: TEXT.name, required: true, maxLength: NAME_MAX });
const spec = createInputField({ label: TEXT.spec });
const price = createInputField({ label: TEXT.value, type: "number", min: 0 });
const unitHost = el("span");
+67
View File
@@ -0,0 +1,67 @@
# -*- coding: utf-8 -*-
"""이름 100 자(PLAN 860-2 ⑦) — 서버 저장 길이 101 자 이름을 막고 100 자는 받는지 · 화면 값과 같은지.
폴더(`tree._name`) · 서고 문서(`store.write` → 단가산출 · 사전조합) · 내 기계 · 내 재료.
값 한 곳 = 파이썬 `M02_MasterTemplete_Tree.MAX_NAME` ↔ TS `ui_template_input.ts` `NAME_MAX`(거울).
"""
import json
import os
import subprocess
import pytest
from M02_MasterTemplete import M02_Labor_Ref as refs
from M02_MasterTemplete import M02_Material_Own as material
from M02_MasterTemplete import M02_MasterTemplete_Store as store
from M02_MasterTemplete import M02_MasterTemplete_Tree as tree
from M02_MasterTemplete import M02_MyMachine as machine
from resources.tester.test_m02_labor_ref import world # noqa: F401 — 임시 층 fixture
HERE = os.path.dirname(os.path.abspath(__file__))
ROOT = os.path.dirname(os.path.dirname(HERE))
OK, LONG = "가" * 100, "가" * 101
def test_폴더_이름_100자까지():
assert tree._name(OK) == OK
with pytest.raises(tree.TreeError) as got:
tree._name(LONG)
assert got.value.status == 422
def test_서고_문서_이름_100자까지(world): # noqa: F811
with store.at(world["system"]):
key = refs.create("precombo", {"이름": OK, "단위": "㎡", "담은로직": []})["이름"]
assert json.loads((world["system"] / "precombo" / f"{key}.json").read_bytes())["이름"] == OK
with pytest.raises(store.StoreError) as got:
refs.create("precombo", {"이름": LONG, "단위": "㎡", "담은로직": []})
assert got.value.status == 400 and "100자까지" in str(got.value.detail)
def test_내_기계_내_재료_이름_100자까지():
with pytest.raises(store.StoreError) as got:
machine.clean({"이름": LONG, "규격": ""})
assert got.value.status == 400
with pytest.raises(store.StoreError) as got:
material._checked({"이름": LONG, "단위": "개"}, [])
assert got.value.status == 400 and "품명" in str(got.value.detail)
def test_화면_값과_서버_값이_같음():
script = r"""
const path = require("path");
const { makeLoader } = require(path.join(process.argv[1], "helper_ts_stub_loader.cjs"));
const { load } = makeLoader({ root: path.join(process.argv[1], "..", "..") });
process.stdout.write(String(load("ui_template", "ui_template_input.ts").NAME_MAX));
"""
proc = subprocess.run(
["node", "-e", script, HERE],
capture_output=True,
text=True,
encoding="utf-8",
timeout=60,
cwd=ROOT,
)
assert proc.returncode == 0, proc.stderr
assert int(proc.stdout) == tree.MAX_NAME == 100
+1 -1
View File
@@ -145,7 +145,7 @@ def test_빈_층에서_폴더_항목_깊이_1_2_5_이름_옮기기_지우기(wor
for bad in (
{"op": "grow"},
{"op": "add-item", "이름": " "},
{"op": "add-item", "이름": "x" * 61},
{"op": "add-item", "이름": "x" * 101},
):
t.do(422, **bad)
t.do(404, op="rename", 키="SS999999", 이름="x")
-25
View File
@@ -136,31 +136,6 @@ def test_항목_추가_일위대가_단위_없이(world):
assert doc["담은로직"] == [] and doc["자재"] == [] and doc["일위대가번"].startswith("SU")
def test_항목_추가_창_카드_격자_표_접기():
"""PLAN 31-2 화면 — 창 = 종류(있는 것 · 새 이름 · 고른 폴더면 안 물음) + 이름 ·
일위대가 줄 없음(39-1d) · 단위 칸 없음 · 카드 2행 2열 · 높이 고정 · 넘치면 카드 ·
상세 칸 스크롤 · 제목 눌러 표 접힘."""
from pathlib import Path
m02 = Path(__file__).resolve().parents[2] / "M02_MasterTemplete"
dlg = (m02 / "M02_MasterTemplete_TreePanel_Dialogs.ts").read_text("utf-8")
assert (
"export function askNewItem(" in dlg and 'kind.input.setAttribute("list", list.id);' in dlg
)
assert "const kind = opt.at.length ? null :" in dlg and "M02_TreeUnit" not in dlg
panel = (m02 / "M02_MasterTemplete_TreePanel.ts").read_text("utf-8")
assert "일위대가:" not in panel and "pickCombo" not in panel + dlg # 39-1d — 고르기 줄 없음
assert "askNewItem({" in panel and "M02_TreeUnit" not in panel
css = (m02 / "M02_MasterTemplete_Structure.css").read_text("utf-8")
assert "grid-template-columns: repeat(3, minmax(0, 1fr));" in css # 카드 셋 3열(40-2)
assert "grid-auto-rows: var(--m02-struct-card-h);" in css
assert "--m02-struct-card-h: min(640px, 70vh);" in css # 31-6 화면 높이에 맞춤
assert "flex: 1 0 var(--m02-struct-grid-min);" in css # 엑셀 격자가 카드 높이를 채움
assert "max-height: calc(100dvh - var(--app-header-h));\n overflow-y: auto;" in css
main = (m02 / "M02_MasterTemplete_UI_Main.ts").read_text("utf-8")
assert "host.hidden = !host.hidden;" in main and 'title.classList.toggle("is-folded"' in main
def test_복사_생성_이름_원래_이름_복사_같은_이름_둘_없음(world):
"""701-4 — 복사 생성(대상 `복사이름`) = 「원래 이름 복사」 · 또 하면 「… 복사(1)」 · 그냥 붙여넣기는 그대로."""
company = _company(world)
+22
View File
@@ -18,6 +18,10 @@ import { el } from "./ui_template_elements_base";
import { fixJosa } from "./ui_template_josa";
import "./ui_template_input.css";
/** 이름 글자 수 상한 — 서고 폴더 · 단가산출 · 일위대가 · 내 기계 · 내 재료 이름 칸(`maxLength: NAME_MAX`)
* 짝 = 파이썬 `M02_MasterTemplete_Tree.MAX_NAME`(서버 저장 길 검사 · 거울 시험 test_860_2_name_max) */
export const NAME_MAX = 100;
export interface InputFieldOptions {
/** 라벨 텍스트 (i18n 결과) */
label?: string;
@@ -38,6 +42,8 @@ export interface InputFieldOptions {
unit?: string;
/** 여러 줄 — textarea(줄 수) */
multiline?: number;
/** 글자 수 상한 — 넘친 글은 잘라 두고 칸 아래 알림(이름 칸 = `NAME_MAX`) */
maxLength?: number;
}
export interface InputFieldHandle {
@@ -104,6 +110,22 @@ export function createInputField(opts: InputFieldOptions): InputFieldHandle {
}
};
const max = opts.maxLength;
if (max) {
// 한글 조합 중엔 두고 조합이 끝난 뒤 자름 · 알림은 부르는 쪽 「입력 = 알림 지움」 뒤에 남게 다음 차례에
const clip = (): void => {
if (input.value.length <= max) return;
input.value = input.value.slice(0, max);
window.setTimeout(() =>
setError(`${opts.label ?? "이름"} 은(는) ${max}자까지 — 넘친 글은 잘림`),
);
};
input.addEventListener("input", (event) => {
if (!(event as InputEvent).isComposing) clip();
});
input.addEventListener("compositionend", clip);
}
return { root, input, setError };
}
+2 -1
View File
@@ -5,7 +5,7 @@
* [확인] = 머리 [닫기] 왼쪽 · [취소] 없음(머리 [닫기] = 취소 · 147-2).
* ========================================================================== */
import { createButton, createInputField, el } from "./ui_template_elements";
import { createButton, createInputField, el, NAME_MAX } from "./ui_template_elements";
import { openModal } from "./ui_template_modal";
export interface AskField {
@@ -52,6 +52,7 @@ export function askFields(opts: AskOptions): Promise<Record<string, string> | nu
label: field.label,
value: field.value ?? "",
placeholder: field.placeholder,
maxLength: NAME_MAX,
}),
}));
const submit = (): void => {
+9
View File
@@ -22,6 +22,15 @@
display: inline-flex;
align-items: center;
min-width: 0;
overflow: hidden;
}
/* 줄 글 = 한 줄 · 넘치면 「…」(긴 이름이 줄을 여러 줄로 접어 목록을 밀지 않게) · 온 이름 = 줄 title */
.ui-tree__text {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.ui-tree__icon {
+2 -2
View File
@@ -134,7 +134,7 @@ export function createTreeRow(
children: [
el("span", { className: "ui-tree__caret", text: caret }),
icon,
el("span", { text: node.label }),
el("span", { className: "ui-tree__text", text: node.label }),
],
}),
...(node.count === null
@@ -143,7 +143,7 @@ export function createTreeRow(
],
});
button.style.paddingLeft = `calc(var(--spacing-8) + ${depth} * var(--spacing-16))`;
if (node.tip) button.title = node.tip;
button.title = node.tip ?? node.label; // 한 줄 말줄임 — 마우스 = 온 이름
button.addEventListener("click", onClick);
button.addEventListener("contextmenu", (event) => {
const items = node.menu?.() ?? [];