improved scoring ui + removed test data filters
Some checks failed
PHPUnit / test (push) Has been cancelled

This commit is contained in:
2026-06-08 19:38:37 +02:00
parent 11bae269e9
commit 3211d35b43
6 changed files with 317 additions and 200 deletions

View File

@ -1,7 +1,6 @@
import { apiGet, apiPost, apiPut, apiDelete } from '../api.js';
import { getRole, getUser, pageHeaderHTML, showToast } from '../app.js';
import { openAdminResetPasswordModal } from '../password-modal.js';
import { isDevTestUsername, testDataRowClassForUser } from '../test-data.js';
// Roles an admin can create; supervisors can only create coaches
const CREATEABLE_ROLES = {
@ -14,7 +13,6 @@ let supervisorsList = [];
let callerRole = '';
/** @type {Record<string, string>} */
let filterSearchByRole = { admin: '', supervisor: '', coach: '' };
let filterTestData = '';
function roleGroupsForCaller() {
return callerRole === 'supervisor'
@ -112,19 +110,7 @@ function renderUsers() {
const byRole = usersByRoleMap();
const groups = roleGroupsForCaller();
const testFilterCard = `
<div class="card" style="margin-bottom:16px">
<div class="filter-bar">
<label style="font-size:.85rem;font-weight:500">Show:</label>
<select id="userTestFilter">
<option value="">All users</option>
<option value="test" ${filterTestData === 'test' ? 'selected' : ''}>Test data only (dev_*)</option>
<option value="hide-test" ${filterTestData === 'hide-test' ? 'selected' : ''}>Hide test data</option>
</select>
</div>
</div>`;
container.innerHTML = testFilterCard + groups.map(group => {
container.innerHTML = groups.map(group => {
const allInRole = byRole[group.key] || [];
if (!allInRole.length) return '';
return `
@ -154,11 +140,6 @@ function renderUsers() {
</div>`;
}).join('');
document.getElementById('userTestFilter')?.addEventListener('change', (e) => {
filterTestData = e.target.value;
renderUsers();
});
container.addEventListener('input', (e) => {
const input = e.target.closest('.user-role-search');
if (!input) return;
@ -184,11 +165,6 @@ function filterUsers(users, roleKey) {
return hay.includes(q);
});
}
if (filterTestData === 'test') {
list = list.filter(u => isDevTestUsername(u.username));
} else if (filterTestData === 'hide-test') {
list = list.filter(u => !isDevTestUsername(u.username));
}
return list;
}
@ -302,7 +278,7 @@ function userRowHTML(u, myUsername) {
}
return `
<tr class="${testDataRowClassForUser(u.username).trim()}">
<tr>
<td>
<strong>${esc(u.username)}</strong>
${isSelf ? '<span class="badge badge-you">You</span>' : ''}