feat(M01): 소요량/계수 「쓰는 로직」 키를 누르면 로직 탭에서 그 로직 바로 엶
Logic_Page 에 openKey 초기 인자 + LogicHandle.openKey 추가(이미 연 뒤에도 재호출 가능) Page.ts 는 복사 안내 대신 로직 탭 전환과 동시에 그 로직을 엶
This commit is contained in:
@@ -27,6 +27,7 @@ import {
|
|||||||
type ElementBrief,
|
type ElementBrief,
|
||||||
type LogicFile,
|
type LogicFile,
|
||||||
type LogicRow,
|
type LogicRow,
|
||||||
|
type LogicSummary,
|
||||||
type SaveFile,
|
type SaveFile,
|
||||||
} from "./M01_MasterData_UI_Logic_Api";
|
} from "./M01_MasterData_UI_Logic_Api";
|
||||||
import { buildCalc } from "./M01_MasterData_UI_Logic_Calc";
|
import { buildCalc } from "./M01_MasterData_UI_Logic_Calc";
|
||||||
@@ -68,7 +69,16 @@ function loadDrafts(): Record<string, Draft> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function mountM01Logic(host: HTMLElement, side: SideHandle): Promise<void> {
|
export interface LogicHandle {
|
||||||
|
/** 밖(요소 화면)에서 이 키를 바로 엶 — 소요량·계수 표의 「쓰는 로직」 눌렀을 때. */
|
||||||
|
openKey: (key: string) => Promise<void>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function mountM01Logic(
|
||||||
|
host: HTMLElement,
|
||||||
|
side: SideHandle,
|
||||||
|
openKey?: string,
|
||||||
|
): Promise<LogicHandle> {
|
||||||
let drafts = loadDrafts();
|
let drafts = loadDrafts();
|
||||||
let files: LogicFile[] = [];
|
let files: LogicFile[] = [];
|
||||||
let opened: Opened | null = null;
|
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<void> => {
|
const reload = async (): Promise<void> => {
|
||||||
const [logics, logicFiles, subs] = await Promise.all([
|
const [logics, logicFiles, subs] = await Promise.all([
|
||||||
fetchLogics(),
|
fetchLogics(),
|
||||||
@@ -227,6 +239,7 @@ export async function mountM01Logic(host: HTMLElement, side: SideHandle): Promis
|
|||||||
fetchLogicSubs(),
|
fetchLogicSubs(),
|
||||||
]);
|
]);
|
||||||
files = logicFiles;
|
files = logicFiles;
|
||||||
|
allLogics = logics;
|
||||||
list.setItems(logics);
|
list.setItems(logics);
|
||||||
// 왼쪽 「전체」 + 구분 → 상세구분 거름 — 고르면 목록으로 돌아와 그 범위만
|
// 왼쪽 「전체」 + 구분 → 상세구분 거름 — 고르면 목록으로 돌아와 그 범위만
|
||||||
filterHost.replaceChildren(
|
filterHost.replaceChildren(
|
||||||
@@ -390,11 +403,19 @@ export async function mountM01Logic(host: HTMLElement, side: SideHandle): Promis
|
|||||||
side.logicHost.replaceChildren(filterHost);
|
side.logicHost.replaceChildren(filterHost);
|
||||||
show(null);
|
show(null);
|
||||||
showLoadingOverlay();
|
showLoadingOverlay();
|
||||||
|
const openKeyOn = async (key: string): Promise<void> => {
|
||||||
|
const found = allLogics.find((x) => x.키 === key);
|
||||||
|
if (found) await open(logicId(found.구분, found.키), found.구분, found.키);
|
||||||
|
else showToast(tx("Load_Failed"), "error");
|
||||||
|
};
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await reload();
|
await reload();
|
||||||
|
if (openKey) await openKeyOn(openKey);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
showToast(error instanceof Error ? error.message : tx("Load_Failed"), "error");
|
showToast(error instanceof Error ? error.message : tx("Load_Failed"), "error");
|
||||||
} finally {
|
} finally {
|
||||||
hideLoadingOverlay();
|
hideLoadingOverlay();
|
||||||
}
|
}
|
||||||
|
return { openKey: openKeyOn };
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ import {
|
|||||||
type Pick,
|
type Pick,
|
||||||
} from "./M01_MasterData_UI_Side";
|
} from "./M01_MasterData_UI_Side";
|
||||||
import { renderTables } from "./M01_MasterData_UI_Tables";
|
import { renderTables } from "./M01_MasterData_UI_Tables";
|
||||||
|
import type { LogicHandle } from "./M01_MasterData_UI_Logic_Page";
|
||||||
import "./M01_MasterData_UI_Style.css";
|
import "./M01_MasterData_UI_Style.css";
|
||||||
|
|
||||||
const TABLE_GROUPS = ["소요량", "계수"];
|
const TABLE_GROUPS = ["소요량", "계수"];
|
||||||
@@ -174,13 +175,9 @@ function buildPage(): HTMLElement {
|
|||||||
return [L("M01_Stale").replace("{value}", stale.map(fileLabel).join(", ")), again];
|
return [L("M01_Stale").replace("{value}", stale.map(fileLabel).join(", ")), again];
|
||||||
};
|
};
|
||||||
|
|
||||||
/** 로직 탭으로 전환 — `key` 가 있으면 들고 가서 로직 목록 찾기 칸에 넣으라고 안내
|
let logicHandle: LogicHandle | null = null;
|
||||||
* (로직 목록이 직접 그 키를 열지는 못함 — 로직 부분은 sub1 담당 파일). */
|
|
||||||
const notifyLogicKey = (key: string): void => {
|
|
||||||
navigator.clipboard?.writeText(key).catch(() => undefined);
|
|
||||||
showToast(L("M01_LogicKeyCopy").replace("{value}", key), "success");
|
|
||||||
};
|
|
||||||
|
|
||||||
|
/** 로직 탭으로 전환 — `key` 가 있으면 그 로직을 바로 엶. */
|
||||||
const openLogicTab = (key?: string): void => {
|
const openLogicTab = (key?: string): void => {
|
||||||
if (key) setPendingLogicKey(key);
|
if (key) setPendingLogicKey(key);
|
||||||
dispose();
|
dispose();
|
||||||
@@ -188,14 +185,14 @@ function buildPage(): HTMLElement {
|
|||||||
current = null;
|
current = null;
|
||||||
showMode("logic");
|
showMode("logic");
|
||||||
if (logicMounted) {
|
if (logicMounted) {
|
||||||
if (key) notifyLogicKey(key);
|
const pending = takePendingLogicKey();
|
||||||
|
if (pending) void logicHandle?.openKey(pending);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
logicMounted = true;
|
logicMounted = true;
|
||||||
void import("./M01_MasterData_UI_Logic_Page").then((m) => {
|
void import("./M01_MasterData_UI_Logic_Page").then(async (m) => {
|
||||||
void m.mountM01Logic(logicHost, side);
|
|
||||||
const pending = takePendingLogicKey();
|
const pending = takePendingLogicKey();
|
||||||
if (pending) notifyLogicKey(pending);
|
logicHandle = await m.mountM01Logic(logicHost, side, pending ?? undefined);
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -64,10 +64,6 @@ export const ui_locales_m1 = {
|
|||||||
M01_TableUsage: ["용도", "Usage"],
|
M01_TableUsage: ["용도", "Usage"],
|
||||||
M01_TableUsageLogicCount: ["로직 {value}개", "{value} logic rules"],
|
M01_TableUsageLogicCount: ["로직 {value}개", "{value} logic rules"],
|
||||||
M01_OpenLogic: ["눌러 로직 탭으로", "Click to jump to the Logic tab"],
|
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_GroupLabor: ["인력", "Labor"],
|
||||||
M01_GroupMaterial: ["재료", "Materials"],
|
M01_GroupMaterial: ["재료", "Materials"],
|
||||||
M01_GroupMachine: ["기계", "Machines"],
|
M01_GroupMachine: ["기계", "Machines"],
|
||||||
|
|||||||
Reference in New Issue
Block a user