`;
- }).join('');
+ });
+
+ list.innerHTML = html;
}
export function _renderMetricTypes() {
@@ -484,7 +525,7 @@ export function deleteClientMetric(metricId, clientId) {
// Обновляем экспорт
window.SettingsLogic = {
show: showSettings,
- addRefExercise, deleteRefExercise, updateRefExerciseType,
+ addRefExercise, deleteRefExercise, updateRefExerciseType, updateRefExerciseGroup,
editRefExercise, clearAllData,
_renderRefExercises, _renderBodyMetricsList,
// Клиенты:
diff --git a/frontend/js/modals/edit-exercise-modal.js b/frontend/js/modals/edit-exercise-modal.js
index 69eae25..6f64311 100644
--- a/frontend/js/modals/edit-exercise-modal.js
+++ b/frontend/js/modals/edit-exercise-modal.js
@@ -1,28 +1,41 @@
import { showModal, closeModal } from './modal-base.js';
+import { state } from '../state.js';
+import { escapeHtml } from '../utils.js';
let _cb = null;
export function showEditExerciseDialog(exercise, callback) {
_cb = callback;
+ const groups = [...new Set(state.exerciseRef.map(e => e.group).filter(Boolean))].sort();
+
showModal(`
Редактировать упражнение
-
+
+
+
+
+
+
+ Упражнения с одинаковой группой показывают историю друг друга
+
+
@@ -34,9 +47,10 @@ export function showEditExerciseDialog(exercise, callback) {
export function submit() {
const name = document.getElementById('m-edit-ex-name').value.trim();
const type = document.getElementById('m-edit-ex-type').value;
+ const group = document.getElementById('m-edit-ex-group').value.trim();
if (!name) { alert('Название не может быть пустым'); return; }
closeModal();
- if (_cb) _cb({ name, workoutType: type });
+ if (_cb) _cb({ name, workoutType: type, group });
}
window.EditExModal = { submit };
diff --git a/frontend/js/modals/set-modal.js b/frontend/js/modals/set-modal.js
index 81f9691..bb86287 100644
--- a/frontend/js/modals/set-modal.js
+++ b/frontend/js/modals/set-modal.js
@@ -1,20 +1,43 @@
-import { showModal, closeModal, stepperHtml } from './modal-base.js';
-import { formatShortDate, formatSet } from '../utils.js';
+import { showModal, closeModal, stepperHtml, weightStep } from './modal-base.js';
+import { formatSet, escapeHtml } from '../utils.js';
let _data = {};
let _cb = null;
-export function showSetDialog(existingSet, history, callback) {
+function formatHistoryDate(iso) {
+ const d = new Date(iso);
+ return d.toLocaleDateString('ru-RU', { day: '2-digit', month: '2-digit', weekday: 'short' });
+}
+
+function formatHistoryRow(h, historyLabel) {
+ const sets = h.sets.map((s, i) =>
+ `
${i + 1}) ${escapeHtml(formatSet(s))}`).join('');
+ const isVariant = historyLabel &&
+ String(h.name || '').trim().toLowerCase() !== String(historyLabel).trim().toLowerCase();
+ const nameLabel = isVariant
+ ? `
${escapeHtml(h.name)}
` : '';
+ return `
+ ${formatHistoryDate(h.date)}
+ ${nameLabel}${sets}
+
`;
+}
+
+/**
+ * @param {object|null} existingSet - редактируемый подход
+ * @param {Array} history - прошлые выполнения [{date, name, sets}]
+ * @param {Function} callback
+ * @param {object} options - { prefill - скопировать значения прошлого подхода,
+ * historyLabel - имя текущего упражнения для подписи вариантов }
+ */
+export function showSetDialog(existingSet, history, callback, options = {}) {
_cb = callback;
const isEdit = !!existingSet;
- const isDropset = existingSet?.isDropset || false;
+ const source = existingSet || options.prefill || null; // «+ подход» стартует с прошлого веса
+ const isDropset = source?.isDropset || false;
let historyHtml = '';
if (history?.length) {
- const rows = history.map(h => `
- ${formatShortDate(h.date)}
- ${h.sets.map(formatSet).join(', ')}
-
`).join('');
+ const rows = history.map(h => formatHistoryRow(h, options.historyLabel)).join('');
historyHtml = `
📊 Прошлые тренировки
${rows}
`;
}
@@ -26,15 +49,15 @@ export function showSetDialog(existingSet, history, callback) {
Это дроп-сет
-
${stepperHtml('m-set-weight', existingSet?.weight ?? '', 0.5, 'Вес')}
-
${stepperHtml('m-set-reps', existingSet?.reps ?? '', 1, 'Повт.', 'numeric')}
+
${stepperHtml('m-set-weight', source?.weight ?? '', 0.5, 'Вес', 'decimal', true)}
+
${stepperHtml('m-set-reps', source?.reps ?? '', 1, 'Повт.', 'numeric')}
- ${[1,2,3,4,5].map(r => ``).join('')}
+ ${[1,2,3,4,5].map(r => ``).join('')}
@@ -42,8 +65,8 @@ export function showSetDialog(existingSet, history, callback) {
`);
_data = {
- isDropset, rating: existingSet?.rating || 3,
- subSets: existingSet?.subSets ? JSON.parse(JSON.stringify(existingSet.subSets)) : [],
+ isDropset, rating: source?.rating || 5,
+ subSets: source?.subSets ? JSON.parse(JSON.stringify(source.subSets)) : [],
};
if (isDropset) { if (!_data.subSets.length) addSubset(); else renderSubsets(); }
rating(_data.rating);
@@ -64,33 +87,38 @@ export function addSubset() {
}
export function renderSubsets() {
- document.getElementById('m-subsets-list').innerHTML = _data.subSets.map((s, i) => `
+ document.getElementById('m-subsets-list').innerHTML = _data.subSets.map((s, i) => {
+ const wStep = weightStep(s.weight);
+ return `
- `).join('');
+
`;
+ }).join('');
}
export function updateSubset(i, field, value) {
_data.subSets[i][field] = value;
}
-export function stepSubset(i, field, delta) {
+export function stepSubset(i, field, dir) {
const current = parseFloat(_data.subSets[i][field]) || 0;
- const step = field === 'weight' ? 0.5 : 1;
- const newVal = Math.max(0, current + delta);
+ // Вес в сбрасываниях — тоже адаптивный шаг
+ const step = field === 'weight' ? weightStep(current) : 1;
+ const newVal = Math.max(0, current + (dir > 0 ? step : -step));
_data.subSets[i][field] = parseFloat((Math.round(newVal / step) * step).toFixed(4));
- renderSubsets(); // Перерисовываем, чтобы обновить значение в input
+ renderSubsets(); // Перерисовываем, чтобы обновить значение и шаг в input
}
export function removeSubset(i) {
@@ -115,7 +143,8 @@ export function submit() {
} else {
const w = parseFloat(document.getElementById('m-set-weight').value);
const r = parseInt(document.getElementById('m-set-reps').value);
- if (!w && !r) { alert('Укажите вес и повторения'); return; }
+ // Пустой или нулевой должен быть и вес, и повторы — например «вес 0, 15 раз» с собой легитимен
+ if (!(w > 0) && !(r > 0)) { alert('Укажите вес и повторения'); return; }
closeModal(); _cb?.({ isDropset: false, weight: w||0, reps: r||0, rating: _data.rating });
}
}
diff --git a/frontend/js/render/set-row.js b/frontend/js/render/set-row.js
index 818eca2..a5bd86a 100644
--- a/frontend/js/render/set-row.js
+++ b/frontend/js/render/set-row.js
@@ -8,14 +8,19 @@ export function renderSetRow(workoutId, exerciseId, set, index, isReadOnly = fal