fix(indicadores): reconcile CaMa period selection and contracts

This commit is contained in:
Angel Capetillo Zavala
2026-11-12 00:39:57 -06:00
parent ce3ed34fbf
commit 5e16f5454b
6 changed files with 50 additions and 8 deletions
@@ -96,6 +96,16 @@ export class IndicadoresMemory {
applied: { tipo: 'semestre', selection: { mode: 'todos' }, revision: 0 },
};
for (const tipo of types) state.editors[tipo] ??= newEditor(tipo, 'semestre');
// Legacy CaMa selections can contain several periods although its editor now shows one.
if (domain === 'cama' && stored) {
for (const editor of Object.values(state.editors)) {
if (editor?.draft.mode === 'explicit' && editor.draft.periodos.length > 1)
editor.draft = { mode: 'explicit', periodos: [editor.draft.periodos[0]] };
}
const selection = state.applied.selection;
if (selection.mode === 'explicit' && selection.periodos.length > 1)
state.applied = { ...state.applied, selection: { mode: 'explicit', periodos: [selection.periodos[0]] }, revision: state.applied.revision + 1 };
}
// Preserve an application whose capabilities changed: consumers explain incompatibility,
// rather than silently replacing or trimming the user's temporal selection.
return state;