Merge remote-tracking branch 'origin/sub_laptop_5' into sub_laptop_2

This commit is contained in:
2026-09-28 22:15:35 +09:00
5 changed files with 23 additions and 1 deletions
@@ -16,6 +16,8 @@ export interface TemplateInfo {
이름: string;
판: string;
수정일: string;
/** 프로그램이 이름으로 부르는 양식이면 그 쓰는 곳 — 있으면 못 지움 */
쓰는곳?: string;
}
export interface TemplateDoc {
@@ -81,7 +81,10 @@ def _path(kind: str, name: str) -> Path:
def _info(kind: str, path: Path) -> dict[str, Any]:
raw = path.read_bytes()
stamp = datetime.fromtimestamp(path.stat().st_mtime).isoformat(timespec="seconds")
return {"종류": kind, "이름": path.stem, "판": version_of(raw), "수정일": stamp}
row = {"종류": kind, "이름": path.stem, "판": version_of(raw), "수정일": stamp}
if (kind, path.stem) in IN_USE:
row["쓰는곳"] = IN_USE[(kind, path.stem)] # 화면이 지우기 확인 창 전에 막음
return row
def list_all() -> list[dict[str, Any]]:
@@ -309,6 +309,13 @@ export function buildSide(opt: SideOptions): SideHandle {
await refresh(); // 저장 직후여도 최신 판으로
const info = currentInfo();
if (!info) return;
if (info.쓰는곳) {
showToast(
L("M02_InUse").replace("{value}", info.이름).replace("{use}", info.쓰는곳),
"error",
);
return;
}
if (!(await showConfirmDialog(L("M02_DeleteConfirm").replace("{value}", info.이름)))) return;
try {
await deleteTemplate(info.종류, info.이름, info.판);
+6
View File
@@ -100,6 +100,12 @@ def test_in_use_templates_not_deleted(client):
got = client.delete(f"/api/m02/templates/{kind}/{name}")
assert got.status_code == 409 and "쓰는 양식" in got.json()["detail"]
assert client.get(f"/api/m02/templates/{kind}/{name}").status_code == 200
# 목록이 쓰는 곳을 실어 화면이 확인 창 전에 막음 · 안 쓰는 양식엔 없음
client.put("/api/m02/templates/drawing/아무도", json={"판": "", "문서": doc})
rows = {(r["종류"], r["이름"]): r for r in client.get("/api/m02/templates").json()}
for key, use in store.IN_USE.items():
assert rows[key]["쓰는곳"] == use
assert "쓰는곳" not in rows[("drawing", "아무도")]
def test_empty_doc_rejected_and_file_untouched(client):
+4
View File
@@ -23,6 +23,10 @@ export const ui_locales_m2 = {
M02_Close: ["닫기", "Close"],
M02_NameNeeded: ["이름을 적을 것", "Enter a name"],
M02_DeleteConfirm: ["「{value}」 양식을 지울까?", "Delete template “{value}”?"],
M02_InUse: [
"쓰는 양식이라 못 지움 「{value}」 — {use}",
"“{value}” is in use and cannot be deleted — {use}",
],
M02_Deleted: ["지웠음", "Deleted"],
M02_Created: ["만들었음", "Created"],
M02_Saved: ["저장했음", "Saved"],