35 lines
1.1 KiB
JavaScript
35 lines
1.1 KiB
JavaScript
/** 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);
|
|
}
|