From a8d6b426d0926b99da83c0feda685593a08fc0f0 Mon Sep 17 00:00:00 2001 From: umsangdon Date: Tue, 17 Nov 2026 21:02:55 +0900 Subject: [PATCH] =?UTF-8?q?refactor(856-4):=20=EA=B1=B0=EA=BE=B8=EB=A1=9C?= =?UTF-8?q?=20=EB=B6=80=EB=A6=84=20=EB=81=8A=EA=B8=B0=20=EB=B3=B8=EB=AC=B8?= =?UTF-8?q?=20=E2=80=94=20=EC=95=9E=20=EC=BB=A4=EB=B0=8B(bd41d8799)?= =?UTF-8?q?=EC=9D=80=20=EC=9D=B4=EB=A6=84=20=EC=98=AE=EA=B9=80=EB=A7=8C=20?= =?UTF-8?q?=EB=8B=B4=EA=B9=80=20=C2=B7=20=EC=9D=B4=20=EC=BB=A4=EB=B0=8B?= =?UTF-8?q?=EA=B3=BC=20=ED=95=9C=20=EB=AC=B6=EC=9D=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 앞 커밋 글 그대로(층 · 부름 common_util_m02_call · 찾아 넣기 창 StackFind 주입 · 단위 고르기 부품 상자 · 합계 상자 A00 · 기계 칸 부품) - 앞 커밋에서 git add 가 옛 경로에 걸려 고친 파일이 빠짐 — 두 커밋을 같이 올림 Co-Authored-By: Claude Opus 5.5 --- A00_Common/formula_doc_foot.css | 64 +++++++++++++++ A00_Common/formula_doc_foot.ts | 47 ++++++++--- A00_Common/line_stack_edit.ts | 9 ++- A00_Common/line_stack_machine.ts | 2 +- A00_Common/line_stack_machine_cell.ts | 66 ++++++++++++++++ A00_Common/line_stack_machine_ctl.ts | 77 +++---------------- A00_Common/line_stack_machine_sheet.ts | 4 + A00_Common/line_stack_machine_work.ts | 2 +- A00_Common/line_stack_material.ts | 2 +- A00_Common/line_stack_pick.ts | 46 +++++++++-- A00_Common/line_stack_rows.ts | 3 +- A00_Common/line_stack_screen.ts | 6 +- M01_MasterData/M01_MasterData_UI_LogicLab.ts | 2 + .../M01_MasterData_UI_LogicLab_Style.css | 68 ---------------- .../M01_MasterData_UI_LogicLab_Text.ts | 1 - .../M01_MasterData_UI_MachineDetail.ts | 2 + M01_MasterData/M01_MasterData_UI_Parts.ts | 2 + M02_MasterTemplete/DataFlow/M02_DF_Api.ts | 16 +--- .../M02_MasterTemplete_Api_Fetch.ts | 42 +--------- .../M02_MasterTemplete_Find_Pick.ts | 3 +- .../M02_MasterTemplete_Hopyo_MatPick.ts | 2 + .../M02_MasterTemplete_Labor_Table.ts | 2 +- .../M02_MasterTemplete_Sangeun_Tabs.ts | 2 + M02_MasterTemplete/M02_Material_Pick.ts | 2 +- M02_MasterTemplete/M02_MyMachine_Form.ts | 2 + M02_MasterTemplete/M02_MyMaterial_View.ts | 2 +- common_util/common_util_m02_call.ts | 47 +++++++++++ resources/tester/helper_845_2_unit_show.cjs | 2 +- resources/tester/helper_856_0_sk_screen.cjs | 2 +- resources/tester/test_721_find_pick.py | 1 - resources/tester/test_737_option_grid_foot.py | 11 --- resources/tester/test_804_7_line_stack_fix.py | 4 +- .../tester/ui_checks/51-5_단위단추_크기.js | 2 +- ui_template/ui_template_unit_pick.ts | 20 ++++- 34 files changed, 330 insertions(+), 235 deletions(-) create mode 100644 A00_Common/formula_doc_foot.css create mode 100644 A00_Common/line_stack_machine_cell.ts create mode 100644 common_util/common_util_m02_call.ts diff --git a/A00_Common/formula_doc_foot.css b/A00_Common/formula_doc_foot.css new file mode 100644 index 000000000..72407d841 --- /dev/null +++ b/A00_Common/formula_doc_foot.css @@ -0,0 +1,64 @@ +/* formula_doc_foot.css — 수식 화면 맨 아래 합계 상자(PLAN 737-1 · 803-2a · 856-4 — M01 LogicLab_Style 에서 옮김) */ + +.m01lab__total { + margin: var(--spacing-8) 0 0; + font-weight: 700; + text-align: right; +} + +/* 737-1 맨 아래 한 줄 4 칸(노무비 · 재료비 · 경비 · 계) — 화면(모달) 바닥에 붙음 · 칸마다 이름 위 · 값 아래 */ +.m01lab__foot { + position: sticky; + bottom: 0; + z-index: 2; + display: grid; + grid-template-columns: repeat(4, minmax(0, 1fr)); + gap: var(--spacing-8); + margin-top: var(--m01lab-box-gap, var(--spacing-12)); + padding: var(--spacing-8) var(--spacing-12); + border: 1px solid var(--color-border); + border-radius: var(--radius-lg); + background: var(--color-surface-raised); +} + +/* 합계 줄이 화면 바닥에 붙으려면 메인 칸이 굴림 칸(overflow:auto)이 아니어야 함 — 메인은 높이가 안 묶여 안 굴렀음 */ +.ui-workflow-layout__main:has(.m01lab__foot) { + overflow: clip; +} + +.m01lab__sums { + display: contents; +} + +.m01lab__foot .ui-calc-row { + display: flex; + flex-direction: column; + align-items: stretch; + gap: 0; + min-height: 0; +} + +.m01lab__foot .ui-calc-row > :empty { + display: none; +} + +.m01lab__foot .ui-calc-row__out { + padding: 0; + text-align: left; +} + +.m01lab__foot .m01lab__total { + display: flex; + flex-direction: column; + margin: 0; + text-align: left; +} + +.m01lab__foot .m01lab__total > :first-child { + color: var(--color-text-secondary); + font-weight: var(--font-weight-regular, 400); +} + +.m01lab__foot .m01lab__total > :last-child { + font-variant-numeric: tabular-nums; +} diff --git a/A00_Common/formula_doc_foot.ts b/A00_Common/formula_doc_foot.ts index 3a224b188..95bce3371 100644 --- a/A00_Common/formula_doc_foot.ts +++ b/A00_Common/formula_doc_foot.ts @@ -1,20 +1,49 @@ /* ============================================================================= * formula_doc_foot.ts - * 수식 탭 맨 아래 합계 상자(PLAN 803-2a · 요구 667-2) — 단가산출 상세 탭과 같은 부품(`buildFoot` · 노무비 · 재료비 · 경비 · 계) - * 값 = 계산기 셈 그대로(여기서 다시 셈 안 함) · 셈 못 함 = 「—」 + * 수식 탭 맨 아래 합계 상자(PLAN 803-2a · 요구 667-2 · 737-1) — 노무비 · 재료비 · 경비 · 계 네 칸 · 화면(모달) 바닥에 붙음 + * 값 = 계산기 셈 그대로(여기서 다시 셈 안 함) · 셈 못 함 = 「—」 · 856-4 = M01 `LogicLab_Foot` 을 여기로(쓰는 곳 하나) * ========================================================================== */ +import { createCalcFormulaRow } from "@ui/ui_template_calc_row"; +import { el } from "@ui/ui_template_elements"; +import { formatMoney } from "../common_util/common_util_money"; import type { DocAnswer } from "../common_util/common_util_formula_doc_calc"; -import { buildFoot } from "../M01_MasterData/M01_MasterData_UI_LogicLab_Foot"; -import "../M01_MasterData/M01_MasterData_UI_LogicLab_Style.css"; +import { ft } from "./formula_doc_text"; +import "./formula_doc_foot.css"; const num = (v: unknown): number => (typeof v === "number" && Number.isFinite(v) ? v : 0); +const PARTS = [ + ["labor", "노무비"], + ["material", "재료비"], + ["cost", "경비"], +] as const; export function docFoot(a: DocAnswer): HTMLElement { const done = !!a.셈됨 && typeof a.계 === "number"; - return buildFoot( - { labor: num(a.노무비), material: num(a.재료비), cost: num(a.경비) }, - done, - num(a.계), - ); + const sums = { labor: num(a.노무비), material: num(a.재료비), cost: num(a.경비) }; + const total = num(a.계); + const cells = PARTS.map(([k, label]) => { + const out = el("span", { + className: "ui-calc-row__out is-key", + text: done ? formatMoney(sums[k]) : "—", + }); + const row = createCalcFormulaRow(label, null, out); + row.dataset.group = k; + row.dataset.subtotal = done ? String(sums[k]) : ""; + return row; + }); + return el("div", { + className: "m01lab__foot", + children: [ + el("div", { className: "m01lab__sums", children: cells }), + el("p", { + className: "m01lab__total", + attrs: { "data-sum": done ? String(total) : "" }, + children: [ + el("span", { text: `${ft("Sum")} ` }), + el("span", { text: done ? formatMoney(total) : "—" }), + ], + }), + ], + }); } diff --git a/A00_Common/line_stack_edit.ts b/A00_Common/line_stack_edit.ts index eaeabf304..b68e5e8d6 100644 --- a/A00_Common/line_stack_edit.ts +++ b/A00_Common/line_stack_edit.ts @@ -56,7 +56,7 @@ import { unswap, } from "../common_util/common_util_line_stack_pick"; import { shownUnitOf, type TableLook } from "../common_util/common_util_line_stack_unit"; -import { createUnitPick, NO_UNIT } from "../M02_MasterTemplete/DataFlow/M02_DF_UnitPick"; +import { createUnitPick, NO_UNIT } from "@ui/ui_template_unit_pick"; import { hiddenByWork, reach } from "./formula_doc_render"; import { attachDrag } from "./line_stack_drag"; import type { WorkSpec } from "../common_util/common_util_formula_doc_work"; @@ -64,7 +64,7 @@ import { openMachineWindow, type MachineCtx } from "./line_stack_machine"; import { dropCover } from "../common_util/common_util_formula_doc_cover_drop"; import { buildMachineCtl, lineCall } from "./line_stack_machine_ctl"; import { putWork, swapMachine } from "./line_stack_machine_work"; -import { openStackPick, type StackTake } from "./line_stack_pick"; +import { openStackPick, type StackFind, type StackTake } from "./line_stack_pick"; import { buildBlock, sourceTag } from "./line_stack_rows"; import { lt, type LsKey } from "./line_stack_text"; @@ -99,6 +99,8 @@ export interface EditHooks { upper?: Cover | null; /** 848-3 M01 기초 제어 구역 엶(시스템 관리자) — M02 = 층(`machine.scope`)이 엶 */ ctlEdit?: boolean; + /** 856-4 찾아 넣기 창(페이지가 넘김) */ + find: StackFind; } const field = ( @@ -229,7 +231,7 @@ function moneyBody(h: EditHooks, i: number): HTMLElement[] { query, pick: fixed ? swapFixed : swap, }) - : openStackPick(kind, swap, undefined, query), + : openStackPick(h.find, kind, swap, undefined, query), }); pick.classList.add("lstk-res"); pick.title = `${lt("Repick")}${res ? ` — ${res}` : ""}`; @@ -406,6 +408,7 @@ function readQty(text: string, note: string, tag: string): HTMLElement { function addLine(h: EditHooks, at: number, kind: string): void { if (["인력", "재료", "기계", "단가산출"].includes(kind)) return openStackPick( + h.find, kind as MoneyKind, (p) => h.change((d, items) => void addPicked(d, items[at], kind as MoneyKind, p)), h.take, diff --git a/A00_Common/line_stack_machine.ts b/A00_Common/line_stack_machine.ts index 4d57a7e77..f4cf6c2ef 100644 --- a/A00_Common/line_stack_machine.ts +++ b/A00_Common/line_stack_machine.ts @@ -14,7 +14,7 @@ import { openModal } from "@ui/ui_template_modal"; import { createText } from "@ui/ui_template_text"; import { isDraftNo, type DraftItem } from "../common_util/common_util_line_stack_draft"; import type { Picked } from "../common_util/common_util_line_stack_pick"; -import { call, type Layer } from "../M02_MasterTemplete/M02_MasterTemplete_Api_Fetch"; +import { call, type Layer } from "../common_util/common_util_m02_call"; import { listMyMachines, machineArg, diff --git a/A00_Common/line_stack_machine_cell.ts b/A00_Common/line_stack_machine_cell.ts new file mode 100644 index 000000000..a867eeff7 --- /dev/null +++ b/A00_Common/line_stack_machine_cell.ts @@ -0,0 +1,66 @@ +/* ============================================================================= + * line_stack_machine_cell.ts + * 기계 제어 구역 칸 부품(PLAN 856-4) — 수 칸 · 「바뀜」 표시(출처 테두리 · 원래 값 풍선) + * 제어 구역(`line_stack_machine_ctl`) · 작업량 묶음(`line_stack_machine_work`)이 같이 씀 — 둘이 서로 부르던 고리 끊음 + * ========================================================================== */ + +import { setUiDiff, type UiDiff } from "@ui/ui_template_button"; +import { el, showToast } from "@ui/ui_template_elements"; +import { createInputField } from "@ui/ui_template_input"; +import { MINE, type Source } from "../common_util/common_util_formula_doc_cover"; +import { lt } from "./line_stack_text"; + +/** 출처(848-3) — 나 · 위 층. 테두리는 나만(892) · 풍선(원래 값)은 둘 다 */ +export type DiffSrc = UiDiff | "upper"; +export const diffOf = (src: Source | undefined): DiffSrc | null => + src === undefined ? null : src === MINE ? "mine" : "upper"; + +/** 칸 묶음 안 입력 · 고르기 · 이름 단추에 「바뀜」 상태(나만) · 풍선(원래 값) */ +export function markDiff(box: HTMLElement, diff: DiffSrc | null, was?: string): void { + const own = ["ui-input", "ui-select", "ui-btn"].some((c) => box.classList.contains(c)); + const nodes = own ? [box] : ["ui-input", "ui-select", "lstk-res"].flatMap((c) => [...box.querySelectorAll(`.${c}`)]); // prettier-ignore + for (const n of nodes) { + setUiDiff(n, diff === "mine" ? "mine" : null); + if (diff && was !== undefined) + n.title = `${n.title ? `${n.title} — ` : ""}${lt("Ctl_Was")} ${was}`; + } +} + +const num = (t: string): number | null => { + const n = Number(t.trim().replace(/,/g, "")); + return t.trim() !== "" && Number.isFinite(n) ? n : null; +}; + +/** 수 칸 — 빈 글 = 원래대로(null) · 음수 · 글 = 알림 · 단위 = 칸 바로 뒤(공식 묶음 값 칸과 같은 자리 · 845-2 ㉥) */ +export function numBox( + label: string, + value: unknown, + unit: string, + ro: boolean, + set: (n: number | null) => void, + hint = "", +): HTMLElement { + const f = createInputField({ + value: value === undefined || value === null ? "" : String(value), + placeholder: hint, + compact: true, + size: 24, + }); + f.root.classList.add("lstk-f-s"); + f.input.setAttribute("aria-label", label); + f.input.title = label; + f.input.disabled = ro; + f.input.addEventListener("change", () => { + const t = f.input.value; + const n = num(t); + if (t.trim() === "") return set(null); + if (n === null || n < 0) { + f.input.value = value === undefined || value === null ? "" : String(value); + return void showToast(lt("Ctl_Bad"), "warning"); + } + set(n); + }); + return unit + ? el("span", { className: "lstk-qty", children: [f.root, el("span", { className: "lstk-unit", text: unit })] }) // prettier-ignore + : f.root; +} diff --git a/A00_Common/line_stack_machine_ctl.ts b/A00_Common/line_stack_machine_ctl.ts index d22bfb7be..ff4091f36 100644 --- a/A00_Common/line_stack_machine_ctl.ts +++ b/A00_Common/line_stack_machine_ctl.ts @@ -16,10 +16,10 @@ * 「고침」 글 배지 없음(테두리로) · 칸 풍선 = 원래 값 · M01 기초(시스템 관리자) = ① 없음 → 기초 고침 = 「나」 * ========================================================================== */ -import { createButton, createIconButton, setUiDiff, type UiDiff } from "@ui/ui_template_button"; +import { createButton, createIconButton } from "@ui/ui_template_button"; import { eqText } from "@ui/ui_template_equation"; -import { el, showToast } from "@ui/ui_template_elements"; -import { createInputField, createSelectField } from "@ui/ui_template_input"; +import { el } from "@ui/ui_template_elements"; +import { createSelectField } from "@ui/ui_template_input"; import { varId, type FormulaDoc, type Link } from "../common_util/common_util_formula_doc"; import { WORK, workKey, type WorkCover } from "../common_util/common_util_formula_doc_work"; import type { DocAnswer } from "../common_util/common_util_formula_doc_calc"; @@ -28,7 +28,6 @@ import { defaultsOf, layeredCover, machineKey, - MINE, partsOf, putCover, rowEntry, @@ -38,7 +37,6 @@ import { type CrewRow, type CoverEntry, type MiscRow, - type Source, } from "../common_util/common_util_formula_doc_cover"; import { subInputs, type StackDoc } from "../common_util/common_util_line_stack"; import type { Picked } from "../common_util/common_util_line_stack_pick"; @@ -46,9 +44,9 @@ import { machineUnit } from "../common_util/common_util_line_stack_unit"; import { attachHost, workAt, workOfMachine } from "../common_util/common_util_line_stack_work"; import { sites, type WorkSpec } from "../common_util/common_util_formula_doc_work"; import { machineCellName } from "../common_util/common_util_machine_symbol_name"; -import { openFindPicker } from "../M02_MasterTemplete/M02_MasterTemplete_Find_Pick"; import { buildWorkGroup, putWork } from "./line_stack_machine_work"; -import { openStackPick } from "./line_stack_pick"; +import { openStackPick, type StackFind } from "./line_stack_pick"; +import { diffOf, markDiff, numBox } from "./line_stack_machine_cell"; import { lt } from "./line_stack_text"; export interface CtlHooks { @@ -69,22 +67,8 @@ export interface CtlHooks { work?: (machine: string) => WorkSpec[]; /** 848-3 ① 위 층 고침(SK 읽기 답 `위덮음` · M01 = 없음) */ upper?: Cover | null; -} - -/** 출처(848-3) — 나 · 위 층. 테두리는 나만(892) · 풍선(원래 값)은 둘 다 */ -export type DiffSrc = UiDiff | "upper"; -export const diffOf = (src: Source | undefined): DiffSrc | null => - src === undefined ? null : src === MINE ? "mine" : "upper"; - -/** 칸 묶음 안 입력 · 고르기 · 이름 단추에 「바뀜」 상태(나만) · 풍선(원래 값) */ -export function markDiff(box: HTMLElement, diff: DiffSrc | null, was?: string): void { - const own = ["ui-input", "ui-select", "ui-btn"].some((c) => box.classList.contains(c)); - const nodes = own ? [box] : ["ui-input", "ui-select", "lstk-res"].flatMap((c) => [...box.querySelectorAll(`.${c}`)]); // prettier-ignore - for (const n of nodes) { - setUiDiff(n, diff === "mine" ? "mine" : null); - if (diff && was !== undefined) - n.title = `${n.title ? `${n.title} — ` : ""}${lt("Ctl_Was")} ${was}`; - } + /** 856-4 찾아 넣기 창(페이지가 넘김) */ + find: StackFind; } const FUELS = ["경유", "휘발유", "실내등유"]; @@ -120,45 +104,6 @@ export function ctlOf(h: CtlHooks, link: Link | undefined, at?: number) { return { machine, sub, vals, base, up, top: upperOf(base, up), entry: coverOf(h.doc)[machine] }; } -const num = (t: string): number | null => { - const n = Number(t.trim().replace(/,/g, "")); - return t.trim() !== "" && Number.isFinite(n) ? n : null; -}; - -/** 수 칸 — 빈 글 = 원래대로(null) · 음수 · 글 = 알림 · 단위 = 칸 바로 뒤(공식 묶음 값 칸과 같은 자리 · 845-2 ㉥) */ -export function numBox( - label: string, - value: unknown, - unit: string, - ro: boolean, - set: (n: number | null) => void, - hint = "", -): HTMLElement { - const f = createInputField({ - value: value === undefined || value === null ? "" : String(value), - placeholder: hint, - compact: true, - size: 24, - }); - f.root.classList.add("lstk-f-s"); - f.input.setAttribute("aria-label", label); - f.input.title = label; - f.input.disabled = ro; - f.input.addEventListener("change", () => { - const t = f.input.value; - const n = num(t); - if (t.trim() === "") return set(null); - if (n === null || n < 0) { - f.input.value = value === undefined || value === null ? "" : String(value); - return void showToast(lt("Ctl_Bad"), "warning"); - } - set(n); - }); - return unit - ? el("span", { className: "lstk-qty", children: [f.root, el("span", { className: "lstk-unit", text: unit })] }) // prettier-ignore - : f.root; -} - const kind = (text: string): HTMLElement => el("span", { className: "lstk-kind", text }); /** 기계 제어 구역 — `link` = 그 기계 줄 단가 기호 연결 · `at` = 그 금액 줄 차례(작업량) */ @@ -243,7 +188,7 @@ export function buildMachineCtl( lt("K_인력"), crewName(r, i), ro, - () => openStackPick("인력", (p) => setCrew(swapAt(crew, i, { ...r, 키: p.키, 이름: p.이름 })), undefined, crewName(r, i)), // prettier-ignore + () => openStackPick(h.find, "인력", (p) => setCrew(swapAt(crew, i, { ...r, 키: p.키, 이름: p.이름 })), undefined, crewName(r, i)), // prettier-ignore [numBox(lt("Ctl_Crew_Qty"), r.인, lt("Ctl_Per_Day"), ro, (n) => setCrew(swapAt(crew, i, { ...r, 인: n ?? 0 })))], // prettier-ignore "노무비", () => setCrew(crew.filter((_, k) => k !== i)), @@ -265,7 +210,7 @@ export function buildMachineCtl( return [r.줄, fuel].filter(Boolean).join(" · "); }; const pickMat = (done: (p: Picked) => void, query: string): void => - openFindPicker({ + h.find({ layer: "system", owner: null, title: `${lt("Find_Title")} — ${lt("Ctl_Misc")}`, @@ -363,7 +308,9 @@ export function buildMachineCtl( lt("Ctl_Crew"), entry.조종원 !== undefined, () => - openStackPick("인력", (p) => setCrew([...crew, { 키: p.키, 이름: p.이름, 인: 1 }])), + openStackPick(h.find, "인력", (p) => + setCrew([...crew, { 키: p.키, 이름: p.이름, 인: 1 }]), + ), () => put({ ...entry, 조종원: undefined }), ro, ), diff --git a/A00_Common/line_stack_machine_sheet.ts b/A00_Common/line_stack_machine_sheet.ts index 015022972..73e4dc688 100644 --- a/A00_Common/line_stack_machine_sheet.ts +++ b/A00_Common/line_stack_machine_sheet.ts @@ -69,6 +69,7 @@ import { sheetWorkCard, sheetWorkOut, type SheetWorkOpts } from "./line_stack_ma import { buildOut } from "./line_stack_out"; import "./line_stack.css"; import "./line_stack_machine_sheet.css"; +import type { StackFind } from "./line_stack_pick"; export interface MachineSimilar { key: string; @@ -91,6 +92,8 @@ export interface MachineSheetOptions { findSimilar?: (q: string) => Promise; onSimilar?: (item: MachineSimilar) => void; onChange?: () => void; + /** 856-4 찾아 넣기 창(조종원 · 잡품 고르기 — 페이지가 넘김) */ + find: StackFind; } export interface MachineSheetState { @@ -287,6 +290,7 @@ export function createMachineSheet(o: MachineSheetOptions) { readOnly: ro, lists: () => engineVals(orig, mine), lock, + find: o.find, }, { ...link, 키: info.키 }, ); diff --git a/A00_Common/line_stack_machine_work.ts b/A00_Common/line_stack_machine_work.ts index bf7edda61..0f1bad65a 100644 --- a/A00_Common/line_stack_machine_work.ts +++ b/A00_Common/line_stack_machine_work.ts @@ -47,7 +47,7 @@ import type { Picked } from "../common_util/common_util_line_stack_pick"; import type { Values } from "../common_util/common_util_formula_doc_view"; import { varUnit } from "../common_util/common_util_line_stack_unit"; import { workUnit } from "../common_util/common_util_line_stack_work"; -import { diffOf, markDiff, numBox, type DiffSrc } from "./line_stack_machine_ctl"; +import { diffOf, markDiff, numBox, type DiffSrc } from "./line_stack_machine_cell"; import { lt } from "./line_stack_text"; import { workRows } from "./line_stack_work"; diff --git a/A00_Common/line_stack_material.ts b/A00_Common/line_stack_material.ts index a50317865..c14071c4f 100644 --- a/A00_Common/line_stack_material.ts +++ b/A00_Common/line_stack_material.ts @@ -12,7 +12,7 @@ import { showToast } from "@ui/ui_template_elements"; import { askConfirm } from "@ui/ui_template_modal"; import type { FormulaDoc } from "../common_util/common_util_formula_doc"; import type { Picked } from "../common_util/common_util_line_stack_pick"; -import { call, type Layer } from "../M02_MasterTemplete/M02_MasterTemplete_Api_Fetch"; +import { call, type Layer } from "../common_util/common_util_m02_call"; import { at } from "../M02_MasterTemplete/M02_MasterTemplete_Hopyo_Api"; import { placeNote } from "../M01_MasterData/M01_MasterData_Api_Fetch"; import type { MachineCtx } from "./line_stack_machine"; diff --git a/A00_Common/line_stack_pick.ts b/A00_Common/line_stack_pick.ts index c9db700a0..6e93a1deb 100644 --- a/A00_Common/line_stack_pick.ts +++ b/A00_Common/line_stack_pick.ts @@ -1,7 +1,8 @@ /* ============================================================================= * line_stack_pick.ts * 줄 쌓기 고르기 창(PLAN 804-3 · 804-4 · 요구 678-1 · 678-3 · 680-1 · 681) - * 찾아 넣기 = M02 [항목 추가] 창 그대로(`openFindPicker` · 탭 M01 전체 · 찾기 칸 · 표) — 줄 갈래마다 그 종류만 + * 찾아 넣기 = M02 [항목 추가] 창 그대로(`openFindPicker` · 탭 M01 전체 · 찾기 칸 · 표) — 줄 갈래마다 그 종류만 · + * 창은 페이지가 넘김(`StackFind` · 856-4 — 공용 화면은 M02 를 부르지 않음) * 인력(노임 LB) · 재료(자재 MT) · 기계(EQ → 시간당 경비 로직 + 기계='원문번호') · 다른 단가산출(M01 단가산출 로직) * 기계 + M02 개인 층(821-3) = 품셈 기계 위 「내 기계」 묶음 · 머리 [새 기계 만들기] — 고름 = 로직 + 기계='개인 EQP…' * 재료 + M02 개인 층(840-4) = M01 재료 위 「내 재료」 묶음 — 고름 = 요소 PM 키(M01 재료와 같은 꼴) @@ -22,11 +23,45 @@ import type { DocTable } from "../common_util/common_util_formula_doc_table"; import type { MoneyKind } from "../common_util/common_util_line_stack"; import type { Picked } from "../common_util/common_util_line_stack_pick"; import { showToast } from "@ui/ui_template_elements"; -import type { Layer } from "../M02_MasterTemplete/M02_MasterTemplete_Api_Fetch"; -import { openFindPicker, type FindKind } from "../M02_MasterTemplete/M02_MasterTemplete_Find_Pick"; +import type { Layer } from "../common_util/common_util_m02_call"; import { lt } from "./line_stack_text"; -const KINDS: Partial> = { +/** 찾아 넣기 종류 — logic = M01 단가산출 · 기초 · labor = 인력 · material = 재료 · machine = 기계 · oil = 유가 · sk = M02 단가산출 · pre = 일위대가 */ +export type StackFindKind = "logic" | "labor" | "material" | "machine" | "oil" | "sk" | "pre"; + +/** 고른 M01 요소 중 공용 화면이 읽는 칸 */ +interface FoundElement { + 코드: string; + 이름: string; + 규격: string; + 단위: string; + /** 기계(804-3) — 시간당 경비 로직 키 · 기종 원문번호 */ + 로직?: string; + 원문번호?: string; +} + +/** 찾아 넣기 창 옵션 — 공용 화면이 쓰는 칸만(M02 `FindPickOptions` 와 같은 뜻) */ +export interface StackFindOptions { + layer: Layer; + owner: string | null; + title?: string; + kinds?: StackFindKind[]; + query?: string; + /** 돈 아닌 기초(작업량 등 결과)만 */ + results?: boolean; + logic: (x: { 키: string; 이름: string; 결과단위: string }) => void; + ref?: (r: { 층: string; 주인: string | null; 키: string }) => void; + element?: (e: FoundElement) => void; + machine?: (e: FoundElement) => void; + oil?: (e: FoundElement) => void; + mine?: { owner: string | null }; + mineMat?: { owner: string | null }; +} + +/** 찾아 넣기 창(856-4) — 페이지가 넘김(M01 · M02 = M02 `openFindPicker`) */ +export type StackFind = (o: StackFindOptions) => void; + +const KINDS: Partial> = { 인력: "labor", 재료: "material", 기계: "machine", @@ -44,6 +79,7 @@ export interface StackTake { /** 찾아 넣기 — 고르면 `done(고른 것)` · 닫으면 아무것도 안 함 · `m02` 있고 다른 단가산출 = 복사해 펼침 · * `query` = 찾기 칸에 넣고 연 결과(이름 단추 · 요구 687-9) */ export function openStackPick( + find: StackFind, kind: MoneyKind, done: (p: Picked) => void, m02?: StackTake, @@ -53,7 +89,7 @@ export function openStackPick( if (!want) return; const spec = (e: { 규격: string }) => (e.규격 ? { 규격: e.규격 } : {}); const copy = kind === "단가산출" && m02 ? m02 : null; - openFindPicker({ + find({ layer: copy?.layer ?? "system", owner: copy?.owner ?? null, title: `${lt("Find_Title")} — ${lt(copy ? "K_복사" : (`K_${kind}` as never))}`, diff --git a/A00_Common/line_stack_rows.ts b/A00_Common/line_stack_rows.ts index 96cb3676c..d7a1d1548 100644 --- a/A00_Common/line_stack_rows.ts +++ b/A00_Common/line_stack_rows.ts @@ -45,7 +45,6 @@ import { tableAlias, } from "../common_util/common_util_line_stack_pick"; import { shownUnitOf, unitText } from "../common_util/common_util_line_stack_unit"; -import { openFindPicker } from "../M02_MasterTemplete/M02_MasterTemplete_Find_Pick"; import type { EditHooks } from "./line_stack_edit"; import { openTablePick } from "./line_stack_pick"; import { lt } from "./line_stack_text"; @@ -282,7 +281,7 @@ export function buildBlock( variant: "ghost", size: 24, onClick: () => - openFindPicker({ + h.find({ layer: "system", owner: null, title: lt("K_단가산출"), diff --git a/A00_Common/line_stack_screen.ts b/A00_Common/line_stack_screen.ts index 0fb1bbb6b..3db308cc7 100644 --- a/A00_Common/line_stack_screen.ts +++ b/A00_Common/line_stack_screen.ts @@ -70,7 +70,7 @@ import { hiddenByWork } from "./formula_doc_render"; import { ft } from "./formula_doc_text"; import { addTaken, type Taken } from "../common_util/common_util_line_stack_copy"; import { machineWork } from "../common_util/common_util_line_stack_work"; -import type { Layer } from "../M02_MasterTemplete/M02_MasterTemplete_Api_Fetch"; +import type { Layer } from "../common_util/common_util_m02_call"; import { applyDiff } from "./line_stack_diff"; import { buildEdit } from "./line_stack_edit"; import { openMachineWindow, type CopyAnswer, type MachineCtx } from "./line_stack_machine"; @@ -78,6 +78,7 @@ import { dropPath } from "../common_util/common_util_formula_doc_cover_drop"; import { buildOut } from "./line_stack_out"; import { lt } from "./line_stack_text"; import "./line_stack.css"; +import type { StackFind } from "./line_stack_pick"; export interface StackScreenOptions { /** 길 앞머리(`/m01/logic/doc`) — GET ?key · POST /preview · /save · /links */ @@ -94,6 +95,8 @@ export interface StackScreenOptions { tools?: HTMLElement; /** 저장 전 SK 문서(836-5 · 불러오기 미리 보기) — 빈 키일 때 이 문서를 서버가 읽어 줌(파일 안 읽음 · 안 씀) */ memory?: () => Record | null; + /** 856-4 찾아 넣기 창(M01 · M02 = M02 `openFindPicker`) — 공용 화면은 M02 를 부르지 않음 */ + find: StackFind; } type Docs = Record; @@ -408,6 +411,7 @@ export function createStackScreen(opt: StackScreenOptions) { ...(edit() || mem() ? [ buildEdit({ + find: opt.find, doc, answer, items, diff --git a/M01_MasterData/M01_MasterData_UI_LogicLab.ts b/M01_MasterData/M01_MasterData_UI_LogicLab.ts index d15e0934e..8571dce69 100644 --- a/M01_MasterData/M01_MasterData_UI_LogicLab.ts +++ b/M01_MasterData/M01_MasterData_UI_LogicLab.ts @@ -47,6 +47,7 @@ import { buildHeadBar } from "./M01_MasterData_UI_Head"; import { fetchSessionUser } from "../A06_Login/A06_Login_Api_Fetch"; import "./M01_MasterData_UI_Logic_Style.css"; import { createEmpty } from "@ui/ui_template_empty"; +import { openFindPicker } from "../M02_MasterTemplete/M02_MasterTemplete_Find_Pick"; /** 저장 안 한 로직 하나 — origKey null = 새 로직 · row null = 지움 */ interface Draft { @@ -99,6 +100,7 @@ export async function mountM01LogicLab( .catch(() => false); // 수식 = 줄 쌓기(804-2 · 804-6 옛 수식 문서 탭 걷음) — 수식 문서 · 캐시 m01_doc_drafts const stack = createStackScreen({ + find: openFindPicker, // 856-4 찾아 넣기 창(M02 창 · M01 전체 탭만) base: "/m01/logic/doc", admin, cache: "m01_doc_drafts", diff --git a/M01_MasterData/M01_MasterData_UI_LogicLab_Style.css b/M01_MasterData/M01_MasterData_UI_LogicLab_Style.css index 62c2c8b77..90ee00aa9 100644 --- a/M01_MasterData/M01_MasterData_UI_LogicLab_Style.css +++ b/M01_MasterData/M01_MasterData_UI_LogicLab_Style.css @@ -56,12 +56,6 @@ white-space: pre-wrap; } -.m01lab__total { - margin: var(--spacing-8) 0 0; - font-weight: 700; - text-align: right; -} - .m01lab__modal { overflow: auto; } @@ -148,69 +142,7 @@ overflow: auto; } -/* 737-1 맨 아래 한 줄 4 칸(노무비 · 재료비 · 경비 · 계) — 화면(모달) 바닥에 붙음 · 칸마다 이름 위 · 값 아래 */ -.m01lab__foot { - position: sticky; - bottom: 0; - z-index: 2; - display: grid; - grid-template-columns: repeat(4, minmax(0, 1fr)); - gap: var(--spacing-8); - margin-top: var(--m01lab-box-gap, var(--spacing-12)); - padding: var(--spacing-8) var(--spacing-12); - border: 1px solid var(--color-border); - border-radius: var(--radius-lg); - background: var(--color-surface-raised); -} - -/* 합계 줄이 화면 바닥에 붙으려면 메인 칸이 굴림 칸(overflow:auto)이 아니어야 함 — 메인은 높이가 안 묶여 안 굴렀음 */ -.ui-workflow-layout__main:has(.m01lab__foot) { - overflow: clip; -} - -.m01lab__sums { - display: contents; -} - -/* 748-3 텍스트 수식 바닥 줄 = 세 칸(계 칸 없음) */ -.m01lab__foot[data-cols="3"] { - grid-template-columns: repeat(3, minmax(0, 1fr)); -} - /* 748-3 비목 상자 사이 간격 = 바닥 고정 줄 위 여유(같은 값 · 두 보기) */ .m01-logic__editor { --m01lab-box-gap: var(--spacing-12); } - -.m01lab__foot .ui-calc-row { - display: flex; - flex-direction: column; - align-items: stretch; - gap: 0; - min-height: 0; -} - -.m01lab__foot .ui-calc-row > :empty { - display: none; -} - -.m01lab__foot .ui-calc-row__out { - padding: 0; - text-align: left; -} - -.m01lab__foot .m01lab__total { - display: flex; - flex-direction: column; - margin: 0; - text-align: left; -} - -.m01lab__foot .m01lab__total > :first-child { - color: var(--color-text-secondary); - font-weight: var(--font-weight-regular, 400); -} - -.m01lab__foot .m01lab__total > :last-child { - font-variant-numeric: tabular-nums; -} diff --git a/M01_MasterData/M01_MasterData_UI_LogicLab_Text.ts b/M01_MasterData/M01_MasterData_UI_LogicLab_Text.ts index 2d69c4105..3176231c2 100644 --- a/M01_MasterData/M01_MasterData_UI_LogicLab_Text.ts +++ b/M01_MasterData/M01_MasterData_UI_LogicLab_Text.ts @@ -22,7 +22,6 @@ const TEXT = { ], View_Equation: ["수식", "Equation"], Subtotal: ["소계", "Subtotal"], - Total: ["계", "Total"], Extra: ["덧줄", "Extra"], Col_Name: ["이름", "Name"], Col_Unit: ["단위", "Unit"], diff --git a/M01_MasterData/M01_MasterData_UI_MachineDetail.ts b/M01_MasterData/M01_MasterData_UI_MachineDetail.ts index 44f689d12..5955d09f4 100644 --- a/M01_MasterData/M01_MasterData_UI_MachineDetail.ts +++ b/M01_MasterData/M01_MasterData_UI_MachineDetail.ts @@ -32,6 +32,7 @@ import { type MachineUses, } from "./M01_MasterData_Machine_Api"; import type { Pick } from "./M01_MasterData_UI_Side"; +import { openFindPicker } from "../M02_MasterTemplete/M02_MasterTemplete_Find_Pick"; export interface MachineDetailOptions { target: string; @@ -105,6 +106,7 @@ async function build(host: HTMLElement, opts: MachineDetailOptions, alive: () => const notice = el("div"); const form = createMachineSheet({ + find: openFindPicker, // 856-4 orig: (orig ?? cur) as Row, cur, mine: false, diff --git a/M01_MasterData/M01_MasterData_UI_Parts.ts b/M01_MasterData/M01_MasterData_UI_Parts.ts index 246e44db2..5a9db6e44 100644 --- a/M01_MasterData/M01_MasterData_UI_Parts.ts +++ b/M01_MasterData/M01_MasterData_UI_Parts.ts @@ -15,6 +15,7 @@ import { currentLanguageIndex } from "@ui/ui_template_locale"; import { createText } from "@ui/ui_template_text"; import { createStackScreen } from "../A00_Common/line_stack_screen"; import type { Pick } from "./M01_MasterData_UI_Side"; +import { openFindPicker } from "../M02_MasterTemplete/M02_MasterTemplete_Find_Pick"; interface Part { 키: string; @@ -47,6 +48,7 @@ export function renderParts(host: HTMLElement, pick: Pick, openLogic: (key: stri /** 줄 쌓기 읽기 창 — 고침 없음 · [단가산출 기초에서 열기] = 수식 탭에서 고침 */ const show = (p: Part): void => { partsStack ??= createStackScreen({ + find: openFindPicker, // 856-4 base: "/m01/logic/doc", admin: false, cache: "m01_parts_view", diff --git a/M02_MasterTemplete/DataFlow/M02_DF_Api.ts b/M02_MasterTemplete/DataFlow/M02_DF_Api.ts index bad809f25..b04f0da09 100644 --- a/M02_MasterTemplete/DataFlow/M02_DF_Api.ts +++ b/M02_MasterTemplete/DataFlow/M02_DF_Api.ts @@ -1,23 +1,11 @@ /* ============================================================================= * M02_DF_Api.ts - * 단위 표준 표 읽기 — 서버 `GET /api/m02/df/standards`(`M02_DF_Router.py`) - * 부르는 곳 = 단위 고르기(`M02_DF_UnitPick`) · 옵션 기계 이름(`formula_doc_options`) + * 기계 이름 · 끈 기계 읽기 — 서버 `GET /api/m02/df/machine-names` · `machine-off`(`M02_DF_Router.py`) + * 부르는 곳 = 옵션 기계 이름(`formula_doc_options`) · 단위 표준 표 읽기는 단위 고르기(`ui_template_unit_pick`)로 옮김(856-4) * ========================================================================== */ import { API_BASE_URL } from "@config/config_frontend"; -/** 단위 표준 표 */ -export interface CfStandards { - unit: { 이름: string; 줄: Record[]; [k: string]: unknown }; - saved: boolean; -} - -export async function cfStandards(): Promise { - const response = await fetch(`${API_BASE_URL}/m02/df/standards`, { credentials: "include" }); - if (!response.ok) throw new Error(`표준 표 읽기 실패 (${response.status})`); - return (await response.json()) as CfStandards; -} - let machineNames: Promise> | null = null; /** 기계 원문번호 → 「이름 규격」 — 한 번 받아 둠(못 받으면 빈 표 · 다음에 다시) */ diff --git a/M02_MasterTemplete/M02_MasterTemplete_Api_Fetch.ts b/M02_MasterTemplete/M02_MasterTemplete_Api_Fetch.ts index 2ec735fed..ebb143f0c 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Api_Fetch.ts +++ b/M02_MasterTemplete/M02_MasterTemplete_Api_Fetch.ts @@ -3,10 +3,10 @@ * 마스터 템플릿 서버 호출 — 계약 `6_계약.md` 서버 길 · 시스템 층은 시스템 관리자만 * ========================================================================== */ -import { API_BASE_URL } from "@config/config_frontend"; +import { call, type Layer } from "../common_util/common_util_m02_call"; -/** 층 이름 — 서버와 같은 글 */ -export type Layer = "system" | "company" | "personal" | "project"; +// 층 이름 · `/api/m02` 부름 = 공용 조각(856-4 — 줄 쌓기 공용 화면도 씀) · 여기서 그대로 내보냄 +export { call, StaleError, type Layer } from "../common_util/common_util_m02_call"; /** 서버 종류 — 화면의 「표 양식」 = table · 「도면 양식」 = drawing · 「구조물 도면」 = structure · * 「면적산출」 = area(구조물집계표 열마다 한 통합문서) · * 「일위대가」 = labor(열마다 문서 · 39장) · @@ -31,42 +31,6 @@ export interface TemplateDoc { 문서: unknown; } -/** 서버가 판 불일치로 막았을 때 · `detail` = 서버 몸 그대로(729-3 `{까닭, 남은줄}`) */ -export class StaleError extends Error { - constructor( - message: string, - readonly detail?: unknown, - ) { - super(message); - } -} - -/** `/api/m02` 아래 길 부름 — 409 = StaleError · 그 밖 실패 = 서버 까닭 글(하위 폴더도 씀) */ -export async function call(path: string, init: RequestInit = {}): Promise { - const response = await fetch(`${API_BASE_URL}/m02${path}`, { - credentials: "include", - headers: { "Content-Type": "application/json" }, - ...init, - }); - const body = (await response.json().catch(() => ({}))) as { detail?: unknown } & T; - if (response.status === 409) - throw new StaleError(reason(body.detail, response.status), body.detail); - if (!response.ok) throw new Error(reason(body.detail, response.status)); - return body; -} - -/** 서버가 막은 까닭 그대로 — 문장 · `{errors: [...]}` · 입력 검사 목록(`[{msg}]`) */ -function reason(detail: unknown, status: number): string { - if (typeof detail === "string") return detail; - const why = (detail as { 까닭?: unknown } | null)?.까닭; - if (typeof why === "string") return why; - const list = Array.isArray(detail) ? detail : (detail as { errors?: unknown } | null)?.errors; - const lines = Array.isArray(list) - ? list.map((x) => (typeof x === "string" ? x : String((x as { msg?: unknown })?.msg ?? ""))) - : []; - return lines.filter(Boolean).join(" · ") || `HTTP ${status}`; -} - /** 지금 화면의 층 — 시스템 · 회사 · 개인 모두 `/layers/{층}` 아래(구조물집계표 · 조합 길 모두 · 읽기는 * 로그인 누구나 · 쓰기는 서버 층 권한 · 옛 `/api/m02/templates/*` 는 시스템 관리자 전용이라 안 씀) · * `owner` = 남의 층을 볼 때 주인(회사 `{C}` · 개인 `{C}/{U}` · 자기 층 = null · PLAN 27-1c) — diff --git a/M02_MasterTemplete/M02_MasterTemplete_Find_Pick.ts b/M02_MasterTemplete/M02_MasterTemplete_Find_Pick.ts index 45ebc0f92..70a6874b3 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Find_Pick.ts +++ b/M02_MasterTemplete/M02_MasterTemplete_Find_Pick.ts @@ -46,6 +46,7 @@ import { listLayerDocs, SANGEUN_KIND, type SangeunRow } from "./M02_MasterTemple import { logicHeads as heads } from "./logic/M02_Find_Heads"; import "../M01_MasterData/M01_MasterData_UI_Logic_Style.css"; // 창 겉틀 import "./M02_MasterTemplete_Labor.css"; +import type { StackFindKind } from "../A00_Common/line_stack_pick"; type Scope = Omit; type Tab = "m01" | "sk" | "pre"; @@ -66,7 +67,7 @@ export interface M01Element { } /** 고를 수 있는 종류 — logic = M01 단가산출 · 기초 로직 · labor = 인력 · material = 재료 · machine = 기계 · sk = M02 단가산출 · pre = 일위대가 */ -export type FindKind = "logic" | "labor" | "material" | "machine" | "oil" | "sk" | "pre"; +export type FindKind = StackFindKind; // 856-4 — 공용 줄 쌓기 창 종류와 한 벌 export interface FindPickOptions { layer: Layer; diff --git a/M02_MasterTemplete/M02_MasterTemplete_Hopyo_MatPick.ts b/M02_MasterTemplete/M02_MasterTemplete_Hopyo_MatPick.ts index e0187ecb4..871a88497 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Hopyo_MatPick.ts +++ b/M02_MasterTemplete/M02_MasterTemplete_Hopyo_MatPick.ts @@ -21,6 +21,7 @@ import { openStackPick } from "../A00_Common/line_stack_pick"; import { call } from "./M02_MasterTemplete_Api_Fetch"; import { at, type HopyoScope } from "./M02_MasterTemplete_Hopyo_Api"; import { placeNote } from "../M01_MasterData/M01_MasterData_Api_Fetch"; +import { openFindPicker } from "./M02_MasterTemplete_Find_Pick"; export interface MatCand { 키: string; @@ -120,6 +121,7 @@ export function createMatPick(opt: { scope: HopyoScope; key: string; target: Hop iconStart: "search", onClick: () => openStackPick( + openFindPicker, "재료", (p) => set(k, { 키: p.키, 이름: p.이름, 규격: p.규격 ?? "", 단위: p.단위 ?? "" }), undefined, diff --git a/M02_MasterTemplete/M02_MasterTemplete_Labor_Table.ts b/M02_MasterTemplete/M02_MasterTemplete_Labor_Table.ts index 8646e833f..cbddeba71 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Labor_Table.ts +++ b/M02_MasterTemplete/M02_MasterTemplete_Labor_Table.ts @@ -53,7 +53,7 @@ import { openMatModal, openRowModal } from "./M02_MasterTemplete_Labor_RowModal" import { tc } from "./M02_MasterTemplete_Labor_Text"; import { insideKeys } from "./M02_Labor_LogicMats_Model"; import { valueLine } from "./M02_Labor_Values_Model"; -import { createUnitPick, NO_UNIT } from "./DataFlow/M02_DF_UnitPick"; +import { createUnitPick, NO_UNIT } from "@ui/ui_template_unit_pick"; import { libMeta } from "./M02_MasterTemplete_Labor_LibMeta"; import "../M01_MasterData/M01_MasterData_UI_Logic_Style.css"; import "../M01_MasterData/M01_MasterData_UI_LogicLab_Style.css"; diff --git a/M02_MasterTemplete/M02_MasterTemplete_Sangeun_Tabs.ts b/M02_MasterTemplete/M02_MasterTemplete_Sangeun_Tabs.ts index 9cc07c8c6..47b618ffd 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Sangeun_Tabs.ts +++ b/M02_MasterTemplete/M02_MasterTemplete_Sangeun_Tabs.ts @@ -10,6 +10,7 @@ import { createStackScreen } from "../A00_Common/line_stack_screen"; import { el } from "@ui/ui_template_elements"; import type { Layer } from "./M02_MasterTemplete_Api_Fetch"; +import { openFindPicker } from "./M02_MasterTemplete_Find_Pick"; export interface SkEquationOptions { scope: { layer: Layer; owner: string | null }; @@ -48,6 +49,7 @@ export function createSangeunTabs(opt: SkEquationOptions): { } { const tools = el("span", { className: "m02-sk__tools", attrs: { "data-sk-tools": "" } }); // [단가 갱신] · [재생성](808-1) const stack = createStackScreen({ + find: openFindPicker, // 856-4 찾아 넣기 창 base: "", admin: opt.edit, cache: "m02_sk_doc_drafts", diff --git a/M02_MasterTemplete/M02_Material_Pick.ts b/M02_MasterTemplete/M02_Material_Pick.ts index f897cf044..c9eb8297c 100644 --- a/M02_MasterTemplete/M02_Material_Pick.ts +++ b/M02_MasterTemplete/M02_Material_Pick.ts @@ -12,7 +12,7 @@ import { createButton, createInputField, el, showToast } from "@ui/ui_template_e import { openModal } from "@ui/ui_template_modal"; import { searchMaterials } from "../M01_MasterData/M01_MasterData_Api_Fetch"; import { call } from "./M02_MasterTemplete_Api_Fetch"; -import { createUnitPick, NO_UNIT } from "./DataFlow/M02_DF_UnitPick"; +import { createUnitPick, NO_UNIT } from "@ui/ui_template_unit_pick"; import { createBadge } from "@ui/ui_template_badge"; import { createText } from "@ui/ui_template_text"; import { createEmpty } from "@ui/ui_template_empty"; diff --git a/M02_MasterTemplete/M02_MyMachine_Form.ts b/M02_MasterTemplete/M02_MyMachine_Form.ts index bdb9f5941..4a5b312b8 100644 --- a/M02_MasterTemplete/M02_MyMachine_Form.ts +++ b/M02_MasterTemplete/M02_MyMachine_Form.ts @@ -37,6 +37,7 @@ import { StaleError } from "./M02_MasterTemplete_Api_Fetch"; import { confirmMyMachineImpact } from "./M02_MyMachine_Impact"; import { mt } from "./M02_MyMachine_Text"; import "./M02_MyMachine.css"; +import { openFindPicker } from "./M02_MasterTemplete_Find_Pick"; export interface MyMachineFormOptions { owner: string | null; @@ -109,6 +110,7 @@ export async function mountMyMachineForm( let m01Same = false; const sheet = createMachineSheet({ + find: openFindPicker, // 856-4 orig: start, mine: true, readOnly: false, diff --git a/M02_MasterTemplete/M02_MyMaterial_View.ts b/M02_MasterTemplete/M02_MyMaterial_View.ts index 165178c89..7e92db159 100644 --- a/M02_MasterTemplete/M02_MyMaterial_View.ts +++ b/M02_MasterTemplete/M02_MyMaterial_View.ts @@ -12,7 +12,7 @@ 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 { createText } from "@ui/ui_template_text"; -import { createUnitPick, NO_UNIT } from "./DataFlow/M02_DF_UnitPick"; +import { createUnitPick, NO_UNIT } from "@ui/ui_template_unit_pick"; import { addMyMaterial, dropMyMaterial, diff --git a/common_util/common_util_m02_call.ts b/common_util/common_util_m02_call.ts new file mode 100644 index 000000000..04053dbd4 --- /dev/null +++ b/common_util/common_util_m02_call.ts @@ -0,0 +1,47 @@ +/* ============================================================================= + * common_util_m02_call.ts + * M02 서버 길 부름(PLAN 856-4) — 층 이름 · `/api/m02` 아래 부름 한 함수 · 409 = 판 다름. + * M02 화면(`M02_MasterTemplete_Api_Fetch` 가 그대로 내보냄)과 공용 줄 쌓기 화면(`A00_Common/line_stack_*`)이 같이 씀 + * — 공용 화면이 M02 를 거꾸로 부르지 않게 + * ========================================================================== */ + +import { API_BASE_URL } from "@config/config_frontend"; + +/** 층 이름 — 서버와 같은 글 */ +export type Layer = "system" | "company" | "personal" | "project"; + +/** 서버가 판 불일치로 막았을 때 · `detail` = 서버 몸 그대로(729-3 `{까닭, 남은줄}`) */ +export class StaleError extends Error { + constructor( + message: string, + readonly detail?: unknown, + ) { + super(message); + } +} + +/** `/api/m02` 아래 길 부름 — 409 = StaleError · 그 밖 실패 = 서버 까닭 글(하위 폴더도 씀) */ +export async function call(path: string, init: RequestInit = {}): Promise { + const response = await fetch(`${API_BASE_URL}/m02${path}`, { + credentials: "include", + headers: { "Content-Type": "application/json" }, + ...init, + }); + const body = (await response.json().catch(() => ({}))) as { detail?: unknown } & T; + if (response.status === 409) + throw new StaleError(reason(body.detail, response.status), body.detail); + if (!response.ok) throw new Error(reason(body.detail, response.status)); + return body; +} + +/** 서버가 막은 까닭 그대로 — 문장 · `{errors: [...]}` · 입력 검사 목록(`[{msg}]`) */ +function reason(detail: unknown, status: number): string { + if (typeof detail === "string") return detail; + const why = (detail as { 까닭?: unknown } | null)?.까닭; + if (typeof why === "string") return why; + const list = Array.isArray(detail) ? detail : (detail as { errors?: unknown } | null)?.errors; + const lines = Array.isArray(list) + ? list.map((x) => (typeof x === "string" ? x : String((x as { msg?: unknown })?.msg ?? ""))) + : []; + return lines.filter(Boolean).join(" · ") || `HTTP ${status}`; +} diff --git a/resources/tester/helper_845_2_unit_show.cjs b/resources/tester/helper_845_2_unit_show.cjs index 733b5d592..03893f2d1 100644 --- a/resources/tester/helper_845_2_unit_show.cjs +++ b/resources/tester/helper_845_2_unit_show.cjs @@ -213,7 +213,7 @@ const noop = () => undefined; const load = makeLoader({ katex: { render: (t, box) => (box.tex = t) }, formula_doc_options: { machineText: () => null, optionText: (x) => x, liveOptions: (l) => l, nameMachines: noop }, - M02_DF_UnitPick: { + ui_template_unit_pick: { NO_UNIT: "(단위 없음)", createUnitPick: (o) => Object.assign(new FakeNode("select"), { value: o.value }), }, diff --git a/resources/tester/helper_856_0_sk_screen.cjs b/resources/tester/helper_856_0_sk_screen.cjs index ed636c290..3cb4c1ce2 100644 --- a/resources/tester/helper_856_0_sk_screen.cjs +++ b/resources/tester/helper_856_0_sk_screen.cjs @@ -198,7 +198,7 @@ const stubs = { M02_MasterTemplete_Labor_Grid: { laborBlock: (cur) => ({ lines: cur.담은로직.map(() => ({ note: "", amounts: { sum: 1 } })) }), }, - M02_DF_UnitPick: { createUnitPick: () => box("div"), NO_UNIT: "-" }, + ui_template_unit_pick: { createUnitPick: () => box("div"), NO_UNIT: "-" }, M02_MasterTemplete_Labor_Unlinked: { unlinkedBar: () => null }, M02_MasterTemplete_Labor_Text: { tc: (k) => k }, M02_MasterTemplete_Labor_LibMeta: { libMeta: () => [] }, diff --git a/resources/tester/test_721_find_pick.py b/resources/tester/test_721_find_pick.py index f0004d1df..a3f8bdd86 100644 --- a/resources/tester/test_721_find_pick.py +++ b/resources/tester/test_721_find_pick.py @@ -121,7 +121,6 @@ def test_736_1_항목_추가_찾기_창_하나(): assert "material: lib.material," in pick find = _text(M02 / "M02_MasterTemplete_Find_Pick.ts") assert 'kind === "재료" && opt.material' in find and "? opt.material" in find - assert '"logic" | "labor" | "material" | "machine" | "oil" | "sk" | "pre"' in find # 785-3 oil def test_736_2_빠진_길_둘_신규_자재_기계_탭(): diff --git a/resources/tester/test_737_option_grid_foot.py b/resources/tester/test_737_option_grid_foot.py index a7961ddf3..a3aba2396 100644 --- a/resources/tester/test_737_option_grid_foot.py +++ b/resources/tester/test_737_option_grid_foot.py @@ -4,9 +4,7 @@ import re from pathlib import Path ROOT = Path(__file__).resolve().parents[2] -M01 = ROOT / "M01_MasterData" SHEET_CSS = (ROOT / "A00_Common" / "calc_sheet.css").read_text(encoding="utf-8") -STYLE = (M01 / "M01_MasterData_UI_LogicLab_Style.css").read_text(encoding="utf-8") def test_옵션_격자_폭_따라_6_4_3_2_1(): @@ -18,12 +16,3 @@ def test_옵션_격자_폭_따라_6_4_3_2_1(): assert "container-type: inline-size" in SHEET_CSS # 창 폭이 아니라 상자 폭 기준 -def test_합계_한_줄_바닥_고정(): - foot = STYLE[STYLE.index(".m01lab__foot {") :] - foot = foot[: foot.index("}")] - assert "position: sticky" in foot and "bottom: 0" in foot - assert "repeat(4, minmax(0, 1fr))" in foot - assert "overflow: clip" in STYLE # 메인 칸이 굴림 칸이면 바닥에 안 붙음 - foot_ts = (M01 / "M01_MasterData_UI_LogicLab_Foot.ts").read_text(encoding="utf-8") - assert 'className: "m01lab__foot"' in foot_ts # 748-3 두 보기가 같은 바닥 줄 부품 - assert 'data-cols="3"' in STYLE diff --git a/resources/tester/test_804_7_line_stack_fix.py b/resources/tester/test_804_7_line_stack_fix.py index d03a712e2..e90adcd4b 100644 --- a/resources/tester/test_804_7_line_stack_fix.py +++ b/resources/tester/test_804_7_line_stack_fix.py @@ -177,7 +177,7 @@ def test_요소키_기호_이름_0_전수() -> None: def test_단위_고르기_공용_친글() -> None: edit = _src("A00_Common/line_stack_edit.ts") assert "createUnitPick({" in edit and "free: true," in edit - pick = _src("M02_MasterTemplete/DataFlow/M02_DF_UnitPick.ts") + pick = _src("ui_template/ui_template_unit_pick.ts") assert "if (opts.free && typed && !all.includes(typed)) shown.push(typed);" in pick main = _src("main.py") at = main.index("M02_MasterTemplete.DataFlow.M02_DF_Router") @@ -275,7 +275,7 @@ def test_단위표_더한_단위_문서_전수() -> None: assert len(lines) > 5000 missing = {u for u in lines if u and same.get(u, u) not in units} assert not missing, missing - pick = _src("M02_MasterTemplete/DataFlow/M02_DF_UnitPick.ts") + pick = _src("ui_template/ui_template_unit_pick.ts") assert ( '...(table["더한 단위"] ?? []),' in pick and '(u && table["같은 단위"]?.[u]) || u' in pick ) diff --git a/resources/tester/ui_checks/51-5_단위단추_크기.js b/resources/tester/ui_checks/51-5_단위단추_크기.js index 9fd87f7d3..f5760dbeb 100644 --- a/resources/tester/ui_checks/51-5_단위단추_크기.js +++ b/resources/tester/ui_checks/51-5_단위단추_크기.js @@ -1,4 +1,4 @@ -/* 51-5 — 단위 고르기 단추(공용 M02_DF_UnitPick) 높이 · 글자 = [저장] 단추와 같음 +/* 51-5 — 단위 고르기 단추(공용 ui_template_unit_pick) 높이 · 글자 = [저장] 단추와 같음 * 시작 화면: M02 마스터 템플릿 · 마스터 층(#/m02-master-template?open=구조물조합&root=master) · 시스템 관리자 * 부르는 법: orca eval --expression "$(tr '\n' ' ' < 이 파일)" (async 식 · JSON 글을 돌려줌) * 하는 일: item1 → 일위대가 [수정] 상세 → 단위 단추 · [저장] 단추 높이 · 글자 크기 잼 diff --git a/ui_template/ui_template_unit_pick.ts b/ui_template/ui_template_unit_pick.ts index 74492291e..aa4ffb249 100644 --- a/ui_template/ui_template_unit_pick.ts +++ b/ui_template/ui_template_unit_pick.ts @@ -1,6 +1,6 @@ /* ============================================================================= - * M02_DF_UnitPick.ts - * 단가산출 흐름도 공용 단위 고르기 — 치면 걸러진 목록 · 고르기만(손글 안 받음 · `free` = 목록에 없는 친 글도 씀) · 「-」 = 없음 + * ui_template_unit_pick.ts + * 공용 단위 고르기(856-4 — 옛 M02 `DataFlow/M02_DF_UnitPick`) — 치면 걸러진 목록 · 고르기만(손글 안 받음 · `free` = 목록에 없는 친 글도 씀) · 「-」 = 없음 * 목록 = 단위 표준(산림품셈 1-2-2) 단위 + 표의 「더한 단위」(수식 문서 줄 단위) + 부른 쪽이 주는 마스터 결과단위 등 + 원 · 「같은 단위」(kg → ㎏) 는 하나만 * 표준 표 읽는 길은 `setUnitSource` 로 바꿔 끼움(기본 = 서버 /standards) — 다른 판도 이것을 씀 * 글 [한, 영] 짝은 아래 TEXT @@ -9,8 +9,8 @@ import { currentLanguageIndex } from "@ui/ui_template_locale"; import { createButton, el } from "@ui/ui_template_elements"; import type { UiSize } from "@ui/ui_template_button"; -import { cfStandards } from "./M02_DF_Api"; -import "./M02_DF_UnitPick.css"; +import { API_BASE_URL } from "@config/config_frontend"; +import "./ui_template_unit_pick.css"; import { createEmpty } from "@ui/ui_template_empty"; import "@ui/ui_template_list_row.css"; @@ -22,6 +22,18 @@ const TEXT = { Pick: ["단위 고르기", "Pick a unit"], } as const; +/** 단위 표준 표 */ +interface CfStandards { + unit: { 이름: string; 줄: Record[]; [k: string]: unknown }; + saved: boolean; +} + +async function cfStandards(): Promise { + const response = await fetch(`${API_BASE_URL}/m02/df/standards`, { credentials: "include" }); + if (!response.ok) throw new Error(`표준 표 읽기 실패 (${response.status})`); + return (await response.json()) as CfStandards; +} + const tu = (key: keyof typeof TEXT): string => TEXT[key][currentLanguageIndex === 1 ? 1 : 0]; /** 「없음」 을 뜻하는 단위 글 */