Refine balance scoring and dashboard views
This commit is contained in:
+30
-12
@@ -425,7 +425,10 @@
|
||||
let minValue = Math.min(...values);
|
||||
let maxValue = Math.max(...values);
|
||||
|
||||
if (seriesName === "mood" || seriesName === "stress" || seriesName === "pain") {
|
||||
if (seriesName === "balance") {
|
||||
minValue = -2;
|
||||
maxValue = 2;
|
||||
} else if (seriesName === "mood" || seriesName === "stress" || seriesName === "pain") {
|
||||
minValue = Math.max(1, minValue - 1.5);
|
||||
maxValue = Math.min(10, maxValue + 1.5);
|
||||
} else {
|
||||
@@ -435,7 +438,10 @@
|
||||
|
||||
if ((maxValue - minValue) < 3) {
|
||||
const center = (maxValue + minValue) / 2;
|
||||
if (seriesName === "mood" || seriesName === "stress" || seriesName === "pain") {
|
||||
if (seriesName === "balance") {
|
||||
minValue = -2;
|
||||
maxValue = 2;
|
||||
} else if (seriesName === "mood" || seriesName === "stress" || seriesName === "pain") {
|
||||
minValue = Math.max(1, center - 1.5);
|
||||
maxValue = Math.min(10, center + 1.5);
|
||||
} else {
|
||||
@@ -701,7 +707,7 @@
|
||||
}
|
||||
|
||||
const title = item.entry
|
||||
? `${item.date}: ${formatNumber(Number(item.entry.score))} Punkte · ${item.entry.label}`
|
||||
? `${item.date}: ${formatNumber(Number(item.entry.score))}% Bilanz · ${item.entry.label}`
|
||||
: `${item.date}: kein Eintrag`;
|
||||
|
||||
if (!item.entry) {
|
||||
@@ -732,7 +738,7 @@
|
||||
</div>
|
||||
<div class="calendar-detail__score">
|
||||
<span data-calendar-score>${formatNumber(Number(latestVisibleEntry.score))}</span>
|
||||
<small>Punkte</small>
|
||||
<small>% Bilanz</small>
|
||||
</div>
|
||||
<a class="ghost-link calendar-detail__link" data-calendar-link href="${dashboardDayPath(latestVisibleEntry.date)}">Tag öffnen</a>
|
||||
`;
|
||||
@@ -1070,6 +1076,12 @@
|
||||
return "tone-zero";
|
||||
};
|
||||
|
||||
const signalLabels = {
|
||||
mood: { "-2": "sehr niedrig", "-1": "niedrig", 0: "neutral", 1: "hoch", 2: "sehr hoch" },
|
||||
energy: { "-2": "leer", "-1": "matt", 0: "okay", 1: "wach", 2: "kraftvoll" },
|
||||
stress: { "-2": "sehr ruhig", "-1": "ruhig", 0: "neutral", 1: "angespannt", 2: "sehr angespannt" },
|
||||
};
|
||||
|
||||
const setHidden = (element, hidden) => {
|
||||
if (!element) {
|
||||
return;
|
||||
@@ -1113,6 +1125,10 @@
|
||||
const metric = stepper.dataset.stepperMetric || "mood";
|
||||
input.value = String(current);
|
||||
value.textContent = `${current > 0 ? "+" : ""}${current}`;
|
||||
const label = stepper.querySelector("[data-stepper-label]");
|
||||
if (label) {
|
||||
label.textContent = signalLabels[metric]?.[current] || signalLabels.mood[current] || "neutral";
|
||||
}
|
||||
minus.disabled = current <= -2;
|
||||
plus.disabled = current >= 2;
|
||||
const ring = stepper.querySelector(".overlay-signal-card__ring");
|
||||
@@ -1434,20 +1450,22 @@
|
||||
let pointerStartX = 0;
|
||||
let pointerStartY = 0;
|
||||
let dragging = false;
|
||||
let ignoreSwipe = false;
|
||||
|
||||
const handleSwipe = (deltaX, deltaY) => {
|
||||
if (Math.abs(deltaX) < 70 || Math.abs(deltaY) > 50) {
|
||||
if (ignoreSwipe || document.body.classList.contains("is-dashboard-overlay-open") || Math.abs(deltaX) < 70 || Math.abs(deltaY) > 50) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (deltaX < 0 && swipeContainer.dataset.prevDate) {
|
||||
window.location.href = dashboardDayPath(swipeContainer.dataset.prevDate);
|
||||
} else if (deltaX > 0 && swipeContainer.dataset.nextDate) {
|
||||
if (deltaX < 0 && swipeContainer.dataset.nextDate) {
|
||||
window.location.href = dashboardDayPath(swipeContainer.dataset.nextDate);
|
||||
} else if (deltaX > 0 && swipeContainer.dataset.prevDate) {
|
||||
window.location.href = dashboardDayPath(swipeContainer.dataset.prevDate);
|
||||
}
|
||||
};
|
||||
|
||||
swipeContainer.addEventListener("pointerdown", event => {
|
||||
ignoreSwipe = Boolean(event.target.closest("a, button, input, textarea, select, label, [data-event-editable]"));
|
||||
dragging = true;
|
||||
pointerStartX = event.clientX;
|
||||
pointerStartY = event.clientY;
|
||||
@@ -1471,12 +1489,12 @@
|
||||
return;
|
||||
}
|
||||
|
||||
if (event.key === "ArrowLeft" && swipeContainer.dataset.prevDate) {
|
||||
window.location.href = dashboardDayPath(swipeContainer.dataset.prevDate);
|
||||
if (event.key === "ArrowLeft" && swipeContainer.dataset.nextDate) {
|
||||
window.location.href = dashboardDayPath(swipeContainer.dataset.nextDate);
|
||||
}
|
||||
|
||||
if (event.key === "ArrowRight" && swipeContainer.dataset.nextDate) {
|
||||
window.location.href = dashboardDayPath(swipeContainer.dataset.nextDate);
|
||||
if (event.key === "ArrowRight" && swipeContainer.dataset.prevDate) {
|
||||
window.location.href = dashboardDayPath(swipeContainer.dataset.prevDate);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user