feat(set-groups): добавление объединений упражнений в сеты с выводом по раундам

Новые модули logic/group.js, modals/group-modal.js, render/circuit-card.js. Тренировка получает поле setGroups, состояние нормализует отсутствующие поля в loadState, удаление упражнения распускает неполные сеты.
This commit is contained in:
Иван Овчинников
2026-11-20 00:51:20 +03:00
parent 2a5c9709e0
commit 340751dd17
8 changed files with 299 additions and 10 deletions
+13
View File
@@ -50,12 +50,25 @@ export function loadState() {
if (!state.metricTypes) state.metricTypes = [];
if (!state.clients) state.clients = [];
if (!state.mode) state.mode = 'personal';
normalizeWorkouts();
} catch (e) {
console.error('Failed to load state', e);
}
}
}
// Допиваем поля, которых может не быть в сохранении старой версии
function normalizeWorkouts() {
for (const w of state.workouts || []) {
if (!Array.isArray(w.exercises)) w.exercises = [];
if (!Array.isArray(w.cardio)) w.cardio = [];
if (!Array.isArray(w.setGroups)) w.setGroups = [];
for (const ex of w.exercises) {
if (!Array.isArray(ex.sets)) ex.sets = [];
}
}
}
export function saveState() {
localStorage.setItem(STORAGE_KEY, JSON.stringify(state));
updateSyncStatus();