Визуализатор: «роль - Имя» в подсказках собирается из справочника, ключ справочника - обычный
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -9,7 +9,7 @@ export interface ProcessRow {
|
|||||||
stage: string | null;
|
stage: string | null;
|
||||||
actionName: string | null;
|
actionName: string | null;
|
||||||
description: string | null;
|
description: string | null;
|
||||||
/** ключи справочника ответственных (колонки responsible, responsible2, responsible3), вида «роль - Имя» */
|
/** ключи справочника ответственных (колонки responsible, responsible2, responsible3) */
|
||||||
responsible: string[];
|
responsible: string[];
|
||||||
/** роль первого ответственного (для дорожек ARIS); для архива khnata - колонка responsible_role */
|
/** роль первого ответственного (для дорожек ARIS); для архива khnata - колонка responsible_role */
|
||||||
role: string | null;
|
role: string | null;
|
||||||
@@ -27,7 +27,7 @@ export interface ProcessRow {
|
|||||||
/** признак вехи: колонка is_milestone; если колонки нет или она пустая - вехами считаются чек-поинты CP-* */
|
/** признак вехи: колонка is_milestone; если колонки нет или она пустая - вехами считаются чек-поинты CP-* */
|
||||||
isMilestone: boolean;
|
isMilestone: boolean;
|
||||||
}
|
}
|
||||||
/** Запись справочника ответственных: ключ `id` = «роль - Имя». */
|
/** Запись справочника ответственных: `id` - обычный ключ, роль и имя хранятся отдельно (склейку «роль - Имя» делает Mathesar и визуализатор). */
|
||||||
export interface ResponsibleRow { id: string; role: string | null; person: string | null; comment: string | null }
|
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 }
|
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 {
|
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;
|
const roleLabel = row.role ? model.roles.find((r) => r.id === row.role)?.person ?? row.role : null;
|
||||||
return [roleLabel, row.responsibleName].filter(Boolean).join(" / ") || "не указан";
|
return [roleLabel, row.responsibleName].filter(Boolean).join(" / ") || "не указан";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,25 +72,25 @@ describe("каноническая длительность", () => {
|
|||||||
describe("справочник ответственных", () => {
|
describe("справочник ответственных", () => {
|
||||||
const raw = {
|
const raw = {
|
||||||
process: [
|
process: [
|
||||||
{ id: "CP-0", responsible: "architect - RIOS", responsible2: "arch_permit_lead - Андрей", data_out1: "Plan" },
|
{ id: "CP-0", responsible: "architect", responsible2: "arch_permit_lead", data_out1: "Plan" },
|
||||||
{ id: "S-1", responsible: "pm - PM" },
|
{ id: "S-1", responsible: "pm" },
|
||||||
{ id: "S-2" },
|
{ id: "S-2" },
|
||||||
],
|
],
|
||||||
refs: [
|
refs: [
|
||||||
{ id: "architect - RIOS", role: "architect", person: "RIOS", comment: null },
|
{ id: "architect", role: "architect", person: "RIOS", comment: null },
|
||||||
{ id: "arch_permit_lead - Андрей", role: "arch_permit_lead", person: "Андрей", comment: "уточнить" },
|
{ 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: "Austin", comment: null },
|
||||||
{ id: "specs_client_mgr - Маша", role: "specs_client_mgr", person: "Маша", comment: "делит с Austin" },
|
{ id: "specs_client_mgr_2", role: "specs_client_mgr", person: "Маша", comment: "делит с Austin" },
|
||||||
{ id: "pm - PM", role: "pm", person: "PM", comment: null },
|
{ id: "pm", role: "pm", person: "PM", comment: null },
|
||||||
],
|
],
|
||||||
legacyRoles: false,
|
legacyRoles: false,
|
||||||
systems: [],
|
systems: [],
|
||||||
data: [{ id: "Plan", data_description: "План", responsible: "architect - RIOS", comment: null }],
|
data: [{ id: "Plan", data_description: "План", responsible: "architect", comment: null }],
|
||||||
};
|
};
|
||||||
it("колонки responsible, responsible2, responsible3 дают список ключей, роль берётся у первого", () => {
|
it("колонки responsible, responsible2, responsible3 дают список ключей, роль берётся у первого", () => {
|
||||||
const m = buildModel("khbuild", raw);
|
const m = buildModel("khbuild", raw);
|
||||||
expect(m.rows[0]).toMatchObject({ responsible: ["architect - RIOS", "arch_permit_lead - Андрей"], role: "architect", responsibleName: "RIOS; Андрей" });
|
expect(m.rows[0]).toMatchObject({ responsible: ["architect", "arch_permit_lead"], role: "architect", responsibleName: "RIOS; Андрей" });
|
||||||
expect(m.rows[1]).toMatchObject({ responsible: ["pm - PM"], role: "pm" });
|
expect(m.rows[1]).toMatchObject({ responsible: ["pm"], role: "pm" });
|
||||||
expect(m.rows[2]).toMatchObject({ responsible: [], role: null });
|
expect(m.rows[2]).toMatchObject({ responsible: [], role: null });
|
||||||
expect(describeResponsible(m.rows[0]!, m)).toBe("architect - RIOS; arch_permit_lead - Андрей");
|
expect(describeResponsible(m.rows[0]!, m)).toBe("architect - RIOS; arch_permit_lead - Андрей");
|
||||||
expect(describeResponsible(m.rows[2]!, m)).toBe("не указан");
|
expect(describeResponsible(m.rows[2]!, m)).toBe("не указан");
|
||||||
@@ -176,8 +176,8 @@ describe("computeSchedule", () => {
|
|||||||
const model: ProcessModel = {
|
const model: ProcessModel = {
|
||||||
set: "khbuild",
|
set: "khbuild",
|
||||||
responsible: [
|
responsible: [
|
||||||
{ id: "architect - RIOS", role: "architect", person: "RIOS", comment: null },
|
{ id: "architect", role: "architect", person: "RIOS", comment: null },
|
||||||
{ id: "pm - PM", role: "pm", person: "PM", comment: "кто именно?" },
|
{ id: "pm", role: "pm", person: "PM", comment: "кто именно?" },
|
||||||
],
|
],
|
||||||
roles: [
|
roles: [
|
||||||
{ id: "architect", person: "RIOS", comment: null },
|
{ id: "architect", person: "RIOS", comment: null },
|
||||||
|
|||||||
Reference in New Issue
Block a user