fix(M02): 층 길 목록 모양 · 프로젝트 층 표는 설계값 채운 문서로 보임 (PLAN 10-1)
Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0148XFUpPfpiuTjxF1EK9c95
This commit is contained in:
@@ -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<TemplateInfo[]> =>
|
||||
call(layer === "system" ? head(layer) : `${head(layer)}${q(projectId)}`);
|
||||
/** 시스템 길은 배열 · 층 길은 `{층, 양식: [...]}` — 둘 다 목록으로 */
|
||||
export const listTemplates = async (
|
||||
layer: Layer,
|
||||
projectId: string | null,
|
||||
): Promise<TemplateInfo[]> => {
|
||||
const got = await call<TemplateInfo[] | { 양식: TemplateInfo[] }>(
|
||||
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<unknown> => call(`/projects/${enc(id)}/sources`);
|
||||
|
||||
/** 설계값을 채운 표 문서 — 서버가 그때그때 채움 · 저장 안 함 */
|
||||
export const readFilled = (id: string, name: string): Promise<TemplateDoc> =>
|
||||
call(`/projects/${enc(id)}/tables/${enc(name)}/filled`);
|
||||
|
||||
@@ -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("");
|
||||
|
||||
Reference in New Issue
Block a user