Add visibility toggle for picks features and rename Mes choix to Mes picks

- Renamed 'Mes choix' to 'Mes picks' across all pages and JavaScript files
- Added visibility toggle in control panel (Réglages > Visibilité) to control:
  - Display of 'Mes picks' button in navigation
  - Display of 'Bon picks' column in user statistics
- Combined both visibility options into single toggle for simplicity
- Added backend API endpoints for visibility configuration
- Implemented localStorage caching for instant visibility updates
- Fixed flash of content issues when navigating between pages
- Updated stats endpoint to calculate correct picks on-the-fly from current winners
- Renamed 'Bonnes réponses' to 'Bon picks' in user statistics table
This commit is contained in:
Mathieu Moran
2025-12-27 22:03:01 -05:00
parent 1281d77c4e
commit 70b309d1ae
14 changed files with 488 additions and 314 deletions
+21
View File
@@ -649,6 +649,24 @@ window.addEventListener('DOMContentLoaded', async function () {
pageLoader.setProgress(70);
const stats = await statsRes.json();
const userTableBody = document.getElementById('user-table-body');
// Check visibility config for Bon picks column
let showBonPicksColumn = true;
try {
const visibilityRes = await fetch('/api/settings/visibility-config', { cache: 'no-store' });
if (visibilityRes.ok) {
const visibilityConfig = await visibilityRes.json();
showBonPicksColumn = visibilityConfig.showBonPicksColumn !== false;
}
} catch (err) {
console.error('Error loading visibility config:', err);
}
// Hide/show Bon picks header
const bonPicksHeader = document.getElementById('bon-picks-header');
if (bonPicksHeader) {
bonPicksHeader.style.display = showBonPicksColumn ? '' : 'none';
}
// Sort by total points (descending), then by watched ratio
stats.sort((a, b) => {
@@ -686,6 +704,9 @@ window.addEventListener('DOMContentLoaded', async function () {
const picksTd = document.createElement('td');
const pickPointsConfig = userStat.pointsConfig || { pointsPerCorrectPick: 1 };
picksTd.innerHTML = `${userStat.correctPicks || 0} <small class="text-muted">(${userStat.pickPoints || 0} pts)</small>`;
if (!showBonPicksColumn) {
picksTd.style.display = 'none';
}
const pointsTd = document.createElement('td');
pointsTd.className = 'text-center';