UX enhancements on data views

This commit is contained in:
2026-05-26 17:07:18 +02:00
parent 9d783b60a9
commit ea3a423186
8 changed files with 558 additions and 43 deletions

34
website/js/test-data.js Normal file
View File

@ -0,0 +1,34 @@
/** Dev fixture prefixes (import script / dev_fixture.php). */
export function isDevTestClientCode(code) {
const c = String(code ?? '').trim();
return c.toUpperCase().startsWith('DEV-CL-');
}
export function isDevTestUsername(username) {
return String(username ?? '').trim().toLowerCase().startsWith('dev_');
}
export function testDataRowClassForClient(clientCode) {
return isDevTestClientCode(clientCode) ? ' row-test-data' : '';
}
export function testDataRowClassForUser(username) {
return isDevTestUsername(username) ? ' row-test-data' : '';
}
/** Local question key from full questionID (hash__q5 → q5). */
export function questionLocalKey(questionID, fallback = '') {
const id = String(questionID ?? '');
const sep = id.lastIndexOf('__');
if (sep >= 0) return id.slice(sep + 2);
return fallback || id;
}
/** header_order.json column id → question key (questionnaire_x-y → y). */
export function headerColumnQuestionKey(headerId) {
const id = String(headerId ?? '');
if (id === 'client_code') return 'client_code';
const dash = id.indexOf('-');
if (dash < 0) return id;
return id.slice(dash + 1);
}