- 1 가림막 저장(확정)도 도중 고침 검사 · 「저장 중 고친 값」 알림(키는 안 막음 · B07~B09 안 번짐) - 2b snapOptions 간격 = 10 만 · 옛 초안 0.1 · 1 m = null(load_station_snap_step 거울) - 3 추가 측점 = 측점 묶음 data-plus · B05 누름 · 가까이 표시가 그 속성으로 - 4d 숨은 동안 고른 카드 = 다음 다시 그림 끝에 밂 · 휠 · 누름이면 버림 - 7 pipe_calc set 다섯 = 풀개 · 횡단 · 종단 보기 onDispose - 8 저장 중 [초기화] = [저장]과 같은 알림 + 막음 · /route/reset = 프로젝트 잠금 안 - 9 isUserPick 거름 = 묶음 띄운 그 누름만 · 계산 중 새 누름 = 폄 - 시험 test_505_2_save_pick 새 · 398_1 busyPick 1 · 390_5 글 맞춤 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
71 lines
3.7 KiB
TypeScript
71 lines
3.7 KiB
TypeScript
/* =============================================================================
|
|
* design_reset.ts
|
|
* [초기화] 한 줄기 — 두 보기의 아래 단추가 **같은 함수**를 부른다(계획서 24-2b).
|
|
*
|
|
* 사용자 편집 전부 폐기, 초기값(자동설계 직후 · 추천 [적용] 직후)을 작업본에 덮어쓴 뒤 재진입(재계산 아님). 네이티브 confirm 은
|
|
* 공용 헤드 브라우저가 자동 취소해 버튼이 죽은 듯 보였다(2026-08-19 진단) — 화면 안 모달로
|
|
* 확인받는다. (`B05_Profile_UI_Page_Actions.resetDesignAction` 에서 옮겨 왔다 — 동작 그대로.)
|
|
* ========================================================================== */
|
|
|
|
import { currentLanguageIndex, ui_locales } from "@ui/ui_template_locale";
|
|
import {
|
|
hideLoadingOverlay,
|
|
showConfirmDialog,
|
|
showLoadingOverlay,
|
|
showToast,
|
|
} from "@ui/ui_template_elements";
|
|
import { clearResults, clearState, namesInBucket } from "./../b_page_state";
|
|
import { clearRouteLatestCache, resetRouteDesign } from "../../B05_Profile/B05_Profile_Api_Fetch";
|
|
import { clearAlignmentDrafts } from "../../B05_Profile/B05_Profile_UI_Profile_Edit";
|
|
import { invalidateSectionDetail } from "../../B06_Section/B06_Section_Section_Store";
|
|
import { designSaveBusy, SAVE_BUSY_TEXT } from "./design_save";
|
|
|
|
function L(key: keyof typeof ui_locales): string {
|
|
return ui_locales[key][currentLanguageIndex];
|
|
}
|
|
|
|
/**
|
|
* [초기화] — 확인을 받고, 서버 초기값 복원 뒤 옛 경로 기준 캐시를 전부 비우고 종단 보기로 다시 들어간다.
|
|
* `onCleared` 는 페이지만 아는 조작 캐시(상단측 변경분 등)를 비울 자리다.
|
|
*/
|
|
export async function resetDesign(
|
|
projectId: string,
|
|
_routeId: number | null,
|
|
onCleared?: () => void,
|
|
): Promise<void> {
|
|
// 저장 중 = [저장]처럼 알림 + 막음(505-2) — 확인 창 동안 뒤 저장이 떴을 수 있어 뒤에도 봄
|
|
const saveBusy = (): boolean => {
|
|
if (designSaveBusy(projectId)) showToast(SAVE_BUSY_TEXT, "warning");
|
|
return designSaveBusy(projectId);
|
|
};
|
|
if (saveBusy() || !(await showConfirmDialog(L("B05_Route_Reset_Confirm"), "초기화"))) return;
|
|
if (saveBusy()) return;
|
|
showLoadingOverlay();
|
|
try {
|
|
await resetRouteDesign(projectId);
|
|
// 옛 경로 기준 캐시를 전부 비우고 페이지를 새로 그린다 — 초기 계산본이 정본이 된다.
|
|
clearRouteLatestCache(projectId);
|
|
invalidateSectionDetail(projectId);
|
|
// 사용자 조작(② 초안)은 **등록표 한 곳**에서 통째로 버린다(2026-09-06 일원화).
|
|
// 예전에는 파일마다 따로 지워 새 값이 늘 때 빠뜨리기 쉬웠다. 노선 범위 초안은
|
|
// 노선이 바뀌면 키가 달라져 자연히 딸려 오지 않는다.
|
|
// 복원은 새 노선 번호를 내므로 모든 노선의 초안 · 결과를 버린다(PLAN 77).
|
|
// 저장 안 한 B08 · B09 초안은 남김 — [초기화]는 B05 · B06 범위만(418).
|
|
namesInBucket("draft")
|
|
.filter((name) => !name.startsWith("b08-") && !name.startsWith("b09-"))
|
|
.forEach((name) => clearState(name, projectId));
|
|
clearResults(projectId);
|
|
onCleared?.();
|
|
// 계획선 편집 초안도 함께 버린다 — 남기면 초기값 위에 옛 편집이 다시 얹혀 계획선이
|
|
// 측점에서 원지반선과 만나지 않는다(2026-09-04 실측: 새로고침 후 최대 6.0m 어긋남).
|
|
clearAlignmentDrafts();
|
|
showToast(L("B05_Route_Reset_Success"), "success");
|
|
// 페이지를 통째로 다시 읽는다 — 제자리 다시 세우기는 옛 메모리 · 진행 중 요청이 남음(PLAN 77).
|
|
location.reload();
|
|
} catch (error) {
|
|
showToast(error instanceof Error ? error.message : L("B05_Route_Reset_Failed"), "error");
|
|
} finally {
|
|
hideLoadingOverlay();
|
|
}
|
|
}
|