diff --git a/B05_Profile/B05_Profile_UI_Page_Actions.ts b/B05_Profile/B05_Profile_UI_Page_Actions.ts index 6d1c8aee..8b822cad 100644 --- a/B05_Profile/B05_Profile_UI_Page_Actions.ts +++ b/B05_Profile/B05_Profile_UI_Page_Actions.ts @@ -7,10 +7,22 @@ * 세션에 쌓인 조작은 [저장]·[확정]에서만 정본으로 나간다). * ========================================================================== */ +import { ROUTES } from "@config/config_frontend"; import { currentLanguageIndex, ui_locales } from "@ui/ui_template_locale"; -import { hideLoadingOverlay, showLoadingOverlay, showToast } from "@ui/ui_template_elements"; -import { resetDesign } from "../A00_Common/design/design_reset"; -import { confirmRoute, solveRoute, type RouteLatestResponse } from "./B05_Profile_Api_Fetch"; +import { + hideLoadingOverlay, + showConfirmDialog, + showLoadingOverlay, + showToast, +} from "@ui/ui_template_elements"; +import { navigateTo } from "../A00_Common/router"; +import { + clearRouteLatestCache, + confirmRoute, + resetRouteDesign, + solveRoute, + type RouteLatestResponse, +} from "./B05_Profile_Api_Fetch"; import { flushCulvertOptions } from "../B06_Section/B06_Section_Api_Culvert_Options"; import { flushPendingPipes } from "./B05_Profile_Api_Pipes_Draft"; import { stateKey } from "../A00_Common/b_page_state"; @@ -18,8 +30,10 @@ import { invalidateSectionDetail, saveCachedCrossPatches, } from "../B06_Section/B06_Section_Section_Store"; +import { clearDrafts } from "../A00_Common/b_page_state"; import { saveCorridorIfDirty } from "./B05_Profile_UI_Corridor"; import { circlePoint, routePoint } from "./B05_Profile_UI_Page_Helpers"; +import { clearAlignmentDrafts } from "./B05_Profile_UI_Profile_Edit"; import type { createRoutePanel } from "./B05_Profile_UI_Panel"; import type { createRouteProfilePanel } from "./B05_Profile_UI_Profile_Panel"; import type { createStructuresBridge } from "./B05_Profile_UI_Page_Structures"; @@ -183,10 +197,30 @@ export async function tempSaveAction(ctx: PageActionContext): Promise { } } -/** [초기화] — 두 보기가 같은 함수를 부른다(`design_reset` · 계획서 24-2b). 페이지만 아는 - * 상단측 변경분만 여기서 비운다. */ +/** [초기화] — 사용자 편집 전부 폐기, 계획노선 CSV 기본값으로 B05·B06 재계산 후 재진입. + * 네이티브 confirm은 공용 헤드 브라우저가 자동 취소해 버튼이 죽은 듯 보였다 + * (2026-08-19 진단) — 화면 안 모달로 확인받는다. */ export async function resetDesignAction(ctx: PageActionContext): Promise { - await resetDesign(ctx.projectId, ctx.latest()?.route?.id ?? null, () => - ctx.uphillOverrides.clear(), - ); + if (!(await showConfirmDialog(L("B05_Route_Reset_Confirm"), "초기화"))) return; + showLoadingOverlay(); + try { + await resetRouteDesign(ctx.projectId); + // 옛 경로 기준 캐시를 전부 비우고 페이지를 새로 그린다 — 초기 계산본이 정본이 된다. + clearRouteLatestCache(ctx.projectId); + invalidateSectionDetail(ctx.projectId); + // 사용자 조작(② 초안)은 **등록표 한 곳**에서 통째로 버린다(2026-09-06 일원화). + // 예전에는 파일마다 따로 지워 새 값이 늘 때 빠뜨리기 쉬웠다. 노선 범위 초안은 + // 노선이 바뀌면 키가 달라져 자연히 딸려 오지 않는다. + clearDrafts(ctx.projectId, ctx.latest()?.route?.id ?? null); + ctx.uphillOverrides.clear(); + // 계획선 편집 초안도 함께 버린다 — 남기면 초기값 위에 옛 편집이 다시 얹혀 계획선이 + // 측점에서 원지반선과 만나지 않는다(2026-09-04 실측: 새로고침 후 최대 6.0m 어긋남). + clearAlignmentDrafts(); + showToast(L("B05_Route_Reset_Success"), "success"); + navigateTo(ROUTES.B05_PROFILE); + } catch (error) { + showToast(error instanceof Error ? error.message : L("B05_Route_Reset_Failed"), "error"); + } finally { + hideLoadingOverlay(); + } }