integrated front and back
This commit is contained in:
@@ -3,9 +3,13 @@ import { renderMainScreen } from '../render/main-screen.js';
|
||||
import { showBodyMetricsDialog } from '../modals/metrics-modal.js';
|
||||
|
||||
export function showBodyMetrics() {
|
||||
showBodyMetricsDialog(state.bodyMetrics, (newMetric) => {
|
||||
// В личном режиме — замеры без клиента
|
||||
const personalMetrics = state.bodyMetrics.filter(m => !m.client_id);
|
||||
|
||||
showBodyMetricsDialog(personalMetrics, (newMetric) => {
|
||||
if (!newMetric) return;
|
||||
newMetric.id = genId();
|
||||
newMetric.client_id = null; // личный замер
|
||||
state.bodyMetrics.unshift(newMetric);
|
||||
state.bodyMetrics.sort((a, b) => new Date(b.date) - new Date(a.date));
|
||||
saveState();
|
||||
@@ -22,10 +26,10 @@ export function editBodyMetric(metricId) {
|
||||
Object.assign(metric, updatedData);
|
||||
state.bodyMetrics.sort((a, b) => new Date(b.date) - new Date(a.date));
|
||||
saveState();
|
||||
// Если сейчас на экране настроек — перерисуем список
|
||||
// Обновляем список в настройках, если он открыт
|
||||
const list = document.getElementById('body-metrics-list');
|
||||
if (list && typeof window.SettingsLogic !== 'undefined') {
|
||||
window.SettingsLogic._renderBodyMetricsList();
|
||||
window.SettingsLogic._renderPersonalMetricsList();
|
||||
} else {
|
||||
renderMainScreen();
|
||||
}
|
||||
@@ -38,7 +42,7 @@ export function deleteMetric(id) {
|
||||
saveState();
|
||||
const list = document.getElementById('body-metrics-list');
|
||||
if (list && typeof window.SettingsLogic !== 'undefined') {
|
||||
window.SettingsLogic._renderBodyMetricsList();
|
||||
window.SettingsLogic._renderPersonalMetricsList();
|
||||
} else {
|
||||
renderMainScreen();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user