fix(860-2): 일위대가 [저장] 빈 이름 · 단위 막음 — 서버 400 전에 칸 초점 · 칸 글 · 토스트 · 화면 줄 그대로

- 일위대가 서고(사전조합) 상세 · 일위대가 줄 모달: 이름 빔 = 이름 칸 글 · 줄 있고 단위 빔 = 단위 칸 아래 글 · 단위 단추 초점
- 그 밖 서버 거절(4xx)은 있던 대로 「저장 못 함 — 까닭」 토스트 · 화면 문서 그대로(가짜 400 으로 확인)
- 구조물 조합 일위대가(단위 선택 아님)는 검사 없음

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-19 09:50:56 +09:00
co-authored by Claude Opus 5.5
parent 54fbb0faa4
commit df80ecd3cd
5 changed files with 31 additions and 2 deletions
@@ -50,6 +50,8 @@ export interface LaborDetailHandle {
/** [엑셀에서 고르기]로 바뀐 면적산출 문서를 저장(일위대가 [저장] 앞) · 저장했으면 참(없으면 거짓) —
* 서버가 면적 저장 때 그 열 일위대가 계산값을 다시 적어 일위대가 판이 바뀜 → 부르는 쪽이 판을 다시 읽음 */
saveArea: () => Promise<boolean>;
/** [저장] 앞 필수 칸(860-2 ① · 일위대가 서고 = 이름 · 줄 있으면 단위) — 빈 칸이면 초점 · 칸 글 · 까닭(없으면 null) */
check: () => string | null;
destroy: () => void;
}
@@ -72,14 +72,17 @@ export async function openRefEdit(opt: RefEditOptions): Promise<void> {
const ok = createButton({
label: tc("Save"),
variant: "filled",
onClick: () =>
onClick: () => {
const need = handle?.check(); // 860-2 ① 빈 이름 · 단위 = 안 보냄 · 줄 그대로
if (need) return void showToast(`${tc("Lib_SaveFailed")} — ${need}`, "error");
void save(handle?.getDoc()).then(
() => {
close();
finish();
},
(error) => fail(error, "Lib_SaveFailed"),
),
);
},
});
body.append(
el("p", {
@@ -479,10 +479,12 @@ export function mountLaborTable(
nameField.input.readOnly = !edit;
nameField.input.addEventListener("input", () => {
(cur as { 이름?: string }).이름 = nameField.input.value.trim();
nameField.setError();
opt.onChanged(dirty());
});
const unit = el("div", { className: "ui-field", attrs: { "data-labor-field": "단위" } });
const unit0 = cur.단위;
let unitWhy = ""; // 860-2 ① 빈 단위로 [저장] — 칸 아래 글(단위를 고르면 지움)
const drawUnit = (): void =>
unit.replaceChildren(
el("label", { className: "ui-field__label", text: tc("Labor_Unit") }),
@@ -493,11 +495,13 @@ export function mountLaborTable(
ariaLabel: tc("Labor_Unit"),
onPick: (u) => {
cur.단위 = u === NO_UNIT ? null : u;
unitWhy = "";
opt.onChanged(dirty());
drawUnit();
draw();
},
}),
...(unitWhy ? [createText(unitWhy, "error")] : []),
);
drawUnit();
const origin = createInputField({ type: "text", label: tc("Labor_Origin") });
@@ -562,6 +566,20 @@ export function mountLaborTable(
return out as unknown as LaborDoc;
},
saveArea: async () => (await combo?.save()) ?? false,
// 860-2 ① 서버 400(이름 · 단위 빔) 전에 막음 — 칸 초점 · 칸 글 · 화면 줄 그대로
check: () => {
if (combo || !edit) return null;
if (!(cur as { 이름?: string }).이름?.trim()) {
nameField.setError(tc("NeedName"));
nameField.input.focus();
return tc("NeedName");
}
if (cur.단위 || !(cur.담은로직.length || cur.자재.length)) return null;
unitWhy = tc("NeedUnit");
drawUnit();
unit.querySelector("button")?.focus();
return unitWhy;
},
destroy: () => {
alive = false;
window.clearTimeout(timer);
@@ -21,6 +21,7 @@ const TEXT = {
Loading: ["불러오는 중…", "Loading…"],
Search: ["이름 · 키로 찾기", "Search by name or key"],
NeedName: ["이름을 적어야 저장됨", "A name is required"],
NeedUnit: ["단위를 골라야 저장됨", "Pick a unit to save"],
Load_Failed: ["불러오지 못함", "Load failed"],
Origin_Self: ["원본", "Original"],
Logics_Title: ["단가산출 기초", "Unit-price logics"],
@@ -56,6 +56,8 @@ export interface Selection {
interface EditorHandle {
getDoc: () => unknown | Promise<unknown>;
/** [저장] 앞 필수 칸(860-2 ① 일위대가) — 까닭이면 저장 안 함 */
check?: () => string | null;
destroy: () => void;
}
@@ -462,6 +464,7 @@ export function createMain(
version = (await readTemplate(at.layer, "labor", at.name, at.projectId)).판 ?? "";
return labor.getDoc();
},
check: labor.check,
destroy: labor.destroy,
};
return;
@@ -578,6 +581,8 @@ export function createMain(
async function doSave(): Promise<void> {
if (!sel) return;
const at = sel;
const need = editor?.check?.(); // 860-2 ① 빈 필수 칸 — 서버에 안 보냄 · 화면 줄 그대로
if (need) return void showToast(L("M02_SaveFailed").replace("{value}", need), "error");
try {
const edited = editor ? await editor.getDoc() : loaded;
// 구조물 도면 저장은 `도면` · `더한장` 칸만 갈아 끼움 — 도번은 읽은 그대로.