Гант: подсказка на стрелке зависимости (от -> к, названия шагов)
All checks were successful
ci / test (push) Successful in 24s
ci / deploy (push) Successful in 1m27s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-17 13:30:50 +03:00
parent f56c19598d
commit c1e2e709e3
2 changed files with 10 additions and 1 deletions

View File

@@ -284,7 +284,9 @@ export function renderGantt(model: ProcessModel, schedule: Schedule, opts: Gantt
const x1 = from.xe;
const x2 = to.xs;
const d = x2 >= x1 ? `M${x1} ${from.y} V${to.y} H${x2}` : `M${x1} ${from.y} H${x1 + 6} V${to.y} H${x2}`;
arrows.push(`<path d="${d}" fill="none" stroke="#444" stroke-width="1.1" marker-end="url(#arr)"/>`);
const depRow = model.rows.find((r) => r.id === dep);
const label = `${dep} -> ${row.id} ${depRow?.actionName ?? ""} -> ${row.actionName ?? ""}`;
arrows.push(`<g>${tooltip([label])}<path d="${d}" fill="none" stroke="#444" stroke-width="1.1" marker-end="url(#arr)"/><path d="${d}" fill="none" stroke="transparent" stroke-width="8" pointer-events="stroke"/></g>`);
}
}
}

View File

@@ -332,6 +332,13 @@ describe("Гант: группы, вехи, свёртывание, масшта
expect(arrows(renderGantt(ms, sch, {}))).toBeGreaterThan(arrows(shut));
});
it("стрелка зависимости имеет подсказку «от -> к» с названиями шагов", () => {
const rows = [row({ id: "A", stage: "S", action_name: "Первый", duration: "1d", date_constraint: "день 0 → день 1" }), row({ id: "B", stage: "S", action_name: "Второй", depends_on: "A", duration: "1d" })];
const m: ProcessModel = { ...model, rows };
const svg = renderGantt(m, computeSchedule(rows), {});
expect(svg).toContain("<title>A -&gt; B Первый -&gt; Второй</title>");
});
it("зависимость, следующая из цепочки других, не рисуется стрелкой (A→C при A→B→C)", () => {
const rows = [row({ id: "A" }), row({ id: "B", depends_on: "A" }), row({ id: "C", depends_on: "B", depends_on2: "A" })];
const redundant = redundantDependencies(rows);