diff --git a/M02_MasterTemplete/M02_MasterTemplete_Api_Fetch.ts b/M02_MasterTemplete/M02_MasterTemplete_Api_Fetch.ts index 00c8cca4..9656e6b5 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_Api_Fetch.ts +++ b/M02_MasterTemplete/M02_MasterTemplete_Api_Fetch.ts @@ -20,7 +20,8 @@ export interface TemplateInfo { export interface TemplateDoc { 종류: Kind; 이름: string; - 판: string; + /** 프로젝트 층에서 작업본이 아직 없으면(옛 프로젝트) 시스템 양식이 와서 null */ + 판: string | null; 문서: unknown; } @@ -49,8 +50,16 @@ const head = (layer: Layer): string => const item = (layer: Layer, kind: Kind, name: string, projectId: string | null): string => `${head(layer)}/${kind}/${enc(name)}${layer === "system" ? "" : q(projectId)}`; -export const listTemplates = (layer: Layer, projectId: string | null): Promise => - call(layer === "system" ? head(layer) : `${head(layer)}${q(projectId)}`); +/** 시스템 길은 배열 · 층 길은 `{층, 양식: [...]}` — 둘 다 목록으로 */ +export const listTemplates = async ( + layer: Layer, + projectId: string | null, +): Promise => { + const got = await call( + layer === "system" ? head(layer) : `${head(layer)}${q(projectId)}`, + ); + return Array.isArray(got) ? got : got.양식; +}; export const readTemplate = ( layer: Layer, @@ -103,3 +112,7 @@ export interface SourceItem { } export const fetchSources = (id: string): Promise => call(`/projects/${enc(id)}/sources`); + +/** 설계값을 채운 표 문서 — 서버가 그때그때 채움 · 저장 안 함 */ +export const readFilled = (id: string, name: string): Promise => + call(`/projects/${enc(id)}/tables/${enc(name)}/filled`); diff --git a/M02_MasterTemplete/M02_MasterTemplete_UI_Main.ts b/M02_MasterTemplete/M02_MasterTemplete_UI_Main.ts index cda7a423..04f8ee4c 100644 --- a/M02_MasterTemplete/M02_MasterTemplete_UI_Main.ts +++ b/M02_MasterTemplete/M02_MasterTemplete_UI_Main.ts @@ -7,6 +7,7 @@ import { createButton, el, showToast } from "@ui/ui_template_elements"; import { t as L } from "@ui/ui_template_locale"; import { + readFilled, readTemplate, saveTemplate, StaleError, @@ -131,9 +132,18 @@ export function createMain(isAdmin: boolean): MainHandle { try { const got = await readTemplate(next.layer, next.kind, next.name, next.projectId); if (mine !== seq) return; - version = got.판; + version = got.판 ?? ""; loaded = got.문서; - await mount(got.문서, next); + // 프로젝트 층 표 — 작업본 판은 그대로 두고 보이는 문서만 설계값으로 채움(서버가 채움 · 저장 안 함) + const shown = + next.layer === "project" && next.kind === "table" && next.projectId + ? await readFilled(next.projectId, next.name).then( + (f) => f.문서, + () => got.문서, + ) + : got.문서; + if (mine !== seq) return; + await mount(shown, next); } catch (error) { if (mine !== seq) return; empty("");