fix(features): доска уходит из сайдбара при отключении + тумблер «Теория»

1) Доска при feature_board_enabled=0 не пропадала у учителя/админа: showBoardIfAllowed()
   зовётся напрямую на ~20 страницах и показывала доску БЕЗ проверки флага, перекрывая
   hideDisabledFeatures(). Теперь функция сперва грузит features и при board===false
   держит ссылку скрытой (для всех ролей).
2) Добавлен фич-флаг theory: ключ в вайтлист updateFeatures (backend), тумблер «Теория»
   в admin → games (GAME_FEATURES), и /theory,/theory.html в map hideDisabledFeatures
   (скрытие из сайдбара + редирект с /theory при выключении). По умолчанию ВКЛ (opt-in disable).

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
Maxim Dolgolyov
2026-06-22 16:56:22 +03:00
parent 9d35aaf673
commit d8f2a7f98d
3 changed files with 8 additions and 2 deletions
+6 -1
View File
@@ -839,9 +839,13 @@ async function showBoardIfAllowed() {
if (!el) return;
const user = getUser();
if (!user) return;
const feats = await loadFeatures();
// Фича выключена (глобально или для класса) → доску не показываем, даже учителю/админу.
// Эта функция зовётся напрямую на многих страницах, поэтому проверка ОБЯЗАТЕЛЬНА,
// иначе она перекрывает скрытие из hideDisabledFeatures().
if (feats.board === false) { el.style.display = 'none'; return; }
if (user.role === 'teacher' || user.role === 'admin') { el.style.display = ''; return; }
// Student: check if in a class
const feats = await loadFeatures();
if (!feats._no_class) el.style.display = '';
}
@@ -864,6 +868,7 @@ async function hideDisabledFeatures() {
exam9: ['/exam9', '/exam9.html'],
textbooks: ['/textbooks', '/textbooks.html', '/textbook'],
quantik: ['/quantik', '/quantik.html'],
theory: ['/theory', '/theory.html'],
};
for (const [key, hrefs] of Object.entries(map)) {
if (feats[key] === false) {