Гант: групповая полоса прерывается там, где нет активностей; справочник этапов (stages) в модели
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -31,6 +31,8 @@ export interface ProcessRow {
|
||||
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 }
|
||||
/** Этап процесса (справочник `<набор>_stages`): `id` - ключ, на который ссылается `stage` шага, `name` - название для показа. */
|
||||
export interface StageRow { id: string; name: string; comment: string | null }
|
||||
export interface SystemRow { id: string; name: string | null; comment: string | null }
|
||||
export interface DataRow { id: string; description: string | null; role: string | null; comment: string | null }
|
||||
|
||||
@@ -39,6 +41,7 @@ export interface ProcessModel {
|
||||
rows: ProcessRow[];
|
||||
responsible: ResponsibleRow[];
|
||||
roles: RoleRow[];
|
||||
stages: StageRow[];
|
||||
systems: SystemRow[];
|
||||
data: DataRow[];
|
||||
}
|
||||
@@ -74,6 +77,8 @@ export interface RawStar {
|
||||
refs: Raw[];
|
||||
/** true, если refs - прежний справочник ролей (id, role_person, comment) */
|
||||
legacyRoles: boolean;
|
||||
/** справочник этапов (khbuild_stages); нет - значит `stage` шага уже содержит название */
|
||||
stages?: Raw[];
|
||||
systems: Raw[];
|
||||
data: Raw[];
|
||||
}
|
||||
@@ -87,7 +92,11 @@ export function buildModel(set: ProcessSet, raw: RawStar): ProcessModel {
|
||||
);
|
||||
const byId = new Map(responsible.map((r) => [r.id, r]));
|
||||
|
||||
const rows = raw.process.map(mapRow).map((row) => {
|
||||
const stages: StageRow[] = (raw.stages ?? []).map((r) => ({ id: String(r.id), name: str(r.stage_name) ?? String(r.id), comment: str(r.comment) }));
|
||||
const stageName = new Map(stages.map((r) => [r.id, r.name]));
|
||||
|
||||
const rows = raw.process.map(mapRow).map((row0) => {
|
||||
const row = row0.stage !== null && stageName.has(row0.stage) ? { ...row0, stage: stageName.get(row0.stage)! } : row0;
|
||||
const refs = row.responsible.map((id) => byId.get(id));
|
||||
if (!refs.length) return row;
|
||||
return { ...row, role: refs[0]?.role ?? row.role, responsibleName: refs.map((r, i) => r?.person ?? row.responsible[i]).join("; ") };
|
||||
@@ -116,6 +125,7 @@ export function buildModel(set: ProcessSet, raw: RawStar): ProcessModel {
|
||||
rows,
|
||||
responsible,
|
||||
roles,
|
||||
stages,
|
||||
systems: raw.systems.map((r) => ({ id: String(r.id), name: str(r.system_name), comment: str(r.comment) })),
|
||||
data,
|
||||
};
|
||||
@@ -155,5 +165,11 @@ export async function loadModel(db: Queryable, set: ProcessSet): Promise<Process
|
||||
refs = await q("roles");
|
||||
legacyRoles = true;
|
||||
}
|
||||
return buildModel(set, { process, refs, legacyRoles, systems, data });
|
||||
let stages: Raw[] = [];
|
||||
try {
|
||||
stages = await q("stages");
|
||||
} catch (e) {
|
||||
if ((e as { code?: string }).code !== PG_UNDEFINED_TABLE) throw e;
|
||||
}
|
||||
return buildModel(set, { process, refs, legacyRoles, stages, systems, data });
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user