diff --git a/M02_MasterTemplete/M02_MasterTemplete_Hopyo.css b/M02_MasterTemplete/M02_MasterTemplete_Hopyo.css index 3529b36c5..0d12c6877 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Hopyo.css +++ b/M02_MasterTemplete/M02_MasterTemplete_Hopyo.css @@ -306,6 +306,10 @@ white-space: normal; } +.m02-hopyo__lines .m02-labrow__name > small { + display: block; +} + .m02-hopyo__lines td.m02-hopyo__compare { min-width: 7em; white-space: pre-line; diff --git a/M02_MasterTemplete/M02_MasterTemplete_Hopyo_CheckRows.ts b/M02_MasterTemplete/M02_MasterTemplete_Hopyo_CheckRows.ts index cfcdfe272..15038eb23 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Hopyo_CheckRows.ts +++ b/M02_MasterTemplete/M02_MasterTemplete_Hopyo_CheckRows.ts @@ -263,13 +263,13 @@ const grid = (heads: HTMLElement[], rows: HTMLElement[], kind: string): HTMLElem export function checkTables(rows: JudgeRow[], ctx: CheckCtx): HTMLElement[] { const logic = rows.filter((r) => tableOf(r, ctx.kit.picksOf(r)) === "logic"); const mat = rows.filter((r) => !logic.includes(r)); - const first = [head(L("M02_JudgeColOk"), true), head(L("M02_JudgeColRow"))]; + const first = (): HTMLElement[] => [head(L("M02_JudgeColOk"), true), head(L("M02_JudgeColRow"))]; // 표마다 새 노드 const out: HTMLElement[] = []; if (logic.length) out.push( grid( [ - ...first, + ...first(), head(`${tc("Sub")} · ${L("M02_JudgeColVerdict")}`, true), head(`${tc("Col_Name")} · ${L("M02_JudgeColPick")}`, true), head(tc("Col_Alias")), @@ -288,7 +288,7 @@ export function checkTables(rows: JudgeRow[], ctx: CheckCtx): HTMLElement[] { el("h4", { className: "m02-hopyo__subhead", text: L("M02_CheckMat") }), grid( [ - ...first, + ...first(), head(tc("Labor_Code")), head(`${tc("Col_Name")} · ${L("M02_JudgeColPick")}`, true), head(tc("Labor_Spec")), diff --git a/M02_MasterTemplete/M02_MasterTemplete_Hopyo_ToItem.ts b/M02_MasterTemplete/M02_MasterTemplete_Hopyo_ToItem.ts index 71bae1765..1bb676024 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Hopyo_ToItem.ts +++ b/M02_MasterTemplete/M02_MasterTemplete_Hopyo_ToItem.ts @@ -11,8 +11,10 @@ import { createInputField } from "@ui/ui_template_input"; import { t as L } from "@ui/ui_template_locale"; import { openModal } from "@ui/ui_template_modal"; import { createText } from "@ui/ui_template_text"; +import { fetchSessionUser } from "../A06_Login/A06_Login_Api_Fetch"; import { editTree, fetchTree, readTemplate, saveTemplate } from "./M02_MasterTemplete_Api_Fetch"; import type { HopyoScope } from "./M02_MasterTemplete_Hopyo_Api"; +import { ownOwner } from "./M02_MasterTemplete_Layer"; /** 만든 항목이 놓이는 폴더 */ export const ITEM_PATH = ["실무자료"]; @@ -33,16 +35,33 @@ export async function makeItem(o: ToItemOptions, label: string): Promise const made = await editTree(layer, { op: "add-item", 경로: ITEM_PATH, 이름: label, 단위: o.unit }, tree.판, owner); // prettier-ignore const col = [made.알림?.열].flat()[0]; if (!col) throw new Error(L("M02_CheckToItemFail")); + try { + await fillLabor(o, col); + } catch (e) { + // 일위대가 못 담음 = 빈 항목 남기지 않음(방금 더한 항목만 지움) + await editTree(layer, { op: "delete", 키: col }, made.판, owner).catch(() => null); + throw e; + } + return col; +} + +/** 새 항목 일위대가 문서 = SC 참조 한 줄 */ +async function fillLabor(o: ToItemOptions, col: string): Promise { + const { layer, owner } = o.target; const now = await readTemplate(layer, "labor", col, null, owner); const doc = (now.문서 ?? {}) as Record; + // 참조 주인 = 실제 주인 id(개인 「회사/사용자」 · 자기 층이면 세션에서 · `Find_Pick.upper` 와 같은 길) + const who = + layer === "system" || layer === "project" + ? null + : (owner ?? ownOwner(layer, await fetchSessionUser())); const line = { - 참조: { 층: layer, 주인: owner, 키: o.sc }, + 참조: { 층: layer, 주인: who, 키: o.sc }, 별칭: null, 메모: null, 수량: { 손: 1 }, }; await saveTemplate(layer, "labor", col, null, now.판 ?? "", { ...doc, 담은로직: [line], 단위: o.unit || doc.단위 || null }, owner); // prettier-ignore - return col; } export function toItem(o: ToItemOptions): void {