Гант: выделение текста только в левом списке, остальное - pan; документация структуры (этапы, системы, ключи)
Мышью выделяются названия и id активностей слева, всё остальное панорамирует картинку. Документация: справочник этапов, ссылки на системы, простые ключи справочника ответственных, удалённые шаги, оценочные длительности (отклонение 27). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -293,8 +293,8 @@ export function renderGantt(model: ProcessModel, schedule: Schedule, opts: Gantt
|
||||
const ms = row.isMilestone;
|
||||
const name = row.actionName ?? row.description ?? "";
|
||||
out.push(`<g${t.fromConstraint || t.kind === "recurring" ? "" : ' opacity="0.65"'}>${tip}`);
|
||||
out.push(`<text x="12" y="${cy + 4}" font-weight="${ms ? 700 : 500}" fill="${warn ? "#b00020" : "#222"}">${esc(row.id)}</text>`);
|
||||
out.push(`<text x="62" y="${cy + 4}" font-weight="${ms ? 600 : 400}" fill="#222">${esc(truncate(name, 52))}</text>`);
|
||||
out.push(`<text class="sel" x="12" y="${cy + 4}" font-weight="${ms ? 700 : 500}" fill="${warn ? "#b00020" : "#222"}">${esc(row.id)}</text>`);
|
||||
out.push(`<text class="sel" x="62" y="${cy + 4}" font-weight="${ms ? 600 : 400}" fill="#222">${esc(truncate(name, 52))}</text>`);
|
||||
if (row.questions) out.push(`<circle cx="${GANTT_LEFT - 14}" cy="${cy}" r="4" fill="#e6a100"><title>${esc(row.questions)}</title></circle>`);
|
||||
const stroke = warn ? "#d32f2f" : c.stroke;
|
||||
const dash = t.approx ? ' stroke-dasharray="4 2"' : "";
|
||||
|
||||
@@ -36,6 +36,8 @@ select,input[type=date]{background:var(--bg);color:var(--fg);border:1px solid va
|
||||
.warn ul{position:absolute;z-index:5;background:var(--bg);border:1px solid var(--line);padding:8px 8px 8px 26px;max-width:640px;margin:4px 0 0}
|
||||
#view{flex:1;overflow:hidden;position:relative;cursor:grab;touch-action:none}
|
||||
#view.drag{cursor:grabbing}
|
||||
#view,#view *{-webkit-user-select:none;user-select:none}
|
||||
#view .sel{-webkit-user-select:text;user-select:text;cursor:text}
|
||||
#stage{transform-origin:0 0;position:absolute;left:0;top:0}
|
||||
a.btn{color:var(--acc);text-decoration:none;border:1px solid var(--line);border-radius:6px;padding:4px 10px}
|
||||
#msg{position:absolute;left:16px;top:12px;color:var(--mut)}
|
||||
@@ -176,7 +178,10 @@ a.btn{color:var(--acc);text-decoration:none;border:1px solid var(--line);border-
|
||||
tx = mx - (mx - tx) * nk / k; ty = my - (my - ty) * nk / k; k = nk; place();
|
||||
}, { passive: false });
|
||||
var drag = null;
|
||||
view.addEventListener('pointerdown', function (e) { drag = { x: e.clientX - tx, y: e.clientY - ty, sx: e.clientX, sy: e.clientY }; view.classList.add('drag'); view.setPointerCapture(e.pointerId); });
|
||||
view.addEventListener('pointerdown', function (e) {
|
||||
// текст активностей и id в левом списке выделяется как обычный текст; всё остальное - перетаскивание (pan)
|
||||
if (e.target.closest && e.target.closest('.sel')) return;
|
||||
drag = { x: e.clientX - tx, y: e.clientY - ty, sx: e.clientX, sy: e.clientY }; view.classList.add('drag'); view.setPointerCapture(e.pointerId); });
|
||||
view.addEventListener('pointermove', function (e) { if (!drag) return; tx = e.clientX - drag.x; ty = e.clientY - drag.y; place(); });
|
||||
view.addEventListener('pointerup', function (e) {
|
||||
var moved = drag ? Math.abs(e.clientX - drag.sx) + Math.abs(e.clientY - drag.sy) : 99;
|
||||
|
||||
@@ -445,6 +445,16 @@ describe("http-api", () => {
|
||||
expect(page).toContain("get('view') === 'aris'");
|
||||
expect(page).toContain('href="../"'); // возврат к списку отчётов
|
||||
});
|
||||
it("выделение текста только у названий и id активностей слева, остальное - под перетаскивание", async () => {
|
||||
const page = (await app.inject({ url: "/", headers: { authorization: "Bearer t" } })).body;
|
||||
expect(page).toContain("#view,#view *{-webkit-user-select:none;user-select:none}");
|
||||
expect(page).toContain("#view .sel{-webkit-user-select:text;user-select:text");
|
||||
expect(page).toContain("closest('.sel')) return;"); // нажатие на выделяемый текст не запускает pan
|
||||
const svg = renderGantt(model, computeSchedule(model.rows), {});
|
||||
const sel = svg.match(/<text class="sel"/g) ?? [];
|
||||
expect(sel.length).toBe(model.rows.length * 2); // id и название каждой строки
|
||||
expect(svg).not.toMatch(/<text class="sel"[^>]*font-size="9"/); // id у полосы, подписи на оси и вех не выделяются
|
||||
});
|
||||
it("неизвестный набор данных заменяется на настроенный", async () => {
|
||||
let asked = "";
|
||||
const a = buildApi({ token: "t", defaultSet: "khbuild", load: async (s) => ((asked = s), model), dbOk: async () => true });
|
||||
|
||||
Reference in New Issue
Block a user