sdlc-hub/web/src/issues/modal.ts
Andrey Epifancev 62f6d8a11f Волна minor-находок карточки: tsbuildinfo, depth, closingDirect, имя окна, key связей
- T3.3/T4.6/O-2: *.tsbuildinfo в .gitignore
- T3.4: cardState принимает depth только целым неотрицательным, иначе 0
- T4.1: отказ от закрытия («Остаться») сбрасывает closingDirect через CloseAbortContext
- T4.4: у <dialog> запасное имя aria-label = ключ задачи (загрузка, 404, ошибка)
- T5.1: проверка закрытия формы заметки в тесте T14.1
- T5.3: уникальный key строки связи (индекс + ключ + тег)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-15 13:28:34 +04:00

24 lines
1.9 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// состояние окна карточки в записи истории (design 10–12): страница под окном, сколько записей заняли карточки
// поверх неё, открыто ли окно прямым адресом
export interface Background { pathname: string; search: string }
export interface CardState { background: Background; depth: number; direct: boolean }
export const LIST_BACKGROUND: Background = { pathname: "/issues", search: "" };
// доска не хранит состояние в адресе: «ⓘ» всегда открывает окно поверх /board
export const BOARD_CARD_STATE: CardState = { background: { pathname: "/board", search: "" }, depth: 1, direct: false };
export function cardState(s: unknown): CardState | null {
const c = s as { background?: { pathname?: unknown; search?: unknown }; depth?: unknown; direct?: unknown } | null;
if (!c || typeof c !== "object" || !c.background || typeof c.background !== "object") return null;
const { pathname, search } = c.background;
if (typeof pathname !== "string" || typeof search !== "string" || typeof c.depth !== "number") return null;
const depth = Number.isInteger(c.depth) && c.depth >= 0 ? c.depth : 0; // NaN, дробные и отрицательные не доходят до navigate(-depth)
return { background: { pathname, search }, depth, direct: c.direct === true };
}
// state ссылки на карточку: со страницы — фон = её адрес, глубина 1; из окна — тот же фон, глубина + 1
export function openCardState(loc: { pathname: string; search: string; state: unknown }): CardState {
const cur = cardState(loc.state);
return cur ? { ...cur, depth: cur.depth + 1 } : { background: { pathname: loc.pathname, search: loc.search }, depth: 1, direct: false };
}