Визуализатор: «роль - Имя» в подсказках собирается из справочника, ключ справочника - обычный
All checks were successful
ci / test (push) Successful in 19s
ci / deploy (push) Successful in 1m27s

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-14 20:11:31 +03:00
parent 66b68cbf32
commit cf1ba11bf7
2 changed files with 24 additions and 16 deletions

View File

@@ -9,7 +9,7 @@ export interface ProcessRow {
stage: string | null;
actionName: string | null;
description: string | null;
/** ключи справочника ответственных (колонки responsible, responsible2, responsible3), вида «роль - Имя» */
/** ключи справочника ответственных (колонки responsible, responsible2, responsible3) */
responsible: string[];
/** роль первого ответственного (для дорожек ARIS); для архива khnata - колонка responsible_role */
role: string | null;
@@ -27,7 +27,7 @@ export interface ProcessRow {
/** признак вехи: колонка is_milestone; если колонки нет или она пустая - вехами считаются чек-поинты CP-* */
isMilestone: boolean;
}
/** Запись справочника ответственных: ключ `id` = «роль - Имя». */
/** Запись справочника ответственных: `id` - обычный ключ, роль и имя хранятся отдельно (склейку «роль - Имя» делает Mathesar и визуализатор). */
export interface ResponsibleRow { id: string; role: string | null; person: string | null; comment: string | null }
/** Роль (производная от справочника ответственных): имена всех ответственных этой роли. */
export interface RoleRow { id: string; person: string | null; comment: string | null }
@@ -121,9 +121,17 @@ export function buildModel(set: ProcessSet, raw: RawStar): ProcessModel {
};
}
/** Ответственные строки для подсказок: ключи «роль - Имя»; для архива (колонки роль и имя) - в прежнем виде. */
/** Ответственные для подсказок: «роль - Имя» по справочнику; для архива (колонки роль и имя) - в прежнем виде. */
export function describeResponsible(row: ProcessRow, model: ProcessModel): string {
if (row.responsible.length) return row.responsible.join("; ");
if (row.responsible.length) {
const byId = new Map(model.responsible.map((r) => [r.id, r]));
return row.responsible
.map((id) => {
const r = byId.get(id);
return r ? [r.role, r.person].filter(Boolean).join(" - ") : id;
})
.join("; ");
}
const roleLabel = row.role ? model.roles.find((r) => r.id === row.role)?.person ?? row.role : null;
return [roleLabel, row.responsibleName].filter(Boolean).join(" / ") || "не указан";
}

View File

@@ -72,25 +72,25 @@ describe("каноническая длительность", () => {
describe("справочник ответственных", () => {
const raw = {
process: [
{ id: "CP-0", responsible: "architect - RIOS", responsible2: "arch_permit_lead - Андрей", data_out1: "Plan" },
{ id: "S-1", responsible: "pm - PM" },
{ id: "CP-0", responsible: "architect", responsible2: "arch_permit_lead", data_out1: "Plan" },
{ id: "S-1", responsible: "pm" },
{ id: "S-2" },
],
refs: [
{ id: "architect - RIOS", role: "architect", person: "RIOS", comment: null },
{ id: "arch_permit_lead - Андрей", role: "arch_permit_lead", person: "Андрей", comment: "уточнить" },
{ id: "specs_client_mgr - Austin", role: "specs_client_mgr", person: "Austin", comment: null },
{ id: "specs_client_mgr - Маша", role: "specs_client_mgr", person: "Маша", comment: "делит с Austin" },
{ id: "pm - PM", role: "pm", person: "PM", comment: null },
{ id: "architect", role: "architect", person: "RIOS", comment: null },
{ id: "arch_permit_lead", role: "arch_permit_lead", person: "Андрей", comment: "уточнить" },
{ id: "specs_client_mgr", role: "specs_client_mgr", person: "Austin", comment: null },
{ id: "specs_client_mgr_2", role: "specs_client_mgr", person: "Маша", comment: "делит с Austin" },
{ id: "pm", role: "pm", person: "PM", comment: null },
],
legacyRoles: false,
systems: [],
data: [{ id: "Plan", data_description: "План", responsible: "architect - RIOS", comment: null }],
data: [{ id: "Plan", data_description: "План", responsible: "architect", comment: null }],
};
it("колонки responsible, responsible2, responsible3 дают список ключей, роль берётся у первого", () => {
const m = buildModel("khbuild", raw);
expect(m.rows[0]).toMatchObject({ responsible: ["architect - RIOS", "arch_permit_lead - Андрей"], role: "architect", responsibleName: "RIOS; Андрей" });
expect(m.rows[1]).toMatchObject({ responsible: ["pm - PM"], role: "pm" });
expect(m.rows[0]).toMatchObject({ responsible: ["architect", "arch_permit_lead"], role: "architect", responsibleName: "RIOS; Андрей" });
expect(m.rows[1]).toMatchObject({ responsible: ["pm"], role: "pm" });
expect(m.rows[2]).toMatchObject({ responsible: [], role: null });
expect(describeResponsible(m.rows[0]!, m)).toBe("architect - RIOS; arch_permit_lead - Андрей");
expect(describeResponsible(m.rows[2]!, m)).toBe("не указан");
@@ -176,8 +176,8 @@ describe("computeSchedule", () => {
const model: ProcessModel = {
set: "khbuild",
responsible: [
{ id: "architect - RIOS", role: "architect", person: "RIOS", comment: null },
{ id: "pm - PM", role: "pm", person: "PM", comment: "кто именно?" },
{ id: "architect", role: "architect", person: "RIOS", comment: null },
{ id: "pm", role: "pm", person: "PM", comment: "кто именно?" },
],
roles: [
{ id: "architect", person: "RIOS", comment: null },