fix(dashboard): пустой бокс колонки прогресса, когда флешкарты отключены
#w-flashcard прятался, но он — секция внутри #w-progress-col (один .widget-бокс с рамкой/паддингом: карточка + прогресс по предметам + результаты). Если все секции скрыты (флешкарты выкл и нет данных), оставался пустой бокс. Добавлена syncProgressCol(): прячет #w-progress-col, если ни одна секция не видна (computed- display, учитывает и инъект-CSS флешкарт). Зовётся в конце loadFlashcardWidget / loadLastResultsWidget / loadSubjProgressWidget. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+18
-2
@@ -3670,12 +3670,25 @@
|
|||||||
document.getElementById('act-cal-pane').classList.toggle('visible', tab === 'calendar');
|
document.getElementById('act-cal-pane').classList.toggle('visible', tab === 'calendar');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Колонка прогресса (#w-progress-col) — это один .widget-бокс с тремя секциями
|
||||||
|
(карточка / по предметам / результаты). Если все секции скрыты (напр. флешкарты
|
||||||
|
отключены и нет данных) — прячем сам бокс, иначе висит пустая рамка. */
|
||||||
|
function syncProgressCol() {
|
||||||
|
const col = document.getElementById('w-progress-col');
|
||||||
|
if (!col) return;
|
||||||
|
const any = ['w-flashcard', 'w-subj-progress', 'w-last-results'].some(id => {
|
||||||
|
const e = document.getElementById(id);
|
||||||
|
return e && getComputedStyle(e).display !== 'none';
|
||||||
|
});
|
||||||
|
col.style.display = any ? '' : 'none';
|
||||||
|
}
|
||||||
|
|
||||||
/* ══ WIDGET: Last results (compact, 5 items) ══════════════════════ */
|
/* ══ WIDGET: Last results (compact, 5 items) ══════════════════════ */
|
||||||
function loadLastResultsWidget(rows) {
|
function loadLastResultsWidget(rows) {
|
||||||
const w = document.getElementById('w-last-results');
|
const w = document.getElementById('w-last-results');
|
||||||
if (!w) return;
|
if (!w) return;
|
||||||
const completed = (rows || []).filter(r => r.score !== null && r.total > 0).slice(0, 5);
|
const completed = (rows || []).filter(r => r.score !== null && r.total > 0).slice(0, 5);
|
||||||
if (!completed.length) { w.style.display = 'none'; return; }
|
if (!completed.length) { w.style.display = 'none'; syncProgressCol(); return; }
|
||||||
w.style.display = '';
|
w.style.display = '';
|
||||||
document.getElementById('last-results-list').innerHTML = completed.map(h => {
|
document.getElementById('last-results-list').innerHTML = completed.map(h => {
|
||||||
const pct = Math.round(h.score / h.total * 100);
|
const pct = Math.round(h.score / h.total * 100);
|
||||||
@@ -3689,6 +3702,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>`;
|
</div>`;
|
||||||
}).join('');
|
}).join('');
|
||||||
|
syncProgressCol();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ══ WIDGET: Subject progress bars ════════════════════════════════ */
|
/* ══ WIDGET: Subject progress bars ════════════════════════════════ */
|
||||||
@@ -3702,7 +3716,7 @@
|
|||||||
bySubj[r.subject_slug].scores.push(Math.round(r.score / r.total * 100));
|
bySubj[r.subject_slug].scores.push(Math.round(r.score / r.total * 100));
|
||||||
});
|
});
|
||||||
const entries = Object.entries(bySubj);
|
const entries = Object.entries(bySubj);
|
||||||
if (!entries.length) { w.style.display = 'none'; return; }
|
if (!entries.length) { w.style.display = 'none'; syncProgressCol(); return; }
|
||||||
w.style.display = '';
|
w.style.display = '';
|
||||||
document.getElementById('subj-progress-bars').innerHTML = entries.map(([slug, d]) => {
|
document.getElementById('subj-progress-bars').innerHTML = entries.map(([slug, d]) => {
|
||||||
const avg = Math.round(d.scores.reduce((a, b) => a + b, 0) / d.scores.length);
|
const avg = Math.round(d.scores.reduce((a, b) => a + b, 0) / d.scores.length);
|
||||||
@@ -3713,6 +3727,7 @@
|
|||||||
<span class="sp-pct" style="color:${color}">${avg}%</span>
|
<span class="sp-pct" style="color:${color}">${avg}%</span>
|
||||||
</div>`;
|
</div>`;
|
||||||
}).join('');
|
}).join('');
|
||||||
|
syncProgressCol();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ══ WIDGET: Theory progress ══════════════════════════════════════ */
|
/* ══ WIDGET: Theory progress ══════════════════════════════════════ */
|
||||||
@@ -4298,6 +4313,7 @@
|
|||||||
renderFlashcardWidget(r);
|
renderFlashcardWidget(r);
|
||||||
w.style.display = '';
|
w.style.display = '';
|
||||||
} catch { /* фича выключена или ошибка — оставляем скрытым */ }
|
} catch { /* фича выключена или ошибка — оставляем скрытым */ }
|
||||||
|
syncProgressCol(); // если карточка скрыта и нет прогресса/результатов — спрятать бокс
|
||||||
}
|
}
|
||||||
|
|
||||||
function renderFlashcardWidget(r) {
|
function renderFlashcardWidget(r) {
|
||||||
|
|||||||
Reference in New Issue
Block a user