From 0331bb4db2066a96cff0efe769894e066b2c87c2 Mon Sep 17 00:00:00 2001 From: umsangdon Date: Sun, 20 Sep 2026 23:14:02 +0900 Subject: [PATCH] =?UTF-8?q?feat(M01):=20=EC=86=8C=EC=9A=94=EB=9F=89/?= =?UTF-8?q?=EA=B3=84=EC=88=98=20=E3=80=8C=EC=93=B0=EB=8A=94=20=EB=A1=9C?= =?UTF-8?q?=EC=A7=81=E3=80=8D=20=ED=82=A4=EB=A5=BC=20=EB=88=84=EB=A5=B4?= =?UTF-8?q?=EB=A9=B4=20=EB=A1=9C=EC=A7=81=20=ED=83=AD=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EA=B7=B8=20=EB=A1=9C=EC=A7=81=20=EB=B0=94=EB=A1=9C=20=EC=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Logic_Page 에 openKey 초기 인자 + LogicHandle.openKey 추가(이미 연 뒤에도 재호출 가능) Page.ts 는 복사 안내 대신 로직 탭 전환과 동시에 그 로직을 엶 --- .../M01_MasterData_UI_Logic_Page.ts | 23 ++++++++++++++++++- M01_MasterData/M01_MasterData_UI_Page.ts | 17 ++++++-------- ui_template/ui_template_locale_m1.ts | 4 ---- 3 files changed, 29 insertions(+), 15 deletions(-) diff --git a/M01_MasterData/M01_MasterData_UI_Logic_Page.ts b/M01_MasterData/M01_MasterData_UI_Logic_Page.ts index 92589788..0de623fd 100644 --- a/M01_MasterData/M01_MasterData_UI_Logic_Page.ts +++ b/M01_MasterData/M01_MasterData_UI_Logic_Page.ts @@ -27,6 +27,7 @@ import { type ElementBrief, type LogicFile, type LogicRow, + type LogicSummary, type SaveFile, } from "./M01_MasterData_UI_Logic_Api"; import { buildCalc } from "./M01_MasterData_UI_Logic_Calc"; @@ -68,7 +69,16 @@ function loadDrafts(): Record { } } -export async function mountM01Logic(host: HTMLElement, side: SideHandle): Promise { +export interface LogicHandle { + /** 밖(요소 화면)에서 이 키를 바로 엶 — 소요량·계수 표의 「쓰는 로직」 눌렀을 때. */ + openKey: (key: string) => Promise; +} + +export async function mountM01Logic( + host: HTMLElement, + side: SideHandle, + openKey?: string, +): Promise { let drafts = loadDrafts(); let files: LogicFile[] = []; let opened: Opened | null = null; @@ -220,6 +230,8 @@ export async function mountM01Logic(host: HTMLElement, side: SideHandle): Promis } }; + let allLogics: LogicSummary[] = []; + const reload = async (): Promise => { const [logics, logicFiles, subs] = await Promise.all([ fetchLogics(), @@ -227,6 +239,7 @@ export async function mountM01Logic(host: HTMLElement, side: SideHandle): Promis fetchLogicSubs(), ]); files = logicFiles; + allLogics = logics; list.setItems(logics); // 왼쪽 「전체」 + 구분 → 상세구분 거름 — 고르면 목록으로 돌아와 그 범위만 filterHost.replaceChildren( @@ -390,11 +403,19 @@ export async function mountM01Logic(host: HTMLElement, side: SideHandle): Promis side.logicHost.replaceChildren(filterHost); show(null); showLoadingOverlay(); + const openKeyOn = async (key: string): Promise => { + const found = allLogics.find((x) => x.키 === key); + if (found) await open(logicId(found.구분, found.키), found.구분, found.키); + else showToast(tx("Load_Failed"), "error"); + }; + try { await reload(); + if (openKey) await openKeyOn(openKey); } catch (error) { showToast(error instanceof Error ? error.message : tx("Load_Failed"), "error"); } finally { hideLoadingOverlay(); } + return { openKey: openKeyOn }; } diff --git a/M01_MasterData/M01_MasterData_UI_Page.ts b/M01_MasterData/M01_MasterData_UI_Page.ts index 61a863fc..2dab4fc7 100644 --- a/M01_MasterData/M01_MasterData_UI_Page.ts +++ b/M01_MasterData/M01_MasterData_UI_Page.ts @@ -33,6 +33,7 @@ import { type Pick, } from "./M01_MasterData_UI_Side"; import { renderTables } from "./M01_MasterData_UI_Tables"; +import type { LogicHandle } from "./M01_MasterData_UI_Logic_Page"; import "./M01_MasterData_UI_Style.css"; const TABLE_GROUPS = ["소요량", "계수"]; @@ -174,13 +175,9 @@ function buildPage(): HTMLElement { return [L("M01_Stale").replace("{value}", stale.map(fileLabel).join(", ")), again]; }; - /** 로직 탭으로 전환 — `key` 가 있으면 들고 가서 로직 목록 찾기 칸에 넣으라고 안내 - * (로직 목록이 직접 그 키를 열지는 못함 — 로직 부분은 sub1 담당 파일). */ - const notifyLogicKey = (key: string): void => { - navigator.clipboard?.writeText(key).catch(() => undefined); - showToast(L("M01_LogicKeyCopy").replace("{value}", key), "success"); - }; + let logicHandle: LogicHandle | null = null; + /** 로직 탭으로 전환 — `key` 가 있으면 그 로직을 바로 엶. */ const openLogicTab = (key?: string): void => { if (key) setPendingLogicKey(key); dispose(); @@ -188,14 +185,14 @@ function buildPage(): HTMLElement { current = null; showMode("logic"); if (logicMounted) { - if (key) notifyLogicKey(key); + const pending = takePendingLogicKey(); + if (pending) void logicHandle?.openKey(pending); return; } logicMounted = true; - void import("./M01_MasterData_UI_Logic_Page").then((m) => { - void m.mountM01Logic(logicHost, side); + void import("./M01_MasterData_UI_Logic_Page").then(async (m) => { const pending = takePendingLogicKey(); - if (pending) notifyLogicKey(pending); + logicHandle = await m.mountM01Logic(logicHost, side, pending ?? undefined); }); }; diff --git a/ui_template/ui_template_locale_m1.ts b/ui_template/ui_template_locale_m1.ts index 3b4af4f0..3d0af7c7 100644 --- a/ui_template/ui_template_locale_m1.ts +++ b/ui_template/ui_template_locale_m1.ts @@ -64,10 +64,6 @@ export const ui_locales_m1 = { M01_TableUsage: ["용도", "Usage"], M01_TableUsageLogicCount: ["로직 {value}개", "{value} logic rules"], M01_OpenLogic: ["눌러 로직 탭으로", "Click to jump to the Logic tab"], - M01_LogicKeyCopy: [ - "로직 탭으로 이동 — 키 {value} 복사함(찾기에 붙여넣을 것)", - "Switched to Logic tab — copied key {value} (paste it into the search box)", - ], M01_GroupLabor: ["인력", "Labor"], M01_GroupMaterial: ["재료", "Materials"], M01_GroupMachine: ["기계", "Machines"],